elm-pages-v3-beta/examples/routing/app/Site.elm

92 lines
2.0 KiB
Elm
Raw Normal View History

2021-04-28 18:28:56 +03:00
module Site exposing (config)
import Cloudinary
2022-03-09 21:33:33 +03:00
import DataSource exposing (DataSource)
2021-04-28 18:28:56 +03:00
import Head
import MimeType
import Pages.Manifest as Manifest
import Pages.Url
2021-04-28 18:28:56 +03:00
import Route exposing (Route)
import SiteConfig exposing (SiteConfig)
2022-03-09 21:33:33 +03:00
config : SiteConfig
2021-04-28 18:28:56 +03:00
config =
2022-03-09 21:33:33 +03:00
{ canonicalUrl = canonicalUrl
2021-08-01 20:25:38 +03:00
, head = head
}
2021-04-28 18:28:56 +03:00
type alias Data =
{ siteName : String
}
2022-03-09 21:33:33 +03:00
data : DataSource Data
2021-04-28 18:28:56 +03:00
data =
DataSource.map Data
--(StaticFile.request "site-name.txt" StaticFile.body)
(DataSource.succeed "site-name")
2022-03-09 21:33:33 +03:00
head : DataSource (List Head.Tag)
head =
2021-04-28 18:28:56 +03:00
[ 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"
]
2022-03-09 21:33:33 +03:00
|> DataSource.succeed
2021-04-28 18:28:56 +03:00
canonicalUrl : String
canonicalUrl =
"https://elm-pages.com"
manifest : Data -> Manifest.Config
manifest static =
Manifest.init
{ name = static.siteName
, description = "elm-pages - " ++ tagline
2021-05-23 21:03:54 +03:00
, startUrl = Route.Slide__Number_ { number = "1" } |> Route.toPath
2021-04-28 18:28:56 +03:00
, icons =
[ icon webp 192
, icon webp 512
, icon MimeType.Png 192
, icon MimeType.Png 512
]
}
|> 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
-> Pages.Url.Url
2021-04-28 18:28:56 +03:00
cloudinaryIcon mimeType width =
Cloudinary.urlSquare "v1603234028/elm-pages/elm-pages-icon" (Just mimeType) width