mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-25 09:21:57 +03:00
Lookup articles.
This commit is contained in:
parent
5d1b5e6b76
commit
d0674f809f
39
src/Main.elm
39
src/Main.elm
@ -75,8 +75,15 @@ view model =
|
||||
}
|
||||
|
||||
|
||||
lookupPage : Url -> Maybe String
|
||||
lookupPage url =
|
||||
lookupPage :
|
||||
Content msg
|
||||
-> Url
|
||||
->
|
||||
Maybe
|
||||
{ body : List (Element msg)
|
||||
, metadata : MarkParser.Metadata msg
|
||||
}
|
||||
lookupPage content url =
|
||||
List.Extra.find
|
||||
(\( path, markup ) ->
|
||||
(String.split "/" url.path
|
||||
@ -84,9 +91,9 @@ lookupPage url =
|
||||
)
|
||||
== path
|
||||
)
|
||||
-- (
|
||||
Content.pages
|
||||
-- ++ Content.posts)
|
||||
(content.pages
|
||||
++ content.posts
|
||||
)
|
||||
|> Maybe.map Tuple.second
|
||||
|
||||
|
||||
@ -102,24 +109,10 @@ mainView url =
|
||||
|
||||
pageView : Content msg -> Url -> Element msg
|
||||
pageView content url =
|
||||
case lookupPage url of
|
||||
Just page ->
|
||||
case Mark.compile (MarkParser.document Element.none) page of
|
||||
Mark.Success markup ->
|
||||
markup.body
|
||||
|> Element.textColumn [ Element.width Element.fill ]
|
||||
|
||||
Mark.Almost { errors, result } ->
|
||||
errors
|
||||
|> List.map (Mark.Error.toHtml Mark.Error.Light)
|
||||
|> List.map Element.html
|
||||
|> Element.column []
|
||||
|
||||
Mark.Failure errors ->
|
||||
errors
|
||||
|> List.map (Mark.Error.toHtml Mark.Error.Light)
|
||||
|> List.map Element.html
|
||||
|> Element.column []
|
||||
case lookupPage content url of
|
||||
Just pageOrPost ->
|
||||
pageOrPost.body
|
||||
|> Element.textColumn [ Element.width Element.fill ]
|
||||
|
||||
Nothing ->
|
||||
Element.column []
|
||||
|
Loading…
Reference in New Issue
Block a user