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

100 lines
2.3 KiB
Elm
Raw Normal View History

module Template.Showcase exposing (Model, Msg, decoder, template)
import Element exposing (Element)
2020-08-25 07:56:38 +03:00
import Global
2020-08-23 03:37:00 +03:00
import GlobalMetadata
import Head
import Head.Seo as Seo
2020-05-24 03:03:28 +03:00
import Json.Decode as Decode exposing (Decoder)
import MarkdownRenderer
import Pages exposing (images)
2020-05-24 18:52:09 +03:00
import Pages.PagePath as PagePath exposing (PagePath)
import Pages.StaticHttp as StaticHttp
import Showcase
import Template
import TemplateDocument exposing (TemplateDocument)
import TemplateMetadata exposing (Showcase)
type Msg
= Msg
2020-08-25 07:56:38 +03:00
template : TemplateDocument Showcase StaticData Model Msg msg
template =
Template.template
{ view = view
, head = head
, staticData = staticData
, init = init
, update = update
}
update : Showcase -> Msg -> Model -> ( Model, Cmd Msg )
update metadata msg model =
( Model, Cmd.none )
decoder : Decoder Showcase
2020-05-24 03:03:28 +03:00
decoder =
Decode.succeed Showcase
2020-05-24 03:03:28 +03:00
2020-05-24 18:52:09 +03:00
staticData : a -> StaticHttp.Request StaticData
staticData siteMetadata =
Showcase.staticRequest
2020-05-24 18:52:09 +03:00
type alias StaticData =
List Showcase.Entry
init : Showcase -> ( Model, Cmd Msg )
2020-05-24 18:52:09 +03:00
init metadata =
( Model, Cmd.none )
type alias Model =
2020-05-24 18:52:09 +03:00
{}
type alias View msg =
( MarkdownRenderer.TableOfContents, List (Element msg) )
2020-08-25 07:56:38 +03:00
view :
(Msg -> msg)
-> (Global.Msg -> msg)
-> List ( PagePath Pages.PathKey, GlobalMetadata.Metadata )
-> StaticData
-> Model
-> Showcase
-> Global.RenderedBody Never
-> { title : String, body : Element Never }
view toMsg toGlobalMsg allMetadata static model metadata rendered =
2020-05-24 18:52:09 +03:00
{ title = "elm-pages blog"
, body =
Element.column [ Element.width Element.fill ]
2020-08-25 07:56:38 +03:00
[ Element.column [ Element.padding 20, Element.centerX ] [ Showcase.view static ]
2020-05-24 18:52:09 +03:00
]
}
head : StaticData -> PagePath.PagePath Pages.PathKey -> Showcase -> List (Head.Tag Pages.PathKey)
2020-05-24 18:52:09 +03:00
head static currentPath metadata =
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