diff --git a/_layout/Index.elm b/_layout/Index.elm new file mode 100644 index 00000000..98be994e --- /dev/null +++ b/_layout/Index.elm @@ -0,0 +1,43 @@ +module Index exposing (view) + +import Element exposing (Element) +import MarkParser + + +view : + List + ( List String + , { body : List (Element msg) + , metadata : MarkParser.Metadata msg + } + ) + -> Element msg +view posts = + Element.column [ Element.spacing 20 ] + (posts + |> List.map postSummary + ) + + +postSummary : + ( List String + , { body : List (Element msg) + , metadata : MarkParser.Metadata msg + } + ) + -> Element msg +postSummary ( postPath, post ) = + Element.paragraph [] post.metadata.title + |> linkToPost postPath + + +linkToPost : List String -> Element msg -> Element msg +linkToPost postPath content = + Element.link [] + { url = postUrl postPath, label = content } + + +postUrl : List String -> String +postUrl postPath = + "/" + ++ String.join "/" postPath diff --git a/elm.json b/elm.json index 0931fd51..6dee89de 100644 --- a/elm.json +++ b/elm.json @@ -2,6 +2,7 @@ "type": "application", "source-directories": [ "src", + "_layout", "gen" ], "elm-version": "0.19.0", @@ -31,4 +32,4 @@ "elm/random": "1.0.0" } } -} \ No newline at end of file +} diff --git a/gen/Content.elm b/gen/Content.elm index f1204386..eb8bcdae 100644 --- a/gen/Content.elm +++ b/gen/Content.elm @@ -1,6 +1,7 @@ module Content exposing (allData, pages, posts) import Element exposing (Element) +import Index import Mark import Mark.Error import MarkParser @@ -32,7 +33,16 @@ allData = let pageListings = pages - |> List.map (\( path, markup ) -> ( path, Mark.compile (MarkParser.document Element.none) markup )) + |> List.map + (\( path, markup ) -> + ( path + , Mark.compile + (MarkParser.document + (Index.view postListings) + ) + markup + ) + ) |> change2 in case pageListings of