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

85 lines
1.9 KiB
Elm
Raw Normal View History

2021-04-01 22:56:33 +03:00
module Template.Showcase exposing (Model, Msg, template)
2021-04-13 02:54:08 +03:00
import Document exposing (Document)
import Element exposing (Element)
import Head
import Head.Seo as Seo
import Pages.ImagePath as ImagePath
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)
2020-08-27 07:14:52 +03:00
type alias Model =
()
2020-09-24 19:04:15 +03:00
type alias Msg =
Never
2021-04-02 07:23:55 +03:00
template : TemplateWithState {} StaticData () Msg
template =
2020-09-24 19:04:15 +03:00
Template.withStaticData
{ head = head
, staticRoutes = StaticHttp.succeed []
2021-04-05 06:47:25 +03:00
, staticData = \_ -> staticData
}
2020-09-24 19:04:15 +03:00
|> Template.buildNoState { view = view }
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 }
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-05 17:48:26 +03:00
StaticPayload StaticData {}
2021-04-13 02:54:08 +03:00
-> Document 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
[ 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
]
]
}
2021-04-10 23:51:39 +03:00
head : StaticPayload StaticData {} -> List Head.Tag
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 = ImagePath.build [ "images", "icon-png.png" ]
2020-05-24 18:52:09 +03:00
, 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