mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-22 21:47:01 +02:00
fix(v2): respect base url in RSS feeds (#4962)
This commit is contained in:
parent
57cf20933e
commit
208c089835
3 changed files with 14 additions and 14 deletions
|
@ -5,32 +5,32 @@ exports[`blogFeed atom should not show feed without posts 1`] = `null`;
|
||||||
exports[`blogFeed atom shows feed item for each post 1`] = `
|
exports[`blogFeed atom shows feed item for each post 1`] = `
|
||||||
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
|
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
|
||||||
<feed xmlns=\\"http://www.w3.org/2005/Atom\\">
|
<feed xmlns=\\"http://www.w3.org/2005/Atom\\">
|
||||||
<id>https://docusaurus.io/blog</id>
|
<id>https://docusaurus.io/myBaseUrl/blog</id>
|
||||||
<title>Hello Blog</title>
|
<title>Hello Blog</title>
|
||||||
<updated>2020-02-27T00:00:00.000Z</updated>
|
<updated>2020-02-27T00:00:00.000Z</updated>
|
||||||
<generator>https://github.com/jpmonette/feed</generator>
|
<generator>https://github.com/jpmonette/feed</generator>
|
||||||
<link rel=\\"alternate\\" href=\\"https://docusaurus.io/blog\\"/>
|
<link rel=\\"alternate\\" href=\\"https://docusaurus.io/myBaseUrl/blog\\"/>
|
||||||
<subtitle>Hello Blog</subtitle>
|
<subtitle>Hello Blog</subtitle>
|
||||||
<icon>https://docusaurus.io/image/favicon.ico</icon>
|
<icon>https://docusaurus.io/myBaseUrl/image/favicon.ico</icon>
|
||||||
<rights>Copyright</rights>
|
<rights>Copyright</rights>
|
||||||
<entry>
|
<entry>
|
||||||
<title type=\\"html\\"><![CDATA[draft]]></title>
|
<title type=\\"html\\"><![CDATA[draft]]></title>
|
||||||
<id>draft</id>
|
<id>draft</id>
|
||||||
<link href=\\"https://docusaurus.io/blog/draft\\"/>
|
<link href=\\"https://docusaurus.io/myBaseUrl/blog/draft\\"/>
|
||||||
<updated>2020-02-27T00:00:00.000Z</updated>
|
<updated>2020-02-27T00:00:00.000Z</updated>
|
||||||
<summary type=\\"html\\"><![CDATA[this post should not be published yet]]></summary>
|
<summary type=\\"html\\"><![CDATA[this post should not be published yet]]></summary>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<title type=\\"html\\"><![CDATA[date-matter]]></title>
|
<title type=\\"html\\"><![CDATA[date-matter]]></title>
|
||||||
<id>date-matter</id>
|
<id>date-matter</id>
|
||||||
<link href=\\"https://docusaurus.io/blog/date-matter\\"/>
|
<link href=\\"https://docusaurus.io/myBaseUrl/blog/date-matter\\"/>
|
||||||
<updated>2019-01-01T00:00:00.000Z</updated>
|
<updated>2019-01-01T00:00:00.000Z</updated>
|
||||||
<summary type=\\"html\\"><![CDATA[date inside front matter]]></summary>
|
<summary type=\\"html\\"><![CDATA[date inside front matter]]></summary>
|
||||||
</entry>
|
</entry>
|
||||||
<entry>
|
<entry>
|
||||||
<title type=\\"html\\"><![CDATA[Happy 1st Birthday Slash! (translated)]]></title>
|
<title type=\\"html\\"><![CDATA[Happy 1st Birthday Slash! (translated)]]></title>
|
||||||
<id>Happy 1st Birthday Slash! (translated)</id>
|
<id>Happy 1st Birthday Slash! (translated)</id>
|
||||||
<link href=\\"https://docusaurus.io/blog/2018/12/14/Happy-First-Birthday-Slash\\"/>
|
<link href=\\"https://docusaurus.io/myBaseUrl/blog/2018/12/14/Happy-First-Birthday-Slash\\"/>
|
||||||
<updated>2018-12-14T00:00:00.000Z</updated>
|
<updated>2018-12-14T00:00:00.000Z</updated>
|
||||||
<summary type=\\"html\\"><![CDATA[Happy birthday! (translated)]]></summary>
|
<summary type=\\"html\\"><![CDATA[Happy birthday! (translated)]]></summary>
|
||||||
</entry>
|
</entry>
|
||||||
|
@ -44,7 +44,7 @@ exports[`blogFeed rss shows feed item for each post 1`] = `
|
||||||
<rss version=\\"2.0\\">
|
<rss version=\\"2.0\\">
|
||||||
<channel>
|
<channel>
|
||||||
<title>Hello Blog</title>
|
<title>Hello Blog</title>
|
||||||
<link>https://docusaurus.io/blog</link>
|
<link>https://docusaurus.io/myBaseUrl/blog</link>
|
||||||
<description>Hello Blog</description>
|
<description>Hello Blog</description>
|
||||||
<lastBuildDate>Thu, 27 Feb 2020 00:00:00 GMT</lastBuildDate>
|
<lastBuildDate>Thu, 27 Feb 2020 00:00:00 GMT</lastBuildDate>
|
||||||
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
|
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
|
||||||
|
@ -52,21 +52,21 @@ exports[`blogFeed rss shows feed item for each post 1`] = `
|
||||||
<copyright>Copyright</copyright>
|
<copyright>Copyright</copyright>
|
||||||
<item>
|
<item>
|
||||||
<title><![CDATA[draft]]></title>
|
<title><![CDATA[draft]]></title>
|
||||||
<link>https://docusaurus.io/blog/draft</link>
|
<link>https://docusaurus.io/myBaseUrl/blog/draft</link>
|
||||||
<guid>draft</guid>
|
<guid>draft</guid>
|
||||||
<pubDate>Thu, 27 Feb 2020 00:00:00 GMT</pubDate>
|
<pubDate>Thu, 27 Feb 2020 00:00:00 GMT</pubDate>
|
||||||
<description><![CDATA[this post should not be published yet]]></description>
|
<description><![CDATA[this post should not be published yet]]></description>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<title><![CDATA[date-matter]]></title>
|
<title><![CDATA[date-matter]]></title>
|
||||||
<link>https://docusaurus.io/blog/date-matter</link>
|
<link>https://docusaurus.io/myBaseUrl/blog/date-matter</link>
|
||||||
<guid>date-matter</guid>
|
<guid>date-matter</guid>
|
||||||
<pubDate>Tue, 01 Jan 2019 00:00:00 GMT</pubDate>
|
<pubDate>Tue, 01 Jan 2019 00:00:00 GMT</pubDate>
|
||||||
<description><![CDATA[date inside front matter]]></description>
|
<description><![CDATA[date inside front matter]]></description>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<title><![CDATA[Happy 1st Birthday Slash! (translated)]]></title>
|
<title><![CDATA[Happy 1st Birthday Slash! (translated)]]></title>
|
||||||
<link>https://docusaurus.io/blog/2018/12/14/Happy-First-Birthday-Slash</link>
|
<link>https://docusaurus.io/myBaseUrl/blog/2018/12/14/Happy-First-Birthday-Slash</link>
|
||||||
<guid>Happy 1st Birthday Slash! (translated)</guid>
|
<guid>Happy 1st Birthday Slash! (translated)</guid>
|
||||||
<pubDate>Fri, 14 Dec 2018 00:00:00 GMT</pubDate>
|
<pubDate>Fri, 14 Dec 2018 00:00:00 GMT</pubDate>
|
||||||
<description><![CDATA[Happy birthday! (translated)]]></description>
|
<description><![CDATA[Happy birthday! (translated)]]></description>
|
||||||
|
|
|
@ -68,7 +68,7 @@ describe('blogFeed', () => {
|
||||||
const generatedFilesDir = path.resolve(siteDir, '.docusaurus');
|
const generatedFilesDir = path.resolve(siteDir, '.docusaurus');
|
||||||
const siteConfig = {
|
const siteConfig = {
|
||||||
title: 'Hello',
|
title: 'Hello',
|
||||||
baseUrl: '/',
|
baseUrl: '/myBaseUrl/',
|
||||||
url: 'https://docusaurus.io',
|
url: 'https://docusaurus.io',
|
||||||
favicon: 'image/favicon.ico',
|
favicon: 'image/favicon.ico',
|
||||||
};
|
};
|
||||||
|
|
|
@ -72,8 +72,8 @@ export async function generateBlogFeed(
|
||||||
}
|
}
|
||||||
|
|
||||||
const {feedOptions, routeBasePath} = options;
|
const {feedOptions, routeBasePath} = options;
|
||||||
const {url: siteUrl, title, favicon} = siteConfig;
|
const {url: siteUrl, baseUrl, title, favicon} = siteConfig;
|
||||||
const blogBaseUrl = normalizeUrl([siteUrl, routeBasePath]);
|
const blogBaseUrl = normalizeUrl([siteUrl, baseUrl, routeBasePath]);
|
||||||
|
|
||||||
const updated =
|
const updated =
|
||||||
(blogPosts[0] && blogPosts[0].metadata.date) ||
|
(blogPosts[0] && blogPosts[0].metadata.date) ||
|
||||||
|
@ -86,7 +86,7 @@ export async function generateBlogFeed(
|
||||||
language: feedOptions.language,
|
language: feedOptions.language,
|
||||||
link: blogBaseUrl,
|
link: blogBaseUrl,
|
||||||
description: feedOptions.description || `${siteConfig.title} Blog`,
|
description: feedOptions.description || `${siteConfig.title} Blog`,
|
||||||
favicon: normalizeUrl([siteUrl, favicon]),
|
favicon: normalizeUrl([siteUrl, baseUrl, favicon]),
|
||||||
copyright: feedOptions.copyright,
|
copyright: feedOptions.copyright,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue