mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-03 16:59:06 +02:00
feat(preset-classic): exclude debug plugin routes from sitemap (#7122)
This commit is contained in:
parent
bfbc78e52a
commit
0963bff5e7
3 changed files with 22 additions and 10 deletions
|
@ -5,6 +5,7 @@
|
|||
* LICENSE file in the root directory of this source tree.
|
||||
*/
|
||||
|
||||
import {routeBasePath as debugPluginRouteBasePath} from '@docusaurus/plugin-debug';
|
||||
import type {
|
||||
Preset,
|
||||
LoadContext,
|
||||
|
@ -28,7 +29,7 @@ export default function preset(
|
|||
opts: Options = {},
|
||||
): Preset {
|
||||
const {siteConfig} = context;
|
||||
const {themeConfig} = siteConfig;
|
||||
const {themeConfig, baseUrl} = siteConfig;
|
||||
const {algolia} = themeConfig as Partial<ThemeConfig>;
|
||||
const isProd = process.env.NODE_ENV === 'production';
|
||||
const {
|
||||
|
@ -36,12 +37,13 @@ export default function preset(
|
|||
docs,
|
||||
blog,
|
||||
pages,
|
||||
sitemap,
|
||||
sitemap = {},
|
||||
theme,
|
||||
googleAnalytics,
|
||||
gtag,
|
||||
...rest
|
||||
} = opts;
|
||||
const isDebugEnabled = debug || (debug === undefined && !isProd);
|
||||
|
||||
const themes: PluginConfig[] = [];
|
||||
themes.push(makePluginConfig('@docusaurus/theme-classic', theme));
|
||||
|
@ -74,13 +76,17 @@ export default function preset(
|
|||
makePluginConfig('@docusaurus/plugin-google-analytics', googleAnalytics),
|
||||
);
|
||||
}
|
||||
if (debug || (debug === undefined && !isProd)) {
|
||||
if (isDebugEnabled) {
|
||||
plugins.push(require.resolve('@docusaurus/plugin-debug'));
|
||||
}
|
||||
if (gtag) {
|
||||
plugins.push(makePluginConfig('@docusaurus/plugin-google-gtag', gtag));
|
||||
}
|
||||
if (isProd && sitemap !== false) {
|
||||
if (isDebugEnabled) {
|
||||
sitemap.ignorePatterns ??= [];
|
||||
sitemap.ignorePatterns.push(`${baseUrl}${debugPluginRouteBasePath}/**`);
|
||||
}
|
||||
plugins.push(makePluginConfig('@docusaurus/plugin-sitemap', sitemap));
|
||||
}
|
||||
if (Object.keys(rest).length > 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue