module Static.MainLayout exposing (main) import Element exposing (..) import Element.Background as Bg import Html exposing (Html) import Html.Attributes exposing (name) import Json.Decode as D exposing (Decoder) import Markdown import Siteelm.Html as Html import Siteelm.Html.Attributes exposing (charset, content) import Siteelm.Page exposing (Page, page) import Static.View.Header as Header import Static.View.Menu as Menu exposing (Menu) main : Page Preamble main = page { decoder = preambleDecoder , head = viewHead , body = viewBody } {-| Preamble is what you write on the head of the content files. -} type alias Preamble = { title : String , menu : List Menu } {-| Preamble is passed as a JSON string. So it requires a decoder. -} preambleDecoder : Decoder Preamble preambleDecoder = D.map2 Preamble (D.field "title" D.string) (D.field "menu" (D.list Menu.decoder)) {-| Make contents inside the _head_ tag. -} viewHead : Preamble -> String -> List (Html Never) viewHead preamble _ = [ Html.meta [ charset "utf-8" ] , Html.title [] (preamble.title ++ " | siteelm") , Html.meta [ name "description", content "siteelm with elm-ui" ] ] {-| Make contents inside the _body_ tag. The parameter "body" is usually something like markdown. -} viewBody : Preamble -> String -> List (Html Never) viewBody preamble body = [ layout [] <| column [ width (px 720) , centerX ] [ Header.view , row [ spacing 8 ] [ Menu.view preamble.menu , column [] [ html (Markdown.toHtml [] body) , html <| Html.dynamic { moduleName = "Dynamic.Counter" , flags = "{value: 25}" } ] ] ] ]