From 3a54c7de1cabb72eb2937a414b1acd1da6e29fa2 Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Mon, 5 Aug 2019 11:13:42 -0700 Subject: [PATCH] Remove siteUrl argument from Pages.application. --- elm-package/src/Pages.elm | 15 +++++---------- examples/docs/src/Main.elm | 13 ++++++++----- site/src/Main.elm | 13 ++++++++----- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/elm-package/src/Pages.elm b/elm-package/src/Pages.elm index f32735fa..144da134 100644 --- a/elm-package/src/Pages.elm +++ b/elm-package/src/Pages.elm @@ -111,9 +111,8 @@ combineTupleResults input = init : (String -> view) -> Yaml.Decode.Decoder metadata - -> String -> (Json.Encode.Value -> Cmd (Msg userMsg)) - -> (String -> metadata -> List Head.Tag) + -> (metadata -> List Head.Tag) -> Parser metadata view -> Content -> (Flags userFlags -> ( userModel, Cmd userMsg )) @@ -121,7 +120,7 @@ init : -> Url -> Browser.Navigation.Key -> ( 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 ( userModel, userCmd ) = initUserModel flags @@ -180,10 +179,7 @@ init markdownToHtml frontmatterParser siteUrl toJsPort head parser content initU } , Cmd.batch ([ Content.lookup okMetadata url - |> Maybe.map - (head - (siteUrl ++ url.path) - ) + |> Maybe.map head |> Maybe.map encodeHeads |> Maybe.map toJsPort , userCmd |> Cmd.map UserMsg |> Just @@ -271,15 +267,14 @@ program : , parser : Parser metadata view , content : Content , toJsPort : Json.Encode.Value -> Cmd (Msg userMsg) - , head : String -> metadata -> List Head.Tag - , siteUrl : String + , head : metadata -> List Head.Tag , frontmatterParser : Yaml.Decode.Decoder metadata , markdownToHtml : String -> view } -> Program userFlags userModel userMsg metadata view program config = 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 , update = update config.update , subscriptions = diff --git a/examples/docs/src/Main.elm b/examples/docs/src/Main.elm index 41cdedf5..c8510de2 100644 --- a/examples/docs/src/Main.elm +++ b/examples/docs/src/Main.elm @@ -44,7 +44,6 @@ main = , markdownToHtml = markdownToHtml , toJsPort = toJsPort , head = head - , siteUrl = "https://elm-pages.com" } @@ -156,8 +155,8 @@ header = -} -head : String -> Metadata.Metadata msg -> List Head.Tag -head canonicalUrl metadata = +head : Metadata.Metadata msg -> List Head.Tag +head metadata = let themeColor = "#ffffff" @@ -165,14 +164,18 @@ head canonicalUrl metadata = [ Head.metaName "theme-color" themeColor , Head.canonicalLink canonicalUrl ] - ++ pageTags canonicalUrl metadata + ++ pageTags metadata + + +canonicalUrl = + "https://elm-pages.com" siteTagline = "A statically typed site generator - elm-pages" -pageTags canonicalUrl metadata = +pageTags metadata = case metadata of Metadata.Page record -> OpenGraph.website diff --git a/site/src/Main.elm b/site/src/Main.elm index 1efd8b59..aaff2e9f 100644 --- a/site/src/Main.elm +++ b/site/src/Main.elm @@ -42,10 +42,13 @@ main = , markdownToHtml = markdownToHtml , toJsPort = toJsPort , head = head - , siteUrl = "https://incrementalelm.com" } +siteUrl = + "https://incrementalelm.com" + + markdownToHtml : String -> Element msg markdownToHtml body = Markdown.toHtmlWith @@ -140,8 +143,8 @@ header = -} -head : String -> Metadata.Metadata msg -> List Head.Tag -head canonicalUrl metadata = +head : Metadata.Metadata msg -> List Head.Tag +head metadata = let siteName = "Incremental Elm Consulting" @@ -151,8 +154,8 @@ head canonicalUrl metadata = in [ Head.metaName "theme-color" themeColor , Head.metaProperty "og:site_name" siteName - , Head.metaProperty "og:url" canonicalUrl - , Head.canonicalLink canonicalUrl + , Head.metaProperty "og:url" siteUrl + , Head.canonicalLink siteUrl ] ++ pageTags metadata