mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-29 08:57:03 +02:00
chore(v2): mark tagline field as optional (#2342)
This commit is contained in:
parent
7b2716e6e1
commit
3cbee86e36
5 changed files with 20 additions and 19 deletions
2
packages/docusaurus-types/src/index.d.ts
vendored
2
packages/docusaurus-types/src/index.d.ts
vendored
|
@ -12,7 +12,7 @@ import {ParsedUrlQueryInput} from 'querystring';
|
||||||
export interface DocusaurusConfig {
|
export interface DocusaurusConfig {
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
favicon: string;
|
favicon: string;
|
||||||
tagline: string;
|
tagline?: string;
|
||||||
title: string;
|
title: string;
|
||||||
url: string;
|
url: string;
|
||||||
organizationName?: string;
|
organizationName?: string;
|
||||||
|
|
|
@ -13,12 +13,12 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
|
||||||
function Layout(props) {
|
function Layout(props) {
|
||||||
const context = useDocusaurusContext();
|
const context = useDocusaurusContext();
|
||||||
const {siteConfig = {}} = context;
|
const {siteConfig = {}} = context;
|
||||||
const {favicon, tagline, title: defaultTitle} = siteConfig;
|
const {favicon, tagline = '', title: defaultTitle} = siteConfig;
|
||||||
const {children, title, description} = props;
|
const {children, title, description} = props;
|
||||||
const faviconUrl = useBaseUrl(favicon);
|
const faviconUrl = useBaseUrl(favicon);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head defaultTitle={`${defaultTitle} · ${tagline}`}>
|
<Head defaultTitle={`${defaultTitle}${tagline ? ` · ${tagline}` : ''}`}>
|
||||||
{title && <title>{`${title} · ${tagline}`}</title>}
|
{title && <title>{`${title} · ${tagline}`}</title>}
|
||||||
{favicon && <link rel="shortcut icon" href={faviconUrl} />}
|
{favicon && <link rel="shortcut icon" href={faviconUrl} />}
|
||||||
{description && <meta name="description" content={description} />}
|
{description && <meta name="description" content={description} />}
|
||||||
|
|
|
@ -41,7 +41,7 @@ describe('loadConfig', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
loadConfig(siteDir);
|
loadConfig(siteDir);
|
||||||
}).toThrowErrorMatchingInlineSnapshot(
|
}).toThrowErrorMatchingInlineSnapshot(
|
||||||
`"The required field(s) 'favicon', 'tagline', 'url' are missing from docusaurus.config.js"`,
|
`"The required field(s) 'favicon', 'url' are missing from docusaurus.config.js"`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ import path from 'path';
|
||||||
import {CONFIG_FILE_NAME} from '../constants';
|
import {CONFIG_FILE_NAME} from '../constants';
|
||||||
import {DocusaurusConfig, PluginConfig} from '@docusaurus/types';
|
import {DocusaurusConfig, PluginConfig} from '@docusaurus/types';
|
||||||
|
|
||||||
const REQUIRED_FIELDS = ['baseUrl', 'favicon', 'tagline', 'title', 'url'];
|
const REQUIRED_FIELDS = ['baseUrl', 'favicon', 'title', 'url'];
|
||||||
|
|
||||||
const OPTIONAL_FIELDS = [
|
const OPTIONAL_FIELDS = [
|
||||||
'organizationName',
|
'organizationName',
|
||||||
|
@ -25,6 +25,7 @@ const OPTIONAL_FIELDS = [
|
||||||
'themeConfig',
|
'themeConfig',
|
||||||
'scripts',
|
'scripts',
|
||||||
'stylesheets',
|
'stylesheets',
|
||||||
|
'tagline',
|
||||||
];
|
];
|
||||||
|
|
||||||
const DEFAULT_CONFIG: {
|
const DEFAULT_CONFIG: {
|
||||||
|
|
|
@ -23,20 +23,6 @@ module.exports = {
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
### `tagline`
|
|
||||||
|
|
||||||
- Type: `string`
|
|
||||||
|
|
||||||
The tagline for your website.
|
|
||||||
|
|
||||||
```js
|
|
||||||
// docusaurus.config.js
|
|
||||||
module.exports = {
|
|
||||||
tagline:
|
|
||||||
'Docusaurus makes it easy to maintain Open Source documentation websites.',
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### `favicon`
|
### `favicon`
|
||||||
|
|
||||||
- Type: `string`
|
- Type: `string`
|
||||||
|
@ -98,6 +84,20 @@ module.exports = {
|
||||||
|
|
||||||
## Optional fields
|
## Optional fields
|
||||||
|
|
||||||
|
### `tagline`
|
||||||
|
|
||||||
|
- Type: `string`
|
||||||
|
|
||||||
|
The tagline for your website.
|
||||||
|
|
||||||
|
```js
|
||||||
|
// docusaurus.config.js
|
||||||
|
module.exports = {
|
||||||
|
tagline:
|
||||||
|
'Docusaurus makes it easy to maintain Open Source documentation websites.',
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
### `organizationName`
|
### `organizationName`
|
||||||
|
|
||||||
- Type: `string`
|
- Type: `string`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue