chore(v2): mark tagline field as optional (#2342)

This commit is contained in:
Alexey Pyltsyn 2020-02-29 08:15:57 +03:00 committed by GitHub
parent 7b2716e6e1
commit 3cbee86e36
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 19 deletions

View file

@ -12,7 +12,7 @@ import {ParsedUrlQueryInput} from 'querystring';
export interface DocusaurusConfig {
baseUrl: string;
favicon: string;
tagline: string;
tagline?: string;
title: string;
url: string;
organizationName?: string;

View file

@ -13,12 +13,12 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
function Layout(props) {
const context = useDocusaurusContext();
const {siteConfig = {}} = context;
const {favicon, tagline, title: defaultTitle} = siteConfig;
const {favicon, tagline = '', title: defaultTitle} = siteConfig;
const {children, title, description} = props;
const faviconUrl = useBaseUrl(favicon);
return (
<>
<Head defaultTitle={`${defaultTitle} · ${tagline}`}>
<Head defaultTitle={`${defaultTitle}${tagline ? ` · ${tagline}` : ''}`}>
{title && <title>{`${title} · ${tagline}`}</title>}
{favicon && <link rel="shortcut icon" href={faviconUrl} />}
{description && <meta name="description" content={description} />}

View file

@ -41,7 +41,7 @@ describe('loadConfig', () => {
expect(() => {
loadConfig(siteDir);
}).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"`,
);
});

View file

@ -12,7 +12,7 @@ import path from 'path';
import {CONFIG_FILE_NAME} from '../constants';
import {DocusaurusConfig, PluginConfig} from '@docusaurus/types';
const REQUIRED_FIELDS = ['baseUrl', 'favicon', 'tagline', 'title', 'url'];
const REQUIRED_FIELDS = ['baseUrl', 'favicon', 'title', 'url'];
const OPTIONAL_FIELDS = [
'organizationName',
@ -25,6 +25,7 @@ const OPTIONAL_FIELDS = [
'themeConfig',
'scripts',
'stylesheets',
'tagline',
];
const DEFAULT_CONFIG: {

View file

@ -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`
- Type: `string`
@ -98,6 +84,20 @@ module.exports = {
## 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`
- Type: `string`