diff --git a/src/components/common/Layout.js b/src/components/common/Layout.js index 037ba31..721c435 100644 --- a/src/components/common/Layout.js +++ b/src/components/common/Layout.js @@ -51,7 +51,7 @@ const DefaultLayout = ({ data, children, bodyClass, isHome, hasFeatureImage }) =
{ isHome ? diff --git a/src/utils/rss/generate-feed.js b/src/utils/rss/generate-feed.js index 9a06c0b..269a7c7 100644 --- a/src/utils/rss/generate-feed.js +++ b/src/utils/rss/generate-feed.js @@ -2,8 +2,18 @@ const cheerio = require(`cheerio`) const tagsHelper = require(`@tryghost/helpers`).tags const _ = require(`lodash`) -const generateItem = function generateItem(post) { - const itemUrl = post.url +const generateItem = function generateItem(post, siteUrl) { + /* + * TODO: detect URL from post.url + * + * Right now post.url returns the Ghost version of the post, + * hence this hack to show the Gatsby site version. But here + * the URL is regenerated from slug, which may not match the + * actual Ghost config. Ideally, we should take post.url, + * remove the ghost site prefix, and replace that with + * siteUrl. + */ + const itemUrl = siteUrl + '/' + post.slug + '/' const html = post.html const htmlContent = cheerio.load(html, { decodeEntities: false, xmlMode: true }) const item = { @@ -46,7 +56,7 @@ const generateItem = function generateItem(post) { const generateRSSFeed = function generateRSSFeed(siteConfig) { return { - serialize: ({ query: { allGhostPost } }) => allGhostPost.edges.map(edge => Object.assign({}, generateItem(edge.node))), + serialize: ({ query: { allGhostPost } }) => allGhostPost.edges.map(edge => Object.assign({}, generateItem(edge.node, siteConfig.siteUrl))), setup: ({ query: { allGhostSettings } }) => { const siteTitle = allGhostSettings.edges[0].node.title || `No Title` const siteDescription = allGhostSettings.edges[0].node.description || `No Description` @@ -55,7 +65,7 @@ const generateRSSFeed = function generateRSSFeed(siteConfig) { description: siteDescription, // generator: `Ghost ` + data.safeVersion, generator: `Ghost 2.9`, - feed_url: `${siteConfig.siteUrl}/rss/`, + feed_url: `${siteConfig.siteUrl}/rss`, site_url: `${siteConfig.siteUrl}/`, image_url: `${siteConfig.siteUrl}/${siteConfig.siteIcon}`, ttl: `60`, @@ -114,7 +124,7 @@ const generateRSSFeed = function generateRSSFeed(siteConfig) { } } `, - output: `/feed.xml`, + output: `/rss`, } }