mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-11 15:22:29 +02:00
* feat(v2): Add themeConfig.noIndex option #3528 * feat(v2): Add themeConfig.noIndex optionthrough ssrTemplate * feat(v2): Include themeConfig.noIndex in CLI migration v1 to v2 * feat(v2): Remove themeConfig.noIndex from env dev
This commit is contained in:
parent
e5d9cdc871
commit
e0c644e623
12 changed files with 31 additions and 3 deletions
|
@ -12,6 +12,7 @@ module.exports = {
|
||||||
baseUrl: '/',
|
baseUrl: '/',
|
||||||
organizationName: 'facebook',
|
organizationName: 'facebook',
|
||||||
projectName: 'docusaurus',
|
projectName: 'docusaurus',
|
||||||
|
noIndex: true,
|
||||||
scripts: [
|
scripts: [
|
||||||
'https://buttons.github.io/buttons.js',
|
'https://buttons.github.io/buttons.js',
|
||||||
'https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js',
|
'https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js',
|
||||||
|
|
|
@ -21,7 +21,7 @@ const siteConfig = {
|
||||||
organizationName: 'facebook',
|
organizationName: 'facebook',
|
||||||
projectName: 'docusaurus',
|
projectName: 'docusaurus',
|
||||||
cname: 'docusaurus.io',
|
cname: 'docusaurus.io',
|
||||||
noIndex: false,
|
noIndex: true,
|
||||||
users,
|
users,
|
||||||
editUrl: 'https://github.com/facebook/docusaurus/edit/master/docs/',
|
editUrl: 'https://github.com/facebook/docusaurus/edit/master/docs/',
|
||||||
headerLinks: [
|
headerLinks: [
|
||||||
|
|
|
@ -296,6 +296,7 @@ export function createConfigFile({
|
||||||
baseUrl: siteConfig.baseUrl ?? '',
|
baseUrl: siteConfig.baseUrl ?? '',
|
||||||
organizationName: siteConfig.organizationName,
|
organizationName: siteConfig.organizationName,
|
||||||
projectName: siteConfig.projectName,
|
projectName: siteConfig.projectName,
|
||||||
|
noIndex: siteConfig.noIndex,
|
||||||
scripts: siteConfig.scripts,
|
scripts: siteConfig.scripts,
|
||||||
stylesheets: siteConfig.stylesheets,
|
stylesheets: siteConfig.stylesheets,
|
||||||
favicon: siteConfig.favicon ?? '',
|
favicon: siteConfig.favicon ?? '',
|
||||||
|
|
|
@ -35,6 +35,7 @@ export interface VersionTwoConfig {
|
||||||
url: string;
|
url: string;
|
||||||
organizationName?: string;
|
organizationName?: string;
|
||||||
projectName?: string;
|
projectName?: string;
|
||||||
|
noIndex?: boolean;
|
||||||
githubHost?: string;
|
githubHost?: string;
|
||||||
onBrokenLinks: string;
|
onBrokenLinks: string;
|
||||||
plugins: Array<[string, {[key: string]: any}]>;
|
plugins: Array<[string, {[key: string]: any}]>;
|
||||||
|
@ -94,7 +95,7 @@ export type VersionOneConfig = {
|
||||||
defaultVersionShown?: string;
|
defaultVersionShown?: string;
|
||||||
organizationName?: string;
|
organizationName?: string;
|
||||||
projectName?: string;
|
projectName?: string;
|
||||||
noIndex?: string;
|
noIndex?: boolean;
|
||||||
headerLinks?: Array<any>;
|
headerLinks?: Array<any>;
|
||||||
headerIcon?: string;
|
headerIcon?: string;
|
||||||
favicon?: string;
|
favicon?: string;
|
||||||
|
|
1
packages/docusaurus-types/src/index.d.ts
vendored
1
packages/docusaurus-types/src/index.d.ts
vendored
|
@ -22,6 +22,7 @@ export interface DocusaurusConfig {
|
||||||
url: string;
|
url: string;
|
||||||
onBrokenLinks: ReportingSeverity;
|
onBrokenLinks: ReportingSeverity;
|
||||||
onDuplicateRoutes: ReportingSeverity;
|
onDuplicateRoutes: ReportingSeverity;
|
||||||
|
noIndex: boolean;
|
||||||
organizationName?: string;
|
organizationName?: string;
|
||||||
projectName?: string;
|
projectName?: string;
|
||||||
githubHost?: string;
|
githubHost?: string;
|
||||||
|
|
|
@ -51,6 +51,7 @@ export default async function render(locals) {
|
||||||
onLinksCollected,
|
onLinksCollected,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
ssrTemplate,
|
ssrTemplate,
|
||||||
|
noIndex,
|
||||||
} = locals;
|
} = locals;
|
||||||
const location = routesLocation[locals.path];
|
const location = routesLocation[locals.path];
|
||||||
await preload(routes, location);
|
await preload(routes, location);
|
||||||
|
@ -101,6 +102,7 @@ export default async function render(locals) {
|
||||||
metaAttributes,
|
metaAttributes,
|
||||||
scripts,
|
scripts,
|
||||||
stylesheets,
|
stylesheets,
|
||||||
|
noIndex,
|
||||||
version: packageJson.version,
|
version: packageJson.version,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,9 @@ module.exports = `
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta name="generator" content="Docusaurus v<%= it.version %>">
|
<meta name="generator" content="Docusaurus v<%= it.version %>">
|
||||||
|
<%if (it.noIndex) { %>
|
||||||
|
<meta name="robots" content="noindex" />
|
||||||
|
<% } %>
|
||||||
<%~ it.headTags %>
|
<%~ it.headTags %>
|
||||||
<% it.metaAttributes.forEach((metaAttribute) => { %>
|
<% it.metaAttributes.forEach((metaAttribute) => { %>
|
||||||
<%~ metaAttribute %>
|
<%~ metaAttribute %>
|
||||||
|
|
|
@ -20,6 +20,7 @@ Object {
|
||||||
"baseUrl": "/",
|
"baseUrl": "/",
|
||||||
"customFields": Object {},
|
"customFields": Object {},
|
||||||
"favicon": "img/docusaurus.ico",
|
"favicon": "img/docusaurus.ico",
|
||||||
|
"noIndex": false,
|
||||||
"onBrokenLinks": "throw",
|
"onBrokenLinks": "throw",
|
||||||
"onDuplicateRoutes": "warn",
|
"onDuplicateRoutes": "warn",
|
||||||
"organizationName": "endiliey",
|
"organizationName": "endiliey",
|
||||||
|
|
|
@ -24,6 +24,7 @@ export const DEFAULT_CONFIG: Pick<
|
||||||
| 'customFields'
|
| 'customFields'
|
||||||
| 'themeConfig'
|
| 'themeConfig'
|
||||||
| 'titleDelimiter'
|
| 'titleDelimiter'
|
||||||
|
| 'noIndex'
|
||||||
> = {
|
> = {
|
||||||
onBrokenLinks: 'throw',
|
onBrokenLinks: 'throw',
|
||||||
onDuplicateRoutes: 'warn',
|
onDuplicateRoutes: 'warn',
|
||||||
|
@ -33,6 +34,7 @@ export const DEFAULT_CONFIG: Pick<
|
||||||
customFields: {},
|
customFields: {},
|
||||||
themeConfig: {},
|
themeConfig: {},
|
||||||
titleDelimiter: '|',
|
titleDelimiter: '|',
|
||||||
|
noIndex: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const PluginSchema = Joi.alternatives().try(
|
const PluginSchema = Joi.alternatives().try(
|
||||||
|
@ -94,6 +96,7 @@ const ConfigSchema = Joi.object({
|
||||||
clientModules: Joi.array().items(Joi.string()),
|
clientModules: Joi.array().items(Joi.string()),
|
||||||
tagline: Joi.string().allow(''),
|
tagline: Joi.string().allow(''),
|
||||||
titleDelimiter: Joi.string().default('|'),
|
titleDelimiter: Joi.string().default('|'),
|
||||||
|
noIndex: Joi.bool().default(false),
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO move to @docusaurus/utils-validation
|
// TODO move to @docusaurus/utils-validation
|
||||||
|
|
|
@ -32,6 +32,7 @@ export default function createServerConfig({
|
||||||
preBodyTags,
|
preBodyTags,
|
||||||
postBodyTags,
|
postBodyTags,
|
||||||
ssrTemplate,
|
ssrTemplate,
|
||||||
|
siteConfig: {noIndex},
|
||||||
} = props;
|
} = props;
|
||||||
const config = createBaseConfig(props, true, minify);
|
const config = createBaseConfig(props, true, minify);
|
||||||
|
|
||||||
|
@ -72,6 +73,7 @@ export default function createServerConfig({
|
||||||
postBodyTags,
|
postBodyTags,
|
||||||
onLinksCollected,
|
onLinksCollected,
|
||||||
ssrTemplate,
|
ssrTemplate,
|
||||||
|
noIndex,
|
||||||
},
|
},
|
||||||
paths: ssgPaths,
|
paths: ssgPaths,
|
||||||
}),
|
}),
|
||||||
|
|
|
@ -80,6 +80,20 @@ module.exports = {
|
||||||
|
|
||||||
## Optional fields
|
## Optional fields
|
||||||
|
|
||||||
|
### `noIndex`
|
||||||
|
|
||||||
|
- Type: `boolean`
|
||||||
|
|
||||||
|
This option adds `<meta name="robots" content="noindex">` in pages, to tell search engines to avoid indexing your site (more information [here](https://moz.com/learn/seo/robots-meta-directives)).
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
```js title="docusaurus.config.js"
|
||||||
|
module.exports = {
|
||||||
|
noIndex: true, // Defaults to false
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
### `onBrokenLinks`
|
### `onBrokenLinks`
|
||||||
|
|
||||||
- Type: `'ignore' | 'log' | 'warn' | 'error' | 'throw'`
|
- Type: `'ignore' | 'log' | 'warn' | 'error' | 'throw'`
|
||||||
|
|
|
@ -440,7 +440,6 @@ The following fields are all deprecated, you may remove from your configuration
|
||||||
- `markdownOptions` - We use MDX in v2 instead of Remarkable. Your markdown options have to be converted to Remark/Rehype plugins.
|
- `markdownOptions` - We use MDX in v2 instead of Remarkable. Your markdown options have to be converted to Remark/Rehype plugins.
|
||||||
- `markdownPlugins` - We use MDX in v2 instead of Remarkable. Your markdown plugins have to be converted to Remark/Rehype plugins.
|
- `markdownPlugins` - We use MDX in v2 instead of Remarkable. Your markdown plugins have to be converted to Remark/Rehype plugins.
|
||||||
- `manifest`
|
- `manifest`
|
||||||
- `noIndex`
|
|
||||||
- `onPageNav` - This is turned on by default now.
|
- `onPageNav` - This is turned on by default now.
|
||||||
- `separateCss` - It can imported in the same manner as `custom.css` mentioned above.
|
- `separateCss` - It can imported in the same manner as `custom.css` mentioned above.
|
||||||
- `scrollToTop`
|
- `scrollToTop`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue