Update examples.

This commit is contained in:
Dillon Kearns 2021-05-17 13:22:37 -07:00
parent 82e0d34afd
commit b33079eb71
6 changed files with 118 additions and 106 deletions

View File

@ -26,6 +26,7 @@
"cross-spawn": "7.0.3",
"elm-hot": "^1.1.6",
"elm-optimize-level-2": "^0.1.5",
"fs-extra": "^10.0.0",
"globby": "^11.0.3",
"gray-matter": "^4.0.3",
"kleur": "^4.1.4",
@ -39,11 +40,12 @@
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/fs-extra": "^9.0.11",
"@types/micromatch": "^4.0.1",
"@types/node": "12.20.12",
"@types/serve-static": "^1.13.9",
"elm-review": "^2.5.0",
"elm-test": "^0.19.1-revision6",
"elm-review": "^2.5.1",
"elm-test": "^0.19.1-revision7",
"elm-tooling": "^1.3.0",
"mocha": "^8.4.0",
"typescript": "^4.2.4"
@ -1485,6 +1487,7 @@
"version": "file:../..",
"requires": {
"@types/cross-spawn": "^6.0.2",
"@types/fs-extra": "^9.0.11",
"@types/micromatch": "^4.0.1",
"@types/node": "12.20.12",
"@types/serve-static": "^1.13.9",
@ -1494,9 +1497,10 @@
"cross-spawn": "7.0.3",
"elm-hot": "^1.1.6",
"elm-optimize-level-2": "^0.1.5",
"elm-review": "^2.5.0",
"elm-test": "^0.19.1-revision6",
"elm-review": "^2.5.1",
"elm-test": "^0.19.1-revision7",
"elm-tooling": "^1.3.0",
"fs-extra": "^10.0.0",
"globby": "^11.0.3",
"gray-matter": "^4.0.3",
"kleur": "^4.1.4",

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

@ -0,0 +1,66 @@
module Page.Index exposing (Model, Msg, Data, page)
import Element exposing (Element)
import Document exposing (Document)
import Pages.ImagePath as ImagePath
import Head
import Head.Seo as Seo
import DataSource exposing (DataSource)
import Shared
import Page exposing (StaticPayload, Page, PageWithState)
type alias Model =
()
type alias Msg =
Never
type alias RouteParams =
{}
page : Page RouteParams Data
page =
Page.singleRoute
{ head = head
, data = data
}
|> Page.buildNoState { view = view }
data : DataSource Data
data =
DataSource.succeed ()
head :
StaticPayload Data RouteParams
-> List Head.Tag
head static =
Seo.summary
{ canonicalUrlOverride = Nothing
, siteName = "elm-pages"
, image =
{ url = ImagePath.build [ "TODO" ]
, alt = "elm-pages logo"
, dimensions = Nothing
, mimeType = Nothing
}
, description = "TODO"
, locale = Nothing
, title = "TODO title" -- metadata.title -- TODO
}
|> Seo.website
type alias Data =
()
view :
StaticPayload Data RouteParams
-> Document Msg
view static =
Document.placeholder "Index"

View File

@ -1,14 +1,12 @@
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.Flags
import Pages.PagePath exposing (PagePath)
import SharedTemplate exposing (SharedTemplate)
import Tailwind.Utilities
template : SharedTemplate Msg Model Data SharedMsg msg
@ -47,6 +45,7 @@ type alias Model =
init :
Maybe Browser.Navigation.Key
-> Pages.Flags.Flags
->
Maybe
{ path :
@ -57,7 +56,7 @@ init :
, metadata : route
}
-> ( Model, Cmd Msg )
init _ maybePagePath =
init _ flags maybePagePath =
( { showMobileMenu = False }
, Cmd.none
)
@ -93,12 +92,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 :

View File

@ -26,12 +26,13 @@
"cross-spawn": "7.0.3",
"elm-hot": "^1.1.6",
"elm-optimize-level-2": "^0.1.5",
"fs-extra": "^10.0.0",
"globby": "^11.0.3",
"gray-matter": "^4.0.2",
"kleur": "^3.0.3",
"micromatch": "^4.0.2",
"gray-matter": "^4.0.3",
"kleur": "^4.1.4",
"micromatch": "^4.0.4",
"serve-static": "^1.14.1",
"terser": "^5.6.1",
"terser": "^5.7.0",
"xhr2": "^0.2.1"
},
"bin": {
@ -39,14 +40,15 @@
},
"devDependencies": {
"@types/cross-spawn": "^6.0.2",
"@types/fs-extra": "^9.0.11",
"@types/micromatch": "^4.0.1",
"@types/node": "^12.7.7",
"@types/node": "12.20.12",
"@types/serve-static": "^1.13.9",
"elm-review": "^2.5.0",
"elm-test": "^0.19.1-revision6",
"elm-review": "^2.5.1",
"elm-test": "^0.19.1-revision7",
"elm-tooling": "^1.3.0",
"mocha": "^8.3.2",
"typescript": "^4.2.3"
"mocha": "^8.4.0",
"typescript": "^4.2.4"
}
},
"../../node_modules/@nodelib/fs.scandir": {
@ -1488,8 +1490,9 @@
"version": "file:../..",
"requires": {
"@types/cross-spawn": "^6.0.2",
"@types/fs-extra": "^9.0.11",
"@types/micromatch": "^4.0.1",
"@types/node": "^12.7.7",
"@types/node": "12.20.12",
"@types/serve-static": "^1.13.9",
"chokidar": "^3.5.1",
"commander": "^7.2.0",
@ -1497,17 +1500,18 @@
"cross-spawn": "7.0.3",
"elm-hot": "^1.1.6",
"elm-optimize-level-2": "^0.1.5",
"elm-review": "^2.5.0",
"elm-test": "^0.19.1-revision6",
"elm-review": "^2.5.1",
"elm-test": "^0.19.1-revision7",
"elm-tooling": "^1.3.0",
"fs-extra": "^10.0.0",
"globby": "^11.0.3",
"gray-matter": "^4.0.2",
"kleur": "^3.0.3",
"micromatch": "^4.0.2",
"mocha": "^8.3.2",
"gray-matter": "^4.0.3",
"kleur": "^4.1.4",
"micromatch": "^4.0.4",
"mocha": "^8.4.0",
"serve-static": "^1.14.1",
"terser": "^5.6.1",
"typescript": "^4.2.3",
"terser": "^5.7.0",
"typescript": "^4.2.4",
"xhr2": "^0.2.1"
},
"dependencies": {
@ -1861,8 +1865,7 @@
}
},
"gray-matter": {
"version": "4.0.2",
"resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.2.tgz",
"version": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.2.tgz",
"integrity": "sha512-7hB/+LxrOjq/dd8APlK0r24uL/67w7SkYnfwhNFwg/VDIGWGmduTDYf3WNstLW2fbbmRwrDGCVSJ2isuf2+4Hw==",
"dev": true,
"requires": {
@ -1963,8 +1966,7 @@
"dev": true
},
"kleur": {
"version": "3.0.3",
"resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
"version": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz",
"integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==",
"dev": true
},
@ -2319,8 +2321,7 @@
}
},
"terser": {
"version": "5.6.1",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.6.1.tgz",
"version": "https://registry.npmjs.org/terser/-/terser-5.6.1.tgz",
"integrity": "sha512-yv9YLFQQ+3ZqgWCUk+pvNJwgUTdlIxUk1WTN+RnaFJe2L7ipG2csPT0ra2XRm7Cs8cxN7QXmK1rFzEwYEQkzXw==",
"dev": true,
"requires": {