Simplify template.

This commit is contained in:
Dillon Kearns 2021-05-15 18:17:02 -07:00
parent 446c7998c2
commit 7bc7ea2cc7
3 changed files with 16 additions and 77 deletions

View File

@ -1,23 +1,23 @@
module Document exposing (Document, map, placeholder)
import Html.Styled exposing (text)
import Html exposing (Html)
type alias Document msg =
{ title : String
, body : List (Html.Styled.Html msg)
, body : List (Html msg)
}
map : (msg1 -> msg2) -> Document msg1 -> Document msg2
map fn doc =
{ title = doc.title
, body = List.map (Html.Styled.map fn) doc.body
, body = List.map (Html.map fn) doc.body
}
placeholder : String -> Document msg
placeholder moduleName =
{ title = "Placeholder - " ++ moduleName
, body = [ text moduleName ]
, body = [ Html.text moduleName ]
}

View File

@ -1,14 +1,11 @@
module Shared exposing (Data, Model, Msg(..), SharedMsg(..), template)
import Browser.Navigation
import Css.Global
import DataSource
import Document exposing (Document)
import Html exposing (Html)
import Html.Styled
import Pages.PagePath exposing (PagePath)
import SharedTemplate exposing (SharedTemplate)
import Tailwind.Utilities
template : SharedTemplate Msg Model Data SharedMsg msg
@ -93,12 +90,7 @@ view :
-> (Msg -> msg)
-> Document msg
-> { body : Html msg, title : String }
view stars page model toMsg pageView =
{ body =
Html.Styled.div []
(Css.Global.global Tailwind.Utilities.globalStyles
:: pageView.body
)
|> Html.Styled.toUnstyled
view sharedData page model toMsg pageView =
{ body = Html.div [] pageView.body
, title = pageView.title
}

View File

@ -1,100 +1,47 @@
module Site exposing (config)
import Cloudinary
import Color
import DataSource
import Head
import MimeType
import Pages.ImagePath as ImagePath exposing (ImagePath)
import Pages.Manifest as Manifest
import Pages.Manifest.Category
import Pages.PagePath as PagePath
import Route exposing (Route)
import SiteConfig exposing (SiteConfig)
import Sitemap
type alias Data =
()
config : SiteConfig Data
config =
\routes ->
{ data = data
, canonicalUrl = canonicalUrl
, canonicalUrl = "https://elm-pages.com"
, manifest = manifest
, head = head
}
type alias Data =
{ siteName : String
}
data : DataSource.DataSource Data
data =
DataSource.map Data
--(StaticFile.request "site-name.txt" StaticFile.body)
(DataSource.succeed "site-name")
DataSource.succeed ()
head : Data -> List Head.Tag
head static =
[ Head.icon [ ( 32, 32 ) ] MimeType.Png (cloudinaryIcon MimeType.Png 32)
, Head.icon [ ( 16, 16 ) ] MimeType.Png (cloudinaryIcon MimeType.Png 16)
, Head.appleTouchIcon (Just 180) (cloudinaryIcon MimeType.Png 180)
, Head.appleTouchIcon (Just 192) (cloudinaryIcon MimeType.Png 192)
, Head.sitemapLink "/sitemap.xml"
[ Head.sitemapLink "/sitemap.xml"
]
canonicalUrl : String
canonicalUrl =
"https://elm-pages.com"
manifest : Data -> Manifest.Config
manifest static =
Manifest.init
{ name = static.siteName
, description = "elm-pages - " ++ tagline
{ name = "Site Name"
, description = "Description"
, startUrl = PagePath.build []
, icons =
[ icon webp 192
, icon webp 512
, icon MimeType.Png 192
, icon MimeType.Png 512
]
, icons = []
}
|> Manifest.withShortName "elm-pages"
tagline : String
tagline =
"A statically typed site generator"
webp : MimeType.MimeImage
webp =
MimeType.OtherImage "webp"
icon :
MimeType.MimeImage
-> Int
-> Manifest.Icon
icon format width =
{ src = cloudinaryIcon format width
, sizes = [ ( width, width ) ]
, mimeType = format |> Just
, purposes = [ Manifest.IconPurposeAny, Manifest.IconPurposeMaskable ]
}
cloudinaryIcon :
MimeType.MimeImage
-> Int
-> ImagePath
cloudinaryIcon mimeType width =
Cloudinary.urlSquare "v1603234028/elm-pages/elm-pages-icon" (Just mimeType) width
siteMap :