mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-30 02:37:59 +02:00
fix(migrate): migration CLI should correctly migrate gtag options (#6276)
* fix(migrate): migration CLI should correctly migrate gtag options * fix
This commit is contained in:
parent
4efdd33df9
commit
1d957d97e8
5 changed files with 70 additions and 37 deletions
|
@ -43,6 +43,7 @@ module.exports = {
|
||||||
},
|
},
|
||||||
blog: {},
|
blog: {},
|
||||||
theme: {},
|
theme: {},
|
||||||
|
googleAnalytics: {trackingID: 'UA-44373548-31'},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -78,6 +79,5 @@ module.exports = {
|
||||||
indexName: 'docusaurus',
|
indexName: 'docusaurus',
|
||||||
algoliaOptions: {facetFilters: ['language:LANGUAGE', 'version:VERSION']},
|
algoliaOptions: {facetFilters: ['language:LANGUAGE', 'version:VERSION']},
|
||||||
},
|
},
|
||||||
gtag: {trackingID: 'UA-44373548-31'},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -247,6 +247,7 @@ export function createConfigFile({
|
||||||
'enableUpdateBy',
|
'enableUpdateBy',
|
||||||
'docsSideNavCollapsible',
|
'docsSideNavCollapsible',
|
||||||
'gaTrackingId',
|
'gaTrackingId',
|
||||||
|
'gaGtag',
|
||||||
];
|
];
|
||||||
const value = siteConfig[key as keyof typeof siteConfig];
|
const value = siteConfig[key as keyof typeof siteConfig];
|
||||||
if (value !== undefined && !knownFields.includes(key)) {
|
if (value !== undefined && !knownFields.includes(key)) {
|
||||||
|
@ -293,6 +294,15 @@ export function createConfigFile({
|
||||||
},
|
},
|
||||||
blog: {},
|
blog: {},
|
||||||
theme: {},
|
theme: {},
|
||||||
|
...(() => {
|
||||||
|
if (siteConfig.gaTrackingId) {
|
||||||
|
if (siteConfig.gaGtag) {
|
||||||
|
return {gtag: {trackingID: siteConfig.gaTrackingId}};
|
||||||
|
}
|
||||||
|
return {googleAnalytics: {trackingID: siteConfig.gaTrackingId}};
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
})(),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
|
@ -351,11 +361,6 @@ export function createConfigFile({
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
algolia: siteConfig.algolia ? siteConfig.algolia : undefined,
|
algolia: siteConfig.algolia ? siteConfig.algolia : undefined,
|
||||||
gtag: siteConfig.gaTrackingId
|
|
||||||
? {
|
|
||||||
trackingID: siteConfig.gaTrackingId,
|
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,8 @@ export type Data = {
|
||||||
export type ClassicPresetEntries = {
|
export type ClassicPresetEntries = {
|
||||||
docs: {[key: string]: unknown};
|
docs: {[key: string]: unknown};
|
||||||
blog: {[key: string]: unknown};
|
blog: {[key: string]: unknown};
|
||||||
|
gtag?: {trackingID: string} | undefined;
|
||||||
|
googleAnalytics?: {trackingID: string} | undefined;
|
||||||
theme: {[key: string]: unknown};
|
theme: {[key: string]: unknown};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -51,9 +53,6 @@ export interface VersionTwoConfig {
|
||||||
themes?: [];
|
themes?: [];
|
||||||
presets: [[string, ClassicPresetEntries]];
|
presets: [[string, ClassicPresetEntries]];
|
||||||
themeConfig: {
|
themeConfig: {
|
||||||
gtag?: {
|
|
||||||
trackingID?: string;
|
|
||||||
};
|
|
||||||
navbar: {
|
navbar: {
|
||||||
title?: string;
|
title?: string;
|
||||||
logo?: {
|
logo?: {
|
||||||
|
@ -120,6 +119,7 @@ export type VersionOneConfig = {
|
||||||
translationRecruitingLink?: string;
|
translationRecruitingLink?: string;
|
||||||
algolia?: Record<string, unknown>;
|
algolia?: Record<string, unknown>;
|
||||||
gaTrackingId?: string;
|
gaTrackingId?: string;
|
||||||
|
gaGtag?: boolean;
|
||||||
highlight?: Record<string, unknown>;
|
highlight?: Record<string, unknown>;
|
||||||
markdownPlugins?: Array<() => void>;
|
markdownPlugins?: Array<() => void>;
|
||||||
scripts?: Array<{src: string; [key: string]: unknown} | string>;
|
scripts?: Array<{src: string; [key: string]: unknown} | string>;
|
||||||
|
|
|
@ -363,29 +363,43 @@ module.exports = {
|
||||||
|
|
||||||
#### `gaTrackingId` {#gatrackingid}
|
#### `gaTrackingId` {#gatrackingid}
|
||||||
|
|
||||||
```js {5} title="docusaurus.config.js"
|
```js title="docusaurus.config.js"
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// ...
|
// ...
|
||||||
themeConfig: {
|
presets: [
|
||||||
googleAnalytics: {
|
[
|
||||||
trackingID: 'UA-141789564-1',
|
'@docusaurus/preset-classic',
|
||||||
},
|
{
|
||||||
// ...
|
// ...
|
||||||
},
|
// highlight-start
|
||||||
|
googleAnalytics: {
|
||||||
|
trackingID: 'UA-141789564-1',
|
||||||
|
},
|
||||||
|
// highlight-end
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `gaGtag` {#gagtag}
|
#### `gaGtag` {#gagtag}
|
||||||
|
|
||||||
```js {5} title="docusaurus.config.js"
|
```js title="docusaurus.config.js"
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// ...
|
// ...
|
||||||
themeConfig: {
|
presets: [
|
||||||
gtag: {
|
[
|
||||||
trackingID: 'UA-141789564-1',
|
'@docusaurus/preset-classic',
|
||||||
},
|
{
|
||||||
// ...
|
// ...
|
||||||
},
|
// highlight-start
|
||||||
|
gtag: {
|
||||||
|
trackingID: 'UA-141789564-1',
|
||||||
|
},
|
||||||
|
// highlight-end
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -363,29 +363,43 @@ module.exports = {
|
||||||
|
|
||||||
#### `gaTrackingId` {#gatrackingid}
|
#### `gaTrackingId` {#gatrackingid}
|
||||||
|
|
||||||
```jsx {5} title="docusaurus.config.js"
|
```js title="docusaurus.config.js"
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// ...
|
// ...
|
||||||
themeConfig: {
|
presets: [
|
||||||
googleAnalytics: {
|
[
|
||||||
trackingID: 'UA-141789564-1',
|
'@docusaurus/preset-classic',
|
||||||
},
|
{
|
||||||
// ...
|
// ...
|
||||||
},
|
// highlight-start
|
||||||
|
googleAnalytics: {
|
||||||
|
trackingID: 'UA-141789564-1',
|
||||||
|
},
|
||||||
|
// highlight-end
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
#### `gaGtag` {#gagtag}
|
#### `gaGtag` {#gagtag}
|
||||||
|
|
||||||
```jsx {5} title="docusaurus.config.js"
|
```js title="docusaurus.config.js"
|
||||||
module.exports = {
|
module.exports = {
|
||||||
// ...
|
// ...
|
||||||
themeConfig: {
|
presets: [
|
||||||
gtag: {
|
[
|
||||||
trackingID: 'UA-141789564-1',
|
'@docusaurus/preset-classic',
|
||||||
},
|
{
|
||||||
// ...
|
// ...
|
||||||
},
|
// highlight-start
|
||||||
|
gtag: {
|
||||||
|
trackingID: 'UA-141789564-1',
|
||||||
|
},
|
||||||
|
// highlight-end
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue