mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-31 01:47:17 +02:00
feat(content-blog): support json feed (#6126)
* feat(content-blog): support json feed * feat(content-blog): support json feed * feat(content-blog): add json type to default feed options * Refactors, docs, validation * Fix test * Ammend docs * Add API doc Co-authored-by: Joshua Chen <sidachen2003@gmail.com>
This commit is contained in:
parent
06bd44c693
commit
7e5f6bb805
9 changed files with 165 additions and 30 deletions
|
@ -50,7 +50,7 @@ async function testGenerateFeeds(
|
|||
}
|
||||
|
||||
describe('blogFeed', () => {
|
||||
(['atom', 'rss'] as const).forEach((feedType) => {
|
||||
(['atom', 'rss', 'json'] as const).forEach((feedType) => {
|
||||
describe(`${feedType}`, () => {
|
||||
test('should not show feed without posts', async () => {
|
||||
const siteDir = __dirname;
|
||||
|
@ -117,8 +117,22 @@ describe('blogFeed', () => {
|
|||
defaultReadingTime({content}),
|
||||
} as PluginOptions,
|
||||
);
|
||||
const feedContent =
|
||||
feed && (feedType === 'rss' ? feed.rss2() : feed.atom1());
|
||||
|
||||
let feedContent = '';
|
||||
switch (feedType) {
|
||||
case 'rss':
|
||||
feedContent = feed.rss2();
|
||||
break;
|
||||
case 'json':
|
||||
feedContent = feed.json1();
|
||||
break;
|
||||
case 'atom':
|
||||
feedContent = feed.atom1();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
expect(feedContent).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue