website/app/Route/Blog.elm

111 lines
2.6 KiB
Elm
Raw Normal View History

module Route.Blog exposing (ActionData, Data, Model, Msg, route)
import Article
import BackendTask exposing (BackendTask)
import Date exposing (Date)
import FatalError exposing (FatalError)
import Head
import Head.Seo as Seo
import Html.Styled exposing (..)
2023-12-17 04:04:06 +07:00
import Html.Styled.Attributes exposing (style)
import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Extra
import Pages.Url
import PagesMsg exposing (PagesMsg)
import Route exposing (Route)
import RouteBuilder exposing (App, StatelessRoute)
import Shared
import View exposing (View)
import Link
import Markdown.Block
import Markdown.Renderer
import MarkdownCodec
import TailwindMarkdownRenderer
import Tailwind.Utilities as Tw
type alias Model =
{}
type alias Msg =
()
type alias RouteParams =
{}
route : StatelessRoute RouteParams Data ActionData
route =
RouteBuilder.single
{ head = head
, data = data
}
|> RouteBuilder.buildNoState { view = view }
type alias Data =
List (Route, Article.ArticleMetadata)
type alias ActionData =
{}
data : BackendTask FatalError Data
data =
Article.blogAllMetadata
|> BackendTask.allowFatal
head :
App Data ActionData RouteParams
-> List Head.Tag
head app =
Seo.summary
{ canonicalUrlOverride = Nothing
2023-11-06 00:20:32 +07:00
, siteName = "nganhkhoa blogs"
, image =
2023-11-06 00:20:32 +07:00
{ url = Pages.Url.external ""
, alt = "nganhkhoa blogs"
, dimensions = Nothing
, mimeType = Nothing
}
2023-11-06 00:20:32 +07:00
, description = "blogs"
, locale = Nothing
2023-11-06 00:20:32 +07:00
, title = "nganhkhoa blogs"
}
|> Seo.website
view :
App Data ActionData RouteParams
-> Shared.Model
-> View msg
view app shared =
2023-11-06 00:20:32 +07:00
{ title = "nganhkhoa blogs"
2023-12-10 03:59:01 +07:00
, body =
[ Link.link (Link.internal (Route.Index)) []
[ text "Home" ]
2023-12-17 04:04:06 +07:00
, div
[ style "margin-top" "10px" ]
(app.data |> List.map renderBlogItem)
2023-12-10 03:59:01 +07:00
]
}
renderBlogItem : (Route, Article.ArticleMetadata) -> Html msg
renderBlogItem (route_, article) =
2023-12-17 04:04:06 +07:00
Link.link (Link.internal route_) [ style "text-decoration" "none" ]
[ div
[ style "display" "flex"
, style "justify-content" "space-between"
-- , style "margin" "auto"
, style "max-width" "550px"
]
2024-01-29 23:35:05 +07:00
[ div []
[ p [ style "color" "blue" ] [ text article.title ]
, p [ style "color" "gray" ] [ text article.subtitle ]
]
2023-12-17 04:04:06 +07:00
, p [] [text (Date.toIsoString article.published)]
]
]