elm-pages-v3-beta/examples/docs/src/Template/Showcase.elm

81 lines
2.0 KiB
Elm
Raw Normal View History

module Template.Showcase exposing (Model, Msg, decoder, template)
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)
import Pages exposing (images)
2020-05-24 18:52:09 +03:00
import Pages.PagePath as PagePath exposing (PagePath)
import Pages.StaticHttp as StaticHttp
2020-09-12 19:15:24 +03:00
import Shared
import Showcase
2020-10-25 18:35:30 +03:00
import Template exposing (StaticPayload, TemplateWithState)
import TemplateMetadata exposing (Showcase)
import TemplateType exposing (TemplateType)
2020-08-27 07:14:52 +03:00
type alias Model =
()
2020-09-24 19:04:15 +03:00
type alias Msg =
Never
2020-10-25 18:35:30 +03:00
template : TemplateWithState Showcase StaticData () Msg
template =
2020-09-24 19:04:15 +03:00
Template.withStaticData
{ head = head
, staticData = staticData
}
2020-09-24 19:04:15 +03:00
|> Template.buildNoState { view = view }
decoder : Decoder Showcase
2020-05-24 03:03:28 +03:00
decoder =
Decode.succeed Showcase
2020-05-24 03:03:28 +03:00
2020-09-06 23:03:46 +03:00
staticData :
List ( PagePath Pages.PathKey, TemplateType )
2020-09-06 23:03:46 +03:00
-> StaticHttp.Request StaticData
2020-05-24 18:52:09 +03:00
staticData siteMetadata =
Showcase.staticRequest
2020-05-24 18:52:09 +03:00
type alias StaticData =
List Showcase.Entry
2020-08-25 07:56:38 +03:00
view :
List ( PagePath Pages.PathKey, TemplateType )
-> StaticPayload Showcase StaticData
2020-09-12 19:15:24 +03:00
-> Shared.RenderedBody
-> Shared.PageView msg
view allMetadata static rendered =
2020-05-24 18:52:09 +03:00
{ title = "elm-pages blog"
, body =
[ Element.column [ Element.width Element.fill ]
[ Element.column [ Element.padding 20, Element.centerX ] [ Showcase.view static.static ]
2020-05-24 18:52:09 +03:00
]
]
}
2020-09-06 22:42:05 +03:00
head : StaticPayload Showcase StaticData -> List (Head.Tag Pages.PathKey)
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