2021-04-01 22:56:33 +03:00
|
|
|
module Template.Showcase exposing (Model, Msg, template)
|
2020-05-20 16:42:52 +03:00
|
|
|
|
|
|
|
import Element exposing (Element)
|
|
|
|
import Head
|
|
|
|
import Head.Seo as Seo
|
2021-04-01 05:55:28 +03:00
|
|
|
import MarkdownRenderer
|
|
|
|
import OptimizedDecoder
|
2020-05-20 16:42:52 +03:00
|
|
|
import Pages exposing (images)
|
2021-04-01 05:55:28 +03:00
|
|
|
import Pages.StaticFile as StaticFile
|
2020-05-20 16:42:52 +03:00
|
|
|
import Pages.StaticHttp as StaticHttp
|
2020-09-12 19:15:24 +03:00
|
|
|
import Shared
|
2020-05-20 16:42:52 +03:00
|
|
|
import Showcase
|
2020-10-25 18:35:30 +03:00
|
|
|
import Template exposing (StaticPayload, TemplateWithState)
|
2020-05-20 16:42:52 +03:00
|
|
|
|
|
|
|
|
2020-08-27 07:14:52 +03:00
|
|
|
type alias Model =
|
|
|
|
()
|
|
|
|
|
|
|
|
|
2020-09-24 19:04:15 +03:00
|
|
|
type alias Msg =
|
|
|
|
Never
|
2020-05-20 16:42:52 +03:00
|
|
|
|
|
|
|
|
2021-04-02 07:23:55 +03:00
|
|
|
template : TemplateWithState {} StaticData () Msg
|
2020-06-07 02:10:18 +03:00
|
|
|
template =
|
2020-09-24 19:04:15 +03:00
|
|
|
Template.withStaticData
|
|
|
|
{ head = head
|
2021-04-05 06:47:25 +03:00
|
|
|
, staticData = \_ -> staticData
|
2020-06-07 02:10:18 +03:00
|
|
|
}
|
2020-09-24 19:04:15 +03:00
|
|
|
|> Template.buildNoState { view = view }
|
2020-06-07 02:10:18 +03:00
|
|
|
|
|
|
|
|
2021-04-01 22:56:33 +03:00
|
|
|
staticData : StaticHttp.Request StaticData
|
|
|
|
staticData =
|
2021-04-03 01:47:07 +03:00
|
|
|
Showcase.staticRequest
|
2021-04-01 05:55:28 +03:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--(StaticHttp.get
|
|
|
|
-- (Secrets.succeed "file://elm.json")
|
|
|
|
-- OptimizedDecoder.string
|
|
|
|
--)
|
|
|
|
|
|
|
|
|
|
|
|
type alias DataFromFile =
|
|
|
|
{ body : List (Element Msg), title : String }
|
|
|
|
|
|
|
|
|
|
|
|
fileRequest : StaticHttp.Request DataFromFile
|
|
|
|
fileRequest =
|
|
|
|
StaticFile.request
|
|
|
|
"content/blog/static-http.md"
|
|
|
|
(OptimizedDecoder.map2 DataFromFile
|
|
|
|
(StaticFile.body
|
|
|
|
|> OptimizedDecoder.andThen
|
|
|
|
(\rawBody ->
|
|
|
|
case rawBody |> MarkdownRenderer.view |> Result.map Tuple.second of
|
|
|
|
Ok renderedBody ->
|
|
|
|
OptimizedDecoder.succeed renderedBody
|
|
|
|
|
|
|
|
Err error ->
|
|
|
|
OptimizedDecoder.fail error
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(StaticFile.frontmatter (OptimizedDecoder.field "title" OptimizedDecoder.string))
|
|
|
|
)
|
2020-05-20 16:42:52 +03:00
|
|
|
|
2020-05-24 18:52:09 +03:00
|
|
|
|
|
|
|
type alias StaticData =
|
2021-04-03 01:47:07 +03:00
|
|
|
List Showcase.Entry
|
2020-05-24 18:52:09 +03:00
|
|
|
|
|
|
|
|
2020-08-25 07:56:38 +03:00
|
|
|
view :
|
2021-04-01 22:56:33 +03:00
|
|
|
StaticPayload StaticData
|
2021-04-01 05:55:28 +03:00
|
|
|
-> Shared.PageView Msg
|
2021-04-03 01:21:17 +03:00
|
|
|
view static =
|
2020-05-24 18:52:09 +03:00
|
|
|
{ title = "elm-pages blog"
|
|
|
|
, body =
|
2021-04-01 05:55:28 +03:00
|
|
|
let
|
2021-04-03 01:47:07 +03:00
|
|
|
showcaseEntries =
|
2021-04-01 05:55:28 +03:00
|
|
|
static.static
|
|
|
|
in
|
2020-10-25 01:46:01 +03:00
|
|
|
[ Element.column [ Element.width Element.fill ]
|
2021-04-03 01:47:07 +03:00
|
|
|
[ Element.column [ Element.padding 20, Element.centerX ] [ Showcase.view showcaseEntries ]
|
2020-05-24 18:52:09 +03:00
|
|
|
]
|
2020-10-25 01:46:01 +03:00
|
|
|
]
|
2020-05-20 16:42:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-04-01 22:56:33 +03:00
|
|
|
head : StaticPayload StaticData -> List (Head.Tag Pages.PathKey)
|
2020-09-06 22:42:05 +03:00
|
|
|
head staticPayload =
|
2020-05-24 18:52:09 +03:00
|
|
|
Seo.summary
|
|
|
|
{ canonicalUrlOverride = Nothing
|
|
|
|
, siteName = "elm-pages"
|
|
|
|
, image =
|
|
|
|
{ url = images.iconPng
|
|
|
|
, alt = "elm-pages logo"
|
|
|
|
, dimensions = Nothing
|
|
|
|
, mimeType = Nothing
|
|
|
|
}
|
|
|
|
, description = "See some neat sites built using elm-pages! (Or submit yours!)"
|
|
|
|
, locale = Nothing
|
|
|
|
, title = "elm-pages sites showcase"
|
|
|
|
}
|
|
|
|
|> Seo.website
|