Remove siteUrl argument from Pages.application.

This commit is contained in:
Dillon Kearns 2019-08-05 11:13:42 -07:00
parent 51f24dcc9b
commit 3a54c7de1c
3 changed files with 21 additions and 20 deletions

View File

@ -111,9 +111,8 @@ combineTupleResults input =
init : init :
(String -> view) (String -> view)
-> Yaml.Decode.Decoder metadata -> Yaml.Decode.Decoder metadata
-> String
-> (Json.Encode.Value -> Cmd (Msg userMsg)) -> (Json.Encode.Value -> Cmd (Msg userMsg))
-> (String -> metadata -> List Head.Tag) -> (metadata -> List Head.Tag)
-> Parser metadata view -> Parser metadata view
-> Content -> Content
-> (Flags userFlags -> ( userModel, Cmd userMsg )) -> (Flags userFlags -> ( userModel, Cmd userMsg ))
@ -121,7 +120,7 @@ init :
-> Url -> Url
-> Browser.Navigation.Key -> Browser.Navigation.Key
-> ( Model userModel userMsg metadata view, Cmd (Msg userMsg) ) -> ( Model userModel userMsg metadata view, Cmd (Msg userMsg) )
init markdownToHtml frontmatterParser siteUrl toJsPort head parser content initUserModel flags url key = init markdownToHtml frontmatterParser toJsPort head parser content initUserModel flags url key =
let let
( userModel, userCmd ) = ( userModel, userCmd ) =
initUserModel flags initUserModel flags
@ -180,10 +179,7 @@ init markdownToHtml frontmatterParser siteUrl toJsPort head parser content initU
} }
, Cmd.batch , Cmd.batch
([ Content.lookup okMetadata url ([ Content.lookup okMetadata url
|> Maybe.map |> Maybe.map head
(head
(siteUrl ++ url.path)
)
|> Maybe.map encodeHeads |> Maybe.map encodeHeads
|> Maybe.map toJsPort |> Maybe.map toJsPort
, userCmd |> Cmd.map UserMsg |> Just , userCmd |> Cmd.map UserMsg |> Just
@ -271,15 +267,14 @@ program :
, parser : Parser metadata view , parser : Parser metadata view
, content : Content , content : Content
, toJsPort : Json.Encode.Value -> Cmd (Msg userMsg) , toJsPort : Json.Encode.Value -> Cmd (Msg userMsg)
, head : String -> metadata -> List Head.Tag , head : metadata -> List Head.Tag
, siteUrl : String
, frontmatterParser : Yaml.Decode.Decoder metadata , frontmatterParser : Yaml.Decode.Decoder metadata
, markdownToHtml : String -> view , markdownToHtml : String -> view
} }
-> Program userFlags userModel userMsg metadata view -> Program userFlags userModel userMsg metadata view
program config = program config =
Browser.application Browser.application
{ init = init config.markdownToHtml config.frontmatterParser config.siteUrl config.toJsPort config.head config.parser config.content config.init { init = init config.markdownToHtml config.frontmatterParser config.toJsPort config.head config.parser config.content config.init
, view = view config.content config.parser config.view , view = view config.content config.parser config.view
, update = update config.update , update = update config.update
, subscriptions = , subscriptions =

View File

@ -44,7 +44,6 @@ main =
, markdownToHtml = markdownToHtml , markdownToHtml = markdownToHtml
, toJsPort = toJsPort , toJsPort = toJsPort
, head = head , head = head
, siteUrl = "https://elm-pages.com"
} }
@ -156,8 +155,8 @@ header =
<https://html.spec.whatwg.org/multipage/semantics.html#standard-metadata-names> <https://html.spec.whatwg.org/multipage/semantics.html#standard-metadata-names>
<https://ogp.me/> <https://ogp.me/>
-} -}
head : String -> Metadata.Metadata msg -> List Head.Tag head : Metadata.Metadata msg -> List Head.Tag
head canonicalUrl metadata = head metadata =
let let
themeColor = themeColor =
"#ffffff" "#ffffff"
@ -165,14 +164,18 @@ head canonicalUrl metadata =
[ Head.metaName "theme-color" themeColor [ Head.metaName "theme-color" themeColor
, Head.canonicalLink canonicalUrl , Head.canonicalLink canonicalUrl
] ]
++ pageTags canonicalUrl metadata ++ pageTags metadata
canonicalUrl =
"https://elm-pages.com"
siteTagline = siteTagline =
"A statically typed site generator - elm-pages" "A statically typed site generator - elm-pages"
pageTags canonicalUrl metadata = pageTags metadata =
case metadata of case metadata of
Metadata.Page record -> Metadata.Page record ->
OpenGraph.website OpenGraph.website

View File

@ -42,10 +42,13 @@ main =
, markdownToHtml = markdownToHtml , markdownToHtml = markdownToHtml
, toJsPort = toJsPort , toJsPort = toJsPort
, head = head , head = head
, siteUrl = "https://incrementalelm.com"
} }
siteUrl =
"https://incrementalelm.com"
markdownToHtml : String -> Element msg markdownToHtml : String -> Element msg
markdownToHtml body = markdownToHtml body =
Markdown.toHtmlWith Markdown.toHtmlWith
@ -140,8 +143,8 @@ header =
<https://html.spec.whatwg.org/multipage/semantics.html#standard-metadata-names> <https://html.spec.whatwg.org/multipage/semantics.html#standard-metadata-names>
<https://ogp.me/> <https://ogp.me/>
-} -}
head : String -> Metadata.Metadata msg -> List Head.Tag head : Metadata.Metadata msg -> List Head.Tag
head canonicalUrl metadata = head metadata =
let let
siteName = siteName =
"Incremental Elm Consulting" "Incremental Elm Consulting"
@ -151,8 +154,8 @@ head canonicalUrl metadata =
in in
[ Head.metaName "theme-color" themeColor [ Head.metaName "theme-color" themeColor
, Head.metaProperty "og:site_name" siteName , Head.metaProperty "og:site_name" siteName
, Head.metaProperty "og:url" canonicalUrl , Head.metaProperty "og:url" siteUrl
, Head.canonicalLink canonicalUrl , Head.canonicalLink siteUrl
] ]
++ pageTags metadata ++ pageTags metadata