diff --git a/packages/docusaurus-plugin-content-blog/assets/atom.xslt b/packages/docusaurus-plugin-content-blog/assets/atom.xslt index 448b2f2f0a1a..11ac5264071a 100644 --- a/packages/docusaurus-plugin-content-blog/assets/atom.xslt +++ b/packages/docusaurus-plugin-content-blog/assets/atom.xslt @@ -35,7 +35,7 @@ - Custom Atom Feed Preview + Atom Feed Preview

diff --git a/packages/docusaurus-plugin-content-blog/src/feed.ts b/packages/docusaurus-plugin-content-blog/src/feed.ts index 268bdd5c9f86..d4db1002f566 100644 --- a/packages/docusaurus-plugin-content-blog/src/feed.ts +++ b/packages/docusaurus-plugin-content-blog/src/feed.ts @@ -233,7 +233,7 @@ async function createBlogFeedFile({ feed, feedType, generatePath, - feedOptions: {atomXslt, rssXslt, xslt}, + feedOptions: {xslt}, contentPaths, }: { feed: Feed; @@ -247,11 +247,11 @@ async function createBlogFeedFile({ case 'rss': { const rssFeed = feed.rss2(); const outputPath = 'rss.xml'; - if (xslt) { + if (xslt.enabled) { const xsltFeed = await transformFeedWithStylesheet({ feedDetails: rssFeed, generatePath, - xsltFile: rssXslt, + xsltFile: xslt.rssXslt, contentPaths, }); return [xsltFeed, outputPath]; @@ -263,11 +263,11 @@ async function createBlogFeedFile({ case 'atom': { const atomFeed = feed.atom1(); const outputPath = 'atom.xml'; - if (xslt) { + if (xslt.enabled) { const xsltFeed = await transformFeedWithStylesheet({ feedDetails: atomFeed, generatePath, - xsltFile: atomXslt, + xsltFile: xslt.atomXslt, contentPaths, }); return [xsltFeed, outputPath]; diff --git a/packages/docusaurus-plugin-content-blog/src/options.ts b/packages/docusaurus-plugin-content-blog/src/options.ts index aa03605ea3b2..aae8a44cca61 100644 --- a/packages/docusaurus-plugin-content-blog/src/options.ts +++ b/packages/docusaurus-plugin-content-blog/src/options.ts @@ -27,9 +27,11 @@ export const DEFAULT_OPTIONS: PluginOptions = { type: ['rss', 'atom'], copyright: '', limit: 20, - xslt: false, - atomXslt: 'atom.xslt', - rssXslt: 'rss.xslt', + xslt: { + enabled: false, + atomXslt: 'atom.xslt', + rssXslt: 'rss.xslt', + }, }, beforeDefaultRehypePlugins: [], beforeDefaultRemarkPlugins: [], @@ -129,9 +131,11 @@ const PluginOptionSchema = Joi.object({ ) .allow(null) .default(DEFAULT_OPTIONS.feedOptions.type), - xslt: Joi.boolean().default(DEFAULT_OPTIONS.feedOptions.xslt), - atomXslt: Joi.string().default(DEFAULT_OPTIONS.feedOptions.atomXslt), - rssXslt: Joi.string().default(DEFAULT_OPTIONS.feedOptions.rssXslt), + xslt: Joi.object({ + enabled: Joi.boolean().default(DEFAULT_OPTIONS.feedOptions.xslt.enabled), + atomXslt: Joi.string().default(DEFAULT_OPTIONS.feedOptions.xslt.atomXslt), + rssXslt: Joi.string().default(DEFAULT_OPTIONS.feedOptions.xslt.rssXslt), + }).default(DEFAULT_OPTIONS.feedOptions.xslt), title: Joi.string().allow(''), description: Joi.string().allow(''), // Only add default value when user actually wants a feed (type is not null) diff --git a/packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts b/packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts index 43b5fd9ab2c5..1349002d5f8a 100644 --- a/packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts +++ b/packages/docusaurus-plugin-content-blog/src/plugin-content-blog.d.ts @@ -291,10 +291,12 @@ yarn workspace v1.22.19image` is a collocated image path, this entry will be the export type FeedType = 'rss' | 'atom' | 'json'; export type XslParams = { - /** Enable xsl stylesheet */ - xslt: boolean; - rssXslt: string; - atomXslt: string; + /** Enable xslt stylesheet */ + xslt: { + enabled: boolean; + rssXslt: string; + atomXslt: string; + }; }; /** @@ -491,6 +493,11 @@ yarn workspace v1.22.19image` is a collocated image path, this entry will be the { /** Type of feed to be generated. Use `null` to disable generation. */ type?: FeedOptions['type'] | 'all' | FeedType; + xslt?: { + enabled?: boolean; + rssXslt?: string; + atomXslt?: string; + }; } >; /** diff --git a/website/_dogfooding/dogfooding.config.ts b/website/_dogfooding/dogfooding.config.ts index 9fb6c60665cd..848b7872603f 100644 --- a/website/_dogfooding/dogfooding.config.ts +++ b/website/_dogfooding/dogfooding.config.ts @@ -88,9 +88,11 @@ export const dogfoodingPluginInstances: PluginConfig[] = [ type: 'all', title: 'Docusaurus Tests Blog', copyright: `Copyright © ${new Date().getFullYear()} Facebook, Inc.`, - xslt: true, - rssXslt: 'custom-rss.xslt', - atomXslt: 'custom-atom.xslt', + xslt: { + enabled: true, + rssXslt: 'custom-rss.xslt', + atomXslt: 'custom-atom.xslt', + }, }, readingTime: ({content, frontMatter, defaultReadingTime}) => frontMatter.hide_reading_time diff --git a/website/docusaurus.config.ts b/website/docusaurus.config.ts index 56d24ea441c7..d26322d84afd 100644 --- a/website/docusaurus.config.ts +++ b/website/docusaurus.config.ts @@ -488,7 +488,9 @@ export default async function createConfigAsync() { feedOptions: { type: 'all', copyright: `Copyright © ${new Date().getFullYear()} Facebook, Inc.`, - xslt: true, + xslt: { + enabled: true, + }, }, blogTitle: 'Docusaurus blog', blogDescription: 'Read blog posts about Docusaurus from the team',