mirror of
https://github.com/avinal/avinal.github.io.git
synced 2026-07-03 23:30:09 +05:30
time format improvements and word count
This commit is contained in:
+2
-2
@@ -109,7 +109,7 @@ view model =
|
||||
[ Html.a [ href <| "/posts/" ++ first.category ++ "/" ++ first.slug ]
|
||||
[ Html.h3 [ class "text-2xl font-semibold sm:text-4xl group-hover:underline group-focus:underline" ]
|
||||
[ Html.text first.title ]
|
||||
, Html.time [ class "text-gray-400", datetime first.date ] [ Html.text <| UU.getFormattedDate first.date True ]
|
||||
, Html.time [ class "text-gray-400", datetime first.date ] [ Html.text <| UU.getFormattedDate first.date False ]
|
||||
, Html.p [] [ Html.text <| String.left 200 first.description ]
|
||||
]
|
||||
, Html.a [ href <| "/posts/" ++ first.category, target "_blank" ] [ UU.categoryNtags first.category [] ]
|
||||
@@ -128,7 +128,7 @@ view model =
|
||||
, Html.div [ class "p-6 space-y-2" ]
|
||||
[ Html.a [ href <| "/posts/" ++ blog.category ++ "/" ++ blog.slug ]
|
||||
[ Html.h3 [ class "text-2xl font-semibold group-hover:underline group-focus:underline" ] [ Html.text blog.title ]
|
||||
, Html.time [ class " text-gray-400", datetime blog.date ] [ Html.text <| UU.getFormattedDate blog.date True ]
|
||||
, Html.time [ class " text-gray-400", datetime blog.date ] [ Html.text <| UU.getFormattedDate blog.date False ]
|
||||
, Html.p [] [ Html.text <| String.left 200 blog.description ]
|
||||
]
|
||||
, Html.a [ href <| "/posts/" ++ blog.category, target "_blank" ] [ UU.categoryNtags blog.category [] ]
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
module Pages.Posts.Category_.Post_ exposing (Model, Msg, page)
|
||||
|
||||
import Components.Footer exposing (avatarAndLinks)
|
||||
import Effect exposing (Effect)
|
||||
import Html exposing (Html)
|
||||
import Html.Attributes exposing (alt, class, datetime, href, id, src, title)
|
||||
import Html.Attributes exposing (alt, class, datetime, href, src, title)
|
||||
import Http
|
||||
import Layouts
|
||||
import Page exposing (Page)
|
||||
import Route exposing (Route)
|
||||
import Shared
|
||||
import String exposing (words)
|
||||
import Url exposing (Protocol(..))
|
||||
import Utils.Utils as UU
|
||||
import View exposing (View)
|
||||
@@ -52,6 +52,7 @@ type alias Model =
|
||||
type alias Blog =
|
||||
{ meta : YamlMeta
|
||||
, content : String
|
||||
, words : Int
|
||||
}
|
||||
|
||||
|
||||
@@ -131,15 +132,31 @@ view model =
|
||||
, alt blog.meta.title
|
||||
]
|
||||
[]
|
||||
, Html.h1 [ class "absolute top-3/4 left-1/2 -translate-x-1/2 -translate-y-1/2 text-center w-full" ] [ Html.text blog.meta.title ]
|
||||
, Html.h1 [ class "absolute top-3/4 left-1/2 -translate-x-1/2 -translate-y-1/2 text-center w-full" ]
|
||||
[ Html.text blog.meta.title ]
|
||||
]
|
||||
, Html.span [ class "text-base font-regular" ]
|
||||
[ Html.text "By "
|
||||
, Html.a [ href "https://avinal.space/pages/about-me", class "font-bold no-underline hover:text-pink-500" ] [ Html.text "Avinal Kumar" ]
|
||||
, Html.text " on "
|
||||
, Html.time [ datetime blog.meta.date ] [ Html.text <| UU.getFormattedDate blog.meta.date True ]
|
||||
, Html.span [ class "text-base font-light font-sans oldstyle-nums" ]
|
||||
[ Html.a [ href "/pages/about-me", class "font-bold no-underline hover:text-pink-500" ]
|
||||
[ Html.text "Avinal Kumar" ]
|
||||
, Html.text " | "
|
||||
, Html.time [ datetime blog.meta.date ] [ Html.text <| UU.getFormattedDate blog.meta.date False ]
|
||||
, Html.text <|
|
||||
" | "
|
||||
++ String.fromInt blog.words
|
||||
++ " words | ~"
|
||||
++ String.fromInt (blog.words // 200)
|
||||
++ " mins read"
|
||||
]
|
||||
, Html.span [ class "text-base font-light float-right" ]
|
||||
[ Html.a
|
||||
[ String.dropLeft 8 model.requestUrl
|
||||
|> String.dropRight 3
|
||||
|> String.append "https://null.avinal.space"
|
||||
|> href
|
||||
, class "hover:text-pink-500"
|
||||
]
|
||||
[ Html.abbr [ class "fa-solid fa-terminal no-underline", title "See a basic version of this page." ] [] ]
|
||||
]
|
||||
, Html.span [ class "text-base font-light float-right" ] [ Html.a [ href "", class "hover:text-pink-500" ] [ Html.abbr [ class "fa-solid fa-link no-underline", title "Share this article" ] [] ] ]
|
||||
, articleNode blog.content model.fragment blog.meta.title blog.meta.description
|
||||
]
|
||||
, UU.categoryNtags blog.meta.category blog.meta.tags
|
||||
@@ -204,7 +221,7 @@ splitMetaContent data =
|
||||
in
|
||||
case Yaml.fromString metaDecoder metadata of
|
||||
Ok meta ->
|
||||
Ok { meta = meta, content = content }
|
||||
Ok { meta = meta, content = content, words = List.length <| words content }
|
||||
|
||||
Err err ->
|
||||
Err ("YAML front matter parsing failed: " ++ Yaml.errorToString err)
|
||||
|
||||
+4
-3
@@ -42,7 +42,7 @@ getFormattedDate dateString time =
|
||||
"Invalid date!!"
|
||||
|
||||
else
|
||||
"Present"
|
||||
"Today"
|
||||
|
||||
|
||||
dateParser : Parser DateTime
|
||||
@@ -55,18 +55,19 @@ dateParser =
|
||||
|. token "-"
|
||||
|. chompWhile (\c -> c == '0')
|
||||
|= int
|
||||
|. spaces
|
||||
|. token "T"
|
||||
|. chompWhile (\c -> c == '0')
|
||||
|= int
|
||||
|. token ":"
|
||||
|. chompWhile (\c -> c == '0')
|
||||
|= int
|
||||
|. chompUntilEndOr "\n"
|
||||
|. end
|
||||
|
||||
|
||||
categoryNtags : String -> List String -> Html msg
|
||||
categoryNtags category tags =
|
||||
Html.span [ class "flex flex-wrap py-6 space-x-2 border-t border-dashed border-teal-500" ]
|
||||
Html.span [ class "flex flex-wrap py-6 space-x-2" ]
|
||||
(Html.a [ class "px-3 py-1 m-1 rounded-sm hover:underline bg-pink-400 text-gray-900 font-bold", href <| "/posts/" ++ category, target "_blank" ]
|
||||
[ Html.text category
|
||||
]
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user