From 2c903b912271558a9cfbe62d370021f1f524fbf1 Mon Sep 17 00:00:00 2001 From: Dillon Kearns Date: Thu, 23 Jan 2020 19:48:23 -0800 Subject: [PATCH] Add head tag for rss feed. --- examples/docs/src/Feed.elm | 2 +- examples/docs/src/Main.elm | 204 +++++++++++++++++++------------------ src/Head.elm | 4 +- 3 files changed, 109 insertions(+), 101 deletions(-) diff --git a/examples/docs/src/Feed.elm b/examples/docs/src/Feed.elm index 1be792e5..78b38df4 100644 --- a/examples/docs/src/Feed.elm +++ b/examples/docs/src/Feed.elm @@ -25,7 +25,7 @@ fileToGenerate : , content : String } fileToGenerate config siteMetadata = - { path = [ "feed.xml" ] + { path = [ "blog", "feed.xml" ] , content = generate config siteMetadata |> Xml.Encode.encode 0 } diff --git a/examples/docs/src/Main.elm b/examples/docs/src/Main.elm index d7f23a00..6cd8a35f 100644 --- a/examples/docs/src/Main.elm +++ b/examples/docs/src/Main.elm @@ -389,6 +389,12 @@ highlightableLink currentPath linkDirectory displayName = } +commonHeadTags : List (Head.Tag Pages.PathKey) +commonHeadTags = + [ Head.rssLink "/blog/feed.xml" + ] + + {-| @@ -396,111 +402,113 @@ highlightableLink currentPath linkDirectory displayName = -} head : Metadata -> List (Head.Tag Pages.PathKey) head metadata = - case metadata of - Metadata.Page meta -> - Seo.summaryLarge - { canonicalUrlOverride = Nothing - , siteName = "elm-pages" - , image = - { url = images.iconPng - , alt = "elm-pages logo" - , dimensions = Nothing - , mimeType = Nothing - } - , description = siteTagline - , locale = Nothing - , title = meta.title - } - |> Seo.website + commonHeadTags + ++ (case metadata of + Metadata.Page meta -> + Seo.summaryLarge + { canonicalUrlOverride = Nothing + , siteName = "elm-pages" + , image = + { url = images.iconPng + , alt = "elm-pages logo" + , dimensions = Nothing + , mimeType = Nothing + } + , description = siteTagline + , locale = Nothing + , title = meta.title + } + |> Seo.website - Metadata.Doc meta -> - Seo.summaryLarge - { canonicalUrlOverride = Nothing - , siteName = "elm-pages" - , image = - { url = images.iconPng - , alt = "elm pages logo" - , dimensions = Nothing - , mimeType = Nothing - } - , locale = Nothing - , description = siteTagline - , title = meta.title - } - |> Seo.website + Metadata.Doc meta -> + Seo.summaryLarge + { canonicalUrlOverride = Nothing + , siteName = "elm-pages" + , image = + { url = images.iconPng + , alt = "elm pages logo" + , dimensions = Nothing + , mimeType = Nothing + } + , locale = Nothing + , description = siteTagline + , title = meta.title + } + |> Seo.website - Metadata.Article meta -> - Seo.summaryLarge - { canonicalUrlOverride = Nothing - , siteName = "elm-pages" - , image = - { url = meta.image - , alt = meta.description - , dimensions = Nothing - , mimeType = Nothing - } - , description = meta.description - , locale = Nothing - , title = meta.title - } - |> Seo.article - { tags = [] - , section = Nothing - , publishedTime = Just (Date.toIsoString meta.published) - , modifiedTime = Nothing - , expirationTime = Nothing - } + Metadata.Article meta -> + Seo.summaryLarge + { canonicalUrlOverride = Nothing + , siteName = "elm-pages" + , image = + { url = meta.image + , alt = meta.description + , dimensions = Nothing + , mimeType = Nothing + } + , description = meta.description + , locale = Nothing + , title = meta.title + } + |> Seo.article + { tags = [] + , section = Nothing + , publishedTime = Just (Date.toIsoString meta.published) + , modifiedTime = Nothing + , expirationTime = Nothing + } - Metadata.Author meta -> - let - ( firstName, lastName ) = - case meta.name |> String.split " " of - [ first, last ] -> - ( first, last ) + Metadata.Author meta -> + let + ( firstName, lastName ) = + case meta.name |> String.split " " of + [ first, last ] -> + ( first, last ) - [ first, middle, last ] -> - ( first ++ " " ++ middle, last ) + [ first, middle, last ] -> + ( first ++ " " ++ middle, last ) - [] -> - ( "", "" ) + [] -> + ( "", "" ) - _ -> - ( meta.name, "" ) - in - Seo.summary - { canonicalUrlOverride = Nothing - , siteName = "elm-pages" - , image = - { url = meta.avatar - , alt = meta.name ++ "'s elm-pages articles." - , dimensions = Nothing - , mimeType = Nothing - } - , description = meta.bio - , locale = Nothing - , title = meta.name ++ "'s elm-pages articles." - } - |> Seo.profile - { firstName = firstName - , lastName = lastName - , username = Nothing - } + _ -> + ( meta.name, "" ) + in + Seo.summary + { canonicalUrlOverride = Nothing + , siteName = "elm-pages" + , image = + { url = meta.avatar + , alt = meta.name ++ "'s elm-pages articles." + , dimensions = Nothing + , mimeType = Nothing + } + , description = meta.bio + , locale = Nothing + , title = meta.name ++ "'s elm-pages articles." + } + |> Seo.profile + { firstName = firstName + , lastName = lastName + , username = Nothing + } - Metadata.BlogIndex -> - Seo.summaryLarge - { canonicalUrlOverride = Nothing - , siteName = "elm-pages" - , image = - { url = images.iconPng - , alt = "elm-pages logo" - , dimensions = Nothing - , mimeType = Nothing - } - , description = siteTagline - , locale = Nothing - , title = "elm-pages blog" - } - |> Seo.website + Metadata.BlogIndex -> + Seo.summaryLarge + { canonicalUrlOverride = Nothing + , siteName = "elm-pages" + , image = + { url = images.iconPng + , alt = "elm-pages logo" + , dimensions = Nothing + , mimeType = Nothing + } + , description = siteTagline + , locale = Nothing + , title = "elm-pages blog" + } + |> Seo.website + ) canonicalSiteUrl : String diff --git a/src/Head.elm b/src/Head.elm index d67533f4..48cfb8f7 100644 --- a/src/Head.elm +++ b/src/Head.elm @@ -118,12 +118,12 @@ Example: rssLink "/feed.xml" -} -rssLink : PagePath pathKey -> Tag pathKey +rssLink : String -> Tag pathKey rssLink url = node "link" [ ( "rel", raw "alternate" ) , ( "type", raw "application/rss+xml" ) - , ( "href", fullPageUrl url ) + , ( "href", raw url ) ]