mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2025-01-05 12:57:33 +03:00
Fix link formatting for RSS.
This commit is contained in:
parent
1729723b7d
commit
611e8f84a0
@ -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
|
||||
|
@ -80,7 +80,7 @@ generateFiles :
|
||||
, content : String
|
||||
}
|
||||
generateFiles siteMetadata =
|
||||
[ Feed.fileToGenerate siteTagline siteMetadata
|
||||
[ Feed.fileToGenerate { siteTagline = siteTagline, siteUrl = canonicalSiteUrl } siteMetadata
|
||||
]
|
||||
|
||||
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user