mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
feat(sitemap): allow customizing the output name (#7469)
* feat(sitemap): allow customizing the output name * add docs
This commit is contained in:
parent
9398bb2487
commit
7ab97d4726
3 changed files with 10 additions and 1 deletions
|
@ -32,7 +32,7 @@ export default function pluginSitemap(
|
|||
);
|
||||
|
||||
// Write sitemap file.
|
||||
const sitemapPath = path.join(outDir, 'sitemap.xml');
|
||||
const sitemapPath = path.join(outDir, options.filename);
|
||||
try {
|
||||
await fs.outputFile(sitemapPath, generatedSitemap);
|
||||
} catch (err) {
|
||||
|
|
|
@ -19,6 +19,11 @@ export type PluginOptions = {
|
|||
* sitemap. Note that you may need to include the base URL in here.
|
||||
*/
|
||||
ignorePatterns: string[];
|
||||
/**
|
||||
* The path to the created sitemap file, relative to the output directory.
|
||||
* Useful if you have two plugin instances outputting two files.
|
||||
*/
|
||||
filename: string;
|
||||
};
|
||||
|
||||
export type Options = Partial<PluginOptions>;
|
||||
|
@ -27,6 +32,7 @@ export const DEFAULT_OPTIONS: PluginOptions = {
|
|||
changefreq: EnumChangefreq.WEEKLY,
|
||||
priority: 0.5,
|
||||
ignorePatterns: [],
|
||||
filename: 'sitemap.xml',
|
||||
};
|
||||
|
||||
const PluginOptionSchema = Joi.object<PluginOptions>({
|
||||
|
@ -46,6 +52,7 @@ const PluginOptionSchema = Joi.object<PluginOptions>({
|
|||
'any.unknown':
|
||||
'Please use the new Docusaurus global trailingSlash config instead, and the sitemaps plugin will use it.',
|
||||
}),
|
||||
filename: Joi.string().default(DEFAULT_OPTIONS.filename),
|
||||
});
|
||||
|
||||
export function validateOptions({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue