diff --git a/examples/docs/src/Feed.elm b/examples/docs/src/Feed.elm index 760ae961..e1b4bcf7 100644 --- a/examples/docs/src/Feed.elm +++ b/examples/docs/src/Feed.elm @@ -11,7 +11,9 @@ import Xml.Encode exposing (..) fileToGenerate : - String + { siteTagline : String + , siteUrl : String + } -> List { path : PagePath Pages.PathKey @@ -21,22 +23,24 @@ fileToGenerate : { path : List String , content : String } -fileToGenerate siteTagline siteMetadata = +fileToGenerate config siteMetadata = { path = [ "feed.xml" ] , content = - generate siteTagline siteMetadata |> Xml.Encode.encode 0 + generate config siteMetadata |> Xml.Encode.encode 0 } generate : - String + { siteTagline : String + , siteUrl : String + } -> List { path : PagePath Pages.PathKey , frontmatter : Metadata } -> Xml.Value -generate siteTagline siteMetadata = +generate { siteTagline, siteUrl } siteMetadata = RssFeed.generate { title = "elm-pages Blog" , description = siteTagline @@ -49,6 +53,7 @@ generate siteTagline siteMetadata = , version = Nothing } , items = siteMetadata |> List.filterMap metadataToRssItem + , siteUrl = siteUrl } @@ -64,7 +69,6 @@ metadataToRssItem page = { title = article.title , description = article.description , url = PagePath.toString page.path - , guid = PagePath.toString page.path , categories = [] , author = article.author.name , pubDate = article.published diff --git a/examples/docs/src/Main.elm b/examples/docs/src/Main.elm index f99c31e6..354feb2c 100644 --- a/examples/docs/src/Main.elm +++ b/examples/docs/src/Main.elm @@ -80,7 +80,7 @@ generateFiles : , content : String } generateFiles siteMetadata = - [ Feed.fileToGenerate siteTagline siteMetadata + [ Feed.fileToGenerate { siteTagline = siteTagline, siteUrl = canonicalSiteUrl } siteMetadata ] diff --git a/examples/docs/src/RssFeed.elm b/examples/docs/src/RssFeed.elm index 39846aee..55b7c874 100644 --- a/examples/docs/src/RssFeed.elm +++ b/examples/docs/src/RssFeed.elm @@ -12,7 +12,6 @@ type alias Item = { title : String , description : String , url : String - , guid : String , categories : List String , author : String , pubDate : Date @@ -39,6 +38,7 @@ generate : , version : Maybe String } , items : List Item + , siteUrl : String } -> Xml.Value generate feed = @@ -59,7 +59,7 @@ generate feed = , keyValue "link" feed.url , keyValue "lastBuildDate" <| Imf.DateTime.fromPosix Time.utc feed.lastBuildTime ] - ++ List.map itemXml feed.items + ++ List.map (itemXml feed.siteUrl) feed.items ++ ([ feed.generator |> Maybe.map generatorXml ] |> List.filterMap identity @@ -71,16 +71,16 @@ generate feed = ] -itemXml : Item -> Xml.Value -itemXml item = +itemXml : String -> Item -> Xml.Value +itemXml siteUrl item = object [ ( "item" , Dict.empty , list ([ keyValue "title" item.title , keyValue "description" item.description - , keyValue "link" item.url - , keyValue "guid" item.guid + , keyValue "link" (siteUrl ++ item.url) + , keyValue "guid" (siteUrl ++ item.url) , keyValue "pubDate" (formatDate item.pubDate) ] ++ ([ item.content |> Maybe.map (\content -> keyValue "content" content)