mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-12-25 04:43:03 +03:00
Update content generation format.
This commit is contained in:
parent
3d8e6f1dde
commit
cfab8fcc82
@ -1,4 +1,4 @@
|
||||
module Content exposing (Content, allData, lookup)
|
||||
module Content exposing (Content, allData, buildAllData, lookup)
|
||||
|
||||
import Element exposing (Element)
|
||||
import Index
|
||||
@ -48,6 +48,45 @@ type alias Content msg =
|
||||
}
|
||||
|
||||
|
||||
buildAllData :
|
||||
{ pages : List ( List String, String ), posts : List ( List String, String ) }
|
||||
-> Result (Element msg) (Content msg)
|
||||
buildAllData record =
|
||||
case
|
||||
record.posts
|
||||
|> List.map (\( path, markup ) -> ( path, Mark.compile (MarkParser.document Element.none) markup ))
|
||||
|> combineResults
|
||||
of
|
||||
Ok postListings ->
|
||||
let
|
||||
pageListings =
|
||||
pages
|
||||
|> List.map
|
||||
(\( path, markup ) ->
|
||||
( path
|
||||
, Mark.compile
|
||||
(MarkParser.document
|
||||
(Index.view postListings)
|
||||
)
|
||||
markup
|
||||
)
|
||||
)
|
||||
|> combineResults
|
||||
in
|
||||
case pageListings of
|
||||
Ok successPageListings ->
|
||||
Ok
|
||||
{ posts = postListings
|
||||
, pages = successPageListings
|
||||
}
|
||||
|
||||
Err errors ->
|
||||
Err (renderErrors errors)
|
||||
|
||||
Err errors ->
|
||||
Err (renderErrors errors)
|
||||
|
||||
|
||||
allData : Result (Element msg) (Content msg)
|
||||
allData =
|
||||
case posts of
|
||||
|
131
gen/RawContent.elm
Normal file
131
gen/RawContent.elm
Normal file
@ -0,0 +1,131 @@
|
||||
module RawContent exposing (pages, posts)
|
||||
|
||||
import Content exposing (Content)
|
||||
import Element exposing (Element)
|
||||
|
||||
|
||||
content : Result (Element msg) (Content msg)
|
||||
content =
|
||||
Content.buildAllData { pages = pages, posts = posts }
|
||||
|
||||
|
||||
pages : List ( List String, String )
|
||||
pages =
|
||||
[ ( [ "" ]
|
||||
, """|> Article
|
||||
author = Dillon Kearns
|
||||
title = Home Page
|
||||
tags = software other
|
||||
description =
|
||||
How I learned to use elm-markup.
|
||||
|
||||
This is the home page.
|
||||
"""
|
||||
)
|
||||
, ( [ "services" ]
|
||||
, """|> Article
|
||||
author = Dillon Kearns
|
||||
title = Services
|
||||
tags = software other
|
||||
description =
|
||||
How I learned to use elm-markup.
|
||||
|
||||
Here are the services I offer.
|
||||
"""
|
||||
)
|
||||
, ( [ "about" ]
|
||||
, """|> Article
|
||||
author = Dillon Kearns
|
||||
title = How I Learned /elm-markup/
|
||||
tags = software other
|
||||
description =
|
||||
How I learned to use elm-markup.
|
||||
|
||||
dummy text of the printing and [typesetting industry]{link| url = http://mechanical-elephant.com }. Lorem Ipsum has been the industrys standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In id pellentesque elit, id sollicitudin felis. Morbi eu risus molestie enim suscipit auctor. Morbi pharetra, nisl ut finibus ornare, dolor tortor aliquet est, quis feugiat odio sem ut sem. Nullam eu bibendum ligula. Nunc mollis tortor ac rutrum interdum. Nunc ultrices risus eu pretium interdum. Nullam maximus convallis quam vitae ullamcorper. Praesent sapien nulla, hendrerit quis tincidunt a, placerat et felis. Nullam consectetur magna nec lacinia egestas. Aenean rutrum nunc diam.
|
||||
Morbi ut porta justo. Integer ac eleifend sem. Fusce sed auctor velit, et condimentum quam. Vivamus id mollis libero, mattis commodo mauris. In hac habitasse platea dictumst. Duis eu lobortis arcu, ac volutpat ante. Duis sapien enim, auctor vitae semper vitae, tincidunt et justo. Cras aliquet turpis nec enim mattis finibus. Nulla diam urna, semper ut elementum at, porttitor ut sapien. Pellentesque et dui neque. In eget lectus odio. Fusce nulla velit, eleifend sit amet malesuada ac, hendrerit id neque. Curabitur blandit elit et urna fringilla, id commodo quam fermentum.
|
||||
But for real, here's a kitten.
|
||||
|
||||
|
||||
|> Image
|
||||
src = http://placekitten.com/g/200/300
|
||||
description = What a cute kitten.
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit. In id pellentesque elit, id sollicitudin felis. Morbi eu risus molestie enim suscipit auctor. Morbi pharetra, nisl ut finibus ornare, dolor tortor aliquet est, quis feugiat odio sem ut sem. Nullam eu bibendum ligula. Nunc mollis tortor ac rutrum interdum. Nunc ultrices risus eu pretium interdum. Nullam maximus convallis quam vitae ullamcorper. Praesent sapien nulla, hendrerit quis tincidunt a, placerat et felis. Nullam consectetur magna nec lacinia egestas. Aenean rutrum nunc diam.
|
||||
Morbi ut porta justo. Integer ac eleifend sem. Fusce sed auctor velit, et condimentum quam. Vivamus id mollis libero, mattis commodo mauris. In hac habitasse platea dictumst. Duis eu lobortis arcu, ac volutpat ante. Duis sapien enim, auctor vitae semper vitae, tincidunt et justo. Cras aliquet turpis nec enim mattis finibus. Nulla diam urna, semper ut elementum at, porttitor ut sapien. Pellentesque et dui neque. In eget lectus odio. Fusce nulla velit, eleifend sit amet malesuada ac, hendrerit id neque. Curabitur blandit elit et urna fringilla, id commodo quam fermentum.
|
||||
|
||||
|> Code
|
||||
This is a code block
|
||||
With Multiple lines
|
||||
|
||||
|> H1
|
||||
Articles
|
||||
|
||||
|
||||
|> IndexContent
|
||||
posts = articles
|
||||
|
||||
Here are a few articles you might like.
|
||||
|
||||
|> H1
|
||||
My section on /lists/
|
||||
|
||||
What does a *list* look like?
|
||||
|
||||
|> List
|
||||
1. This is definitely the first thing.
|
||||
Add all together now
|
||||
With some Content
|
||||
-- Another thing.
|
||||
1. sublist
|
||||
-- more sublist
|
||||
-- indented
|
||||
-- other sublist
|
||||
-- subthing
|
||||
-- other subthing
|
||||
-- and yet, another
|
||||
-- and another one
|
||||
With some content
|
||||
"""
|
||||
)
|
||||
, ( [ "articles" ]
|
||||
, """|> Article
|
||||
author = Matthew Griffith
|
||||
title = How I Learned /elm-markup/
|
||||
tags = software other
|
||||
description =
|
||||
How I learned to use elm-markup.
|
||||
|
||||
|
||||
Here are some articles. You can learn more at.....
|
||||
|
||||
|> IndexContent
|
||||
posts = articles"""
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
posts : List ( List String, String )
|
||||
posts =
|
||||
[ ( [ "articles", "tiny-steps" ]
|
||||
, """|> Article
|
||||
author = Dillon Kearns
|
||||
title = Tiny Steps
|
||||
tags = software other
|
||||
description =
|
||||
How I learned to use elm-markup.
|
||||
|
||||
Here is an article.
|
||||
"""
|
||||
)
|
||||
, ( [ "articles", "gatekeepers" ]
|
||||
, """|> Article
|
||||
author = Dillon Kearns
|
||||
title = Gatekeepers
|
||||
tags = software other
|
||||
description =
|
||||
How I learned to use elm-markup.
|
||||
|
||||
Here is an article.
|
||||
"""
|
||||
)
|
||||
]
|
@ -15,7 +15,15 @@ port printAndExitFailure : String -> Cmd msg
|
||||
|
||||
|
||||
generate =
|
||||
interpolate """
|
||||
interpolate """module RawContent exposing (content)
|
||||
|
||||
import Content
|
||||
|
||||
|
||||
content : Result (Element msg) (Content msg)
|
||||
content =
|
||||
Content.buildAllData { pages = pages, posts = posts }
|
||||
|
||||
|
||||
pages : List ( List String, String )
|
||||
pages =
|
||||
|
Loading…
Reference in New Issue
Block a user