mirror of
https://github.com/facebook/docusaurus.git
synced 2025-07-24 20:17:50 +02:00
fix(preset-classic): throw if preset finds GA options in theme config (#6284)
* fix(preset-classic): throw if preset finds GA options in theme config * revert * stricter
This commit is contained in:
parent
e231359f84
commit
37a84f86a5
3 changed files with 14 additions and 4 deletions
|
@ -82,7 +82,7 @@ export function validateOptions({
|
||||||
export function validateThemeConfig({
|
export function validateThemeConfig({
|
||||||
themeConfig,
|
themeConfig,
|
||||||
}: ThemeConfigValidationContext<ThemeConfig>): ValidationResult<ThemeConfig> {
|
}: ThemeConfigValidationContext<ThemeConfig>): ValidationResult<ThemeConfig> {
|
||||||
if (themeConfig.googleAnalytics) {
|
if ('googleAnalytics' in themeConfig) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'The "googleAnalytics" field in themeConfig should now be specified as option for plugin-google-analytics. More information at https://github.com/facebook/docusaurus/pull/5832.',
|
'The "googleAnalytics" field in themeConfig should now be specified as option for plugin-google-analytics. More information at https://github.com/facebook/docusaurus/pull/5832.',
|
||||||
);
|
);
|
||||||
|
|
|
@ -95,7 +95,7 @@ export function validateOptions({
|
||||||
export function validateThemeConfig({
|
export function validateThemeConfig({
|
||||||
themeConfig,
|
themeConfig,
|
||||||
}: ThemeConfigValidationContext<ThemeConfig>): ValidationResult<ThemeConfig> {
|
}: ThemeConfigValidationContext<ThemeConfig>): ValidationResult<ThemeConfig> {
|
||||||
if (themeConfig.gtag) {
|
if ('gtag' in themeConfig) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
'The "gtag" field in themeConfig should now be specified as option for plugin-google-gtag. More information at https://github.com/facebook/docusaurus/pull/5832.',
|
'The "gtag" field in themeConfig should now be specified as option for plugin-google-gtag. More information at https://github.com/facebook/docusaurus/pull/5832.',
|
||||||
);
|
);
|
||||||
|
|
|
@ -48,6 +48,16 @@ export default function preset(
|
||||||
if (algolia) {
|
if (algolia) {
|
||||||
themes.push(require.resolve('@docusaurus/theme-search-algolia'));
|
themes.push(require.resolve('@docusaurus/theme-search-algolia'));
|
||||||
}
|
}
|
||||||
|
if ('gtag' in themeConfig) {
|
||||||
|
throw new Error(
|
||||||
|
'The "gtag" field in themeConfig should now be specified as option for plugin-google-gtag. For preset-classic, simply move themeConfig.gtag to preset options. More information at https://github.com/facebook/docusaurus/pull/5832.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if ('googleAnalytics' in themeConfig) {
|
||||||
|
throw new Error(
|
||||||
|
'The "googleAnalytics" field in themeConfig should now be specified as option for plugin-google-analytics. For preset-classic, simply move themeConfig.googleAnalytics to preset options. More information at https://github.com/facebook/docusaurus/pull/5832.',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const plugins: PluginConfig[] = [];
|
const plugins: PluginConfig[] = [];
|
||||||
if (docs !== false) {
|
if (docs !== false) {
|
||||||
|
@ -59,7 +69,7 @@ export default function preset(
|
||||||
if (pages !== false) {
|
if (pages !== false) {
|
||||||
plugins.push(makePluginConfig('@docusaurus/plugin-content-pages', pages));
|
plugins.push(makePluginConfig('@docusaurus/plugin-content-pages', pages));
|
||||||
}
|
}
|
||||||
if (isProd && googleAnalytics) {
|
if (googleAnalytics) {
|
||||||
plugins.push(
|
plugins.push(
|
||||||
makePluginConfig('@docusaurus/plugin-google-analytics', googleAnalytics),
|
makePluginConfig('@docusaurus/plugin-google-analytics', googleAnalytics),
|
||||||
);
|
);
|
||||||
|
@ -67,7 +77,7 @@ export default function preset(
|
||||||
if (debug || (debug === undefined && !isProd)) {
|
if (debug || (debug === undefined && !isProd)) {
|
||||||
plugins.push(require.resolve('@docusaurus/plugin-debug'));
|
plugins.push(require.resolve('@docusaurus/plugin-debug'));
|
||||||
}
|
}
|
||||||
if (isProd && gtag) {
|
if (gtag) {
|
||||||
plugins.push(makePluginConfig('@docusaurus/plugin-google-gtag', gtag));
|
plugins.push(makePluginConfig('@docusaurus/plugin-google-gtag', gtag));
|
||||||
}
|
}
|
||||||
if (isProd && sitemap !== false) {
|
if (isProd && sitemap !== false) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue