mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-29 18:27:56 +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: {},
|
||||
theme: {},
|
||||
googleAnalytics: {trackingID: 'UA-44373548-31'},
|
||||
},
|
||||
],
|
||||
],
|
||||
|
@ -78,6 +79,5 @@ module.exports = {
|
|||
indexName: 'docusaurus',
|
||||
algoliaOptions: {facetFilters: ['language:LANGUAGE', 'version:VERSION']},
|
||||
},
|
||||
gtag: {trackingID: 'UA-44373548-31'},
|
||||
},
|
||||
};
|
||||
|
|
|
@ -247,6 +247,7 @@ export function createConfigFile({
|
|||
'enableUpdateBy',
|
||||
'docsSideNavCollapsible',
|
||||
'gaTrackingId',
|
||||
'gaGtag',
|
||||
];
|
||||
const value = siteConfig[key as keyof typeof siteConfig];
|
||||
if (value !== undefined && !knownFields.includes(key)) {
|
||||
|
@ -293,6 +294,15 @@ export function createConfigFile({
|
|||
},
|
||||
blog: {},
|
||||
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,
|
||||
gtag: siteConfig.gaTrackingId
|
||||
? {
|
||||
trackingID: siteConfig.gaTrackingId,
|
||||
}
|
||||
: undefined,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
|
@ -18,6 +18,8 @@ export type Data = {
|
|||
export type ClassicPresetEntries = {
|
||||
docs: {[key: string]: unknown};
|
||||
blog: {[key: string]: unknown};
|
||||
gtag?: {trackingID: string} | undefined;
|
||||
googleAnalytics?: {trackingID: string} | undefined;
|
||||
theme: {[key: string]: unknown};
|
||||
};
|
||||
|
||||
|
@ -51,9 +53,6 @@ export interface VersionTwoConfig {
|
|||
themes?: [];
|
||||
presets: [[string, ClassicPresetEntries]];
|
||||
themeConfig: {
|
||||
gtag?: {
|
||||
trackingID?: string;
|
||||
};
|
||||
navbar: {
|
||||
title?: string;
|
||||
logo?: {
|
||||
|
@ -120,6 +119,7 @@ export type VersionOneConfig = {
|
|||
translationRecruitingLink?: string;
|
||||
algolia?: Record<string, unknown>;
|
||||
gaTrackingId?: string;
|
||||
gaGtag?: boolean;
|
||||
highlight?: Record<string, unknown>;
|
||||
markdownPlugins?: Array<() => void>;
|
||||
scripts?: Array<{src: string; [key: string]: unknown} | string>;
|
||||
|
|
|
@ -363,29 +363,43 @@ module.exports = {
|
|||
|
||||
#### `gaTrackingId` {#gatrackingid}
|
||||
|
||||
```js {5} title="docusaurus.config.js"
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
// ...
|
||||
themeConfig: {
|
||||
googleAnalytics: {
|
||||
trackingID: 'UA-141789564-1',
|
||||
},
|
||||
// ...
|
||||
},
|
||||
presets: [
|
||||
[
|
||||
'@docusaurus/preset-classic',
|
||||
{
|
||||
// ...
|
||||
// highlight-start
|
||||
googleAnalytics: {
|
||||
trackingID: 'UA-141789564-1',
|
||||
},
|
||||
// highlight-end
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
#### `gaGtag` {#gagtag}
|
||||
|
||||
```js {5} title="docusaurus.config.js"
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
// ...
|
||||
themeConfig: {
|
||||
gtag: {
|
||||
trackingID: 'UA-141789564-1',
|
||||
},
|
||||
// ...
|
||||
},
|
||||
presets: [
|
||||
[
|
||||
'@docusaurus/preset-classic',
|
||||
{
|
||||
// ...
|
||||
// highlight-start
|
||||
gtag: {
|
||||
trackingID: 'UA-141789564-1',
|
||||
},
|
||||
// highlight-end
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
|
|
|
@ -363,29 +363,43 @@ module.exports = {
|
|||
|
||||
#### `gaTrackingId` {#gatrackingid}
|
||||
|
||||
```jsx {5} title="docusaurus.config.js"
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
// ...
|
||||
themeConfig: {
|
||||
googleAnalytics: {
|
||||
trackingID: 'UA-141789564-1',
|
||||
},
|
||||
// ...
|
||||
},
|
||||
presets: [
|
||||
[
|
||||
'@docusaurus/preset-classic',
|
||||
{
|
||||
// ...
|
||||
// highlight-start
|
||||
googleAnalytics: {
|
||||
trackingID: 'UA-141789564-1',
|
||||
},
|
||||
// highlight-end
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
#### `gaGtag` {#gagtag}
|
||||
|
||||
```jsx {5} title="docusaurus.config.js"
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
// ...
|
||||
themeConfig: {
|
||||
gtag: {
|
||||
trackingID: 'UA-141789564-1',
|
||||
},
|
||||
// ...
|
||||
},
|
||||
presets: [
|
||||
[
|
||||
'@docusaurus/preset-classic',
|
||||
{
|
||||
// ...
|
||||
// highlight-start
|
||||
gtag: {
|
||||
trackingID: 'UA-141789564-1',
|
||||
},
|
||||
// highlight-end
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue