mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-02 11:47:23 +02:00
fix(v2): allow undefined favicon (#5054)
* fix(v2): allow undefined favicon * fix snapshots
This commit is contained in:
parent
05c85c7be7
commit
138b4c9975
7 changed files with 20 additions and 41 deletions
|
@ -99,7 +99,7 @@ export async function generateBlogFeed(
|
||||||
language: feedOptions.language,
|
language: feedOptions.language,
|
||||||
link: blogBaseUrl,
|
link: blogBaseUrl,
|
||||||
description: feedOptions.description || `${siteConfig.title} Blog`,
|
description: feedOptions.description || `${siteConfig.title} Blog`,
|
||||||
favicon: normalizeUrl([siteUrl, baseUrl, favicon]),
|
favicon: favicon ? normalizeUrl([siteUrl, baseUrl, favicon]) : undefined,
|
||||||
copyright: feedOptions.copyright,
|
copyright: feedOptions.copyright,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
2
packages/docusaurus-types/src/index.d.ts
vendored
2
packages/docusaurus-types/src/index.d.ts
vendored
|
@ -26,7 +26,7 @@ export type ThemeConfig = {
|
||||||
export interface DocusaurusConfig {
|
export interface DocusaurusConfig {
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
baseUrlIssueBanner: boolean;
|
baseUrlIssueBanner: boolean;
|
||||||
favicon: string;
|
favicon?: string;
|
||||||
tagline?: string;
|
tagline?: string;
|
||||||
title: string;
|
title: string;
|
||||||
url: string;
|
url: string;
|
||||||
|
|
|
@ -1,14 +1,12 @@
|
||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`loadConfig website with incomplete siteConfig 1`] = `
|
exports[`loadConfig website with incomplete siteConfig 1`] = `
|
||||||
"\\"favicon\\" is required
|
"\\"url\\" is required
|
||||||
\\"url\\" is required
|
|
||||||
"
|
"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`loadConfig website with useless field (wrong field) in siteConfig 1`] = `
|
exports[`loadConfig website with useless field (wrong field) in siteConfig 1`] = `
|
||||||
"\\"favicon\\" is required
|
"These field(s) (\\"useLessField\\",) are not recognized in docusaurus.config.js.
|
||||||
These field(s) (\\"useLessField\\",) are not recognized in docusaurus.config.js.
|
|
||||||
If you still want these fields to be in your configuration, put them in the \\"customFields\\" field.
|
If you still want these fields to be in your configuration, put them in the \\"customFields\\" field.
|
||||||
See https://docusaurus.io/docs/docusaurus.config.js/#customfields"
|
See https://docusaurus.io/docs/docusaurus.config.js/#customfields"
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -7,7 +7,6 @@ exports[`normalizeConfig should throw error for baseUrl without trailing \`/\` 1
|
||||||
|
|
||||||
exports[`normalizeConfig should throw error for required fields 1`] = `
|
exports[`normalizeConfig should throw error for required fields 1`] = `
|
||||||
"\\"baseUrl\\" is required
|
"\\"baseUrl\\" is required
|
||||||
\\"favicon\\" is required
|
|
||||||
\\"title\\" is required
|
\\"title\\" is required
|
||||||
\\"url\\" is required
|
\\"url\\" is required
|
||||||
\\"themes\\" must be an array
|
\\"themes\\" must be an array
|
||||||
|
|
|
@ -12,9 +12,8 @@ import {
|
||||||
} from '../configValidation';
|
} from '../configValidation';
|
||||||
import {DocusaurusConfig} from '@docusaurus/types';
|
import {DocusaurusConfig} from '@docusaurus/types';
|
||||||
|
|
||||||
const baseConfig = {
|
const baseConfig: DocusaurusConfig = {
|
||||||
baseUrl: '/',
|
baseUrl: '/',
|
||||||
favicon: 'some.ico',
|
|
||||||
title: 'my site',
|
title: 'my site',
|
||||||
url: 'https://mysite.com',
|
url: 'https://mysite.com',
|
||||||
};
|
};
|
||||||
|
|
|
@ -127,7 +127,7 @@ export const ConfigSchema = Joi.object({
|
||||||
.regex(new RegExp('/$', 'm'))
|
.regex(new RegExp('/$', 'm'))
|
||||||
.message('{{#label}} must be a string with a trailing slash.'),
|
.message('{{#label}} must be a string with a trailing slash.'),
|
||||||
baseUrlIssueBanner: Joi.boolean().default(DEFAULT_CONFIG.baseUrlIssueBanner),
|
baseUrlIssueBanner: Joi.boolean().default(DEFAULT_CONFIG.baseUrlIssueBanner),
|
||||||
favicon: Joi.string().required(),
|
favicon: Joi.string().optional(),
|
||||||
title: Joi.string().required(),
|
title: Joi.string().required(),
|
||||||
url: SiteUrlSchema,
|
url: SiteUrlSchema,
|
||||||
trailingSlash: Joi.boolean(), // No default value! undefined = retrocompatible legacy behavior!
|
trailingSlash: Joi.boolean(), // No default value! undefined = retrocompatible legacy behavior!
|
||||||
|
|
|
@ -24,37 +24,6 @@ module.exports = {
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
### `favicon` {#favicon}
|
|
||||||
|
|
||||||
- Type: `string`
|
|
||||||
|
|
||||||
URL for site favicon. Example:
|
|
||||||
|
|
||||||
```js title="docusaurus.config.js"
|
|
||||||
module.exports = {
|
|
||||||
favicon: 'https://docusaurus.io/favicon.ico',
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
You can also use the favicon URL relative to the `static` directory of your site. For example, your site has the following directory structure:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
.
|
|
||||||
├── README.md
|
|
||||||
├ # ... other files in root directory
|
|
||||||
└─ static
|
|
||||||
└── img
|
|
||||||
└── favicon.ico
|
|
||||||
```
|
|
||||||
|
|
||||||
So you can refer it like below:
|
|
||||||
|
|
||||||
```js title="docusaurus.config.js"
|
|
||||||
module.exports = {
|
|
||||||
favicon: 'img/favicon.ico',
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### `url` {#url}
|
### `url` {#url}
|
||||||
|
|
||||||
- Type: `string`
|
- Type: `string`
|
||||||
|
@ -81,6 +50,20 @@ module.exports = {
|
||||||
|
|
||||||
## Optional fields {#optional-fields}
|
## Optional fields {#optional-fields}
|
||||||
|
|
||||||
|
### `favicon` {#favicon}
|
||||||
|
|
||||||
|
- Type: `string | undefined`
|
||||||
|
|
||||||
|
Path to your site favicon
|
||||||
|
|
||||||
|
Example, if your favicon is in `static/img/favicon.ico`:
|
||||||
|
|
||||||
|
```js title="docusaurus.config.js"
|
||||||
|
module.exports = {
|
||||||
|
favicon: '/img/favicon.ico',
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
### `trailingSlash` {#trailing-slash}
|
### `trailingSlash` {#trailing-slash}
|
||||||
|
|
||||||
- Type: `boolean | undefined`
|
- Type: `boolean | undefined`
|
||||||
|
|
Loading…
Add table
Reference in a new issue