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
|
2020-05-24 03:03:28 +03:00
|
|
|
import Json.Decode as Decode exposing (Decoder)
|
2021-04-01 05:55:28 +03:00
|
|
|
import MarkdownRenderer
|
|
|
|
import OptimizedDecoder
|
2020-05-20 16:42:52 +03:00
|
|
|
import Pages exposing (images)
|
2020-05-24 18:52:09 +03:00
|
|
|
import Pages.PagePath as PagePath exposing (PagePath)
|
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
|
2021-04-01 05:55:28 +03:00
|
|
|
import Secrets
|
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-09-17 07:08:12 +03:00
|
|
|
import TemplateType exposing (TemplateType)
|
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-01 22:56:33 +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
|
2020-06-07 02:10:18 +03:00
|
|
|
, staticData = staticData
|
|
|
|
}
|
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-01 05:55:28 +03:00
|
|
|
StaticHttp.map2 Tuple.pair
|
|
|
|
Showcase.staticRequest
|
|
|
|
fileRequest
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--(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-01 05:55:28 +03:00
|
|
|
( List Showcase.Entry, DataFromFile )
|
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
|
2020-09-12 19:15:24 +03:00
|
|
|
-> Shared.RenderedBody
|
2021-04-01 05:55:28 +03:00
|
|
|
-> Shared.PageView Msg
|
2021-04-01 22:56:33 +03:00
|
|
|
view static rendered =
|
2020-05-24 18:52:09 +03:00
|
|
|
{ title = "elm-pages blog"
|
|
|
|
, body =
|
2021-04-01 05:55:28 +03:00
|
|
|
let
|
|
|
|
( showcaseEntries, dataFromFile ) =
|
|
|
|
static.static
|
|
|
|
in
|
2020-10-25 01:46:01 +03:00
|
|
|
[ Element.column [ Element.width Element.fill ]
|
2021-04-01 05:55:28 +03:00
|
|
|
[ Element.text <| dataFromFile.title
|
|
|
|
, Element.column [] dataFromFile.body
|
|
|
|
|
|
|
|
--, 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
|