mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-29 02:08:36 +02:00
refactor(types): JSDoc for docusaurus config fields (#7291)
This commit is contained in:
parent
fc8b7674e3
commit
5bed55aeda
9 changed files with 308 additions and 86 deletions
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
|
@ -27,7 +27,7 @@ jobs:
|
|||
cache: yarn
|
||||
- name: Installation
|
||||
run: yarn
|
||||
# run: yarn install --immutable # Fails if yarn.lock is modified (unfortunately only works for Yarn 2, and --frozen-lockfile is not the same!)
|
||||
# run: yarn install --immutable # Fails if yarn.lock is modified (unfortunately only works for Yarn 2, and --frozen-lockfile is not the same!)
|
||||
- name: Check immutable yarn.lock
|
||||
run: git diff --exit-code
|
||||
- name: Lint
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
"format:diff": "prettier --list-different .",
|
||||
"lint": "yarn lint:js && yarn lint:style && yarn lint:spelling",
|
||||
"lint:ci": "yarn lint:js --quiet && yarn lint:style && yarn lint:spelling",
|
||||
"lint:js": "eslint --cache --report-unused-disable-directives \"**/*.{js,jsx,ts,tsx,mjs}\"",
|
||||
"lint:js": "eslint --cache --report-unused-disable-directives \"**/*.{js,jsx,ts,tsx,mjs}\"",
|
||||
"lint:spelling": "cspell \"**\" --no-progress",
|
||||
"lint:style": "stylelint \"**/*.css\"",
|
||||
"lerna": "lerna",
|
||||
|
|
|
@ -10,7 +10,7 @@ import BrowserOnly from '@docusaurus/BrowserOnly';
|
|||
import type {Props} from '@theme/DebugJsonView';
|
||||
import type {ReactJsonViewProps} from 'react-json-view';
|
||||
|
||||
// Avoids "react-json-view" to display "root"
|
||||
// Avoids "react-json-view" displaying "root"
|
||||
const RootName = null;
|
||||
|
||||
// Seems ReactJson does not work with SSR
|
||||
|
|
257
packages/docusaurus-types/src/index.d.ts
vendored
257
packages/docusaurus-types/src/index.d.ts
vendored
|
@ -43,15 +43,36 @@ export type ThemeConfig = {
|
|||
};
|
||||
|
||||
export type I18nLocaleConfig = {
|
||||
/** The label displayed for this locale in the locales dropdown. */
|
||||
label: string;
|
||||
/**
|
||||
* BCP 47 language tag to use in `<html lang="...">` and in
|
||||
* `<link ... hreflang="...">`
|
||||
*/
|
||||
htmlLang: string;
|
||||
direction: string;
|
||||
/** Used to select the locale's CSS and html meta attribute. */
|
||||
direction: 'ltr' | 'rtl';
|
||||
/**
|
||||
* The [calendar](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar)
|
||||
* used to calculate the date era. Note that it doesn't control the actual
|
||||
* string displayed: `MM/DD/YYYY` and `DD/MM/YYYY` are both gregory. To choose
|
||||
* the format (`DD/MM/YYYY` or `MM/DD/YYYY`), set your locale name to `en-GB`
|
||||
* or `en-US` (`en` means `en-US`).
|
||||
*/
|
||||
calendar: string;
|
||||
};
|
||||
|
||||
export type I18nConfig = {
|
||||
/**
|
||||
* The locale that:
|
||||
* 1. Does not have its name in the base URL
|
||||
* 2. Gets started with `docusaurus start` without `--locale` option
|
||||
* 3. Will be used for the `<link hrefLang="x-default">` tag
|
||||
*/
|
||||
defaultLocale: string;
|
||||
/** List of locales deployed on your site. Must contain `defaultLocale`. */
|
||||
locales: [string, ...string[]];
|
||||
/** Individual options for each locale. */
|
||||
localeConfigs: {[locale: string]: Partial<I18nLocaleConfig>};
|
||||
};
|
||||
|
||||
|
@ -60,36 +81,188 @@ export type I18nConfig = {
|
|||
*/
|
||||
export type DocusaurusConfig = {
|
||||
/**
|
||||
* Always has both leading and trailing slash (`/base/`). May be localized.
|
||||
* Title for your website. Will be used in metadata and as browser tab title.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#title
|
||||
*/
|
||||
baseUrl: string;
|
||||
baseUrlIssueBanner: boolean;
|
||||
favicon?: string;
|
||||
tagline: string;
|
||||
title: string;
|
||||
/**
|
||||
* URL for your website. This can also be considered the top-level hostname.
|
||||
* For example, `https://facebook.github.io` is the URL of
|
||||
* https://facebook.github.io/metro/, and `https://docusaurus.io` is the URL
|
||||
* for https://docusaurus.io.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#url
|
||||
*/
|
||||
url: string;
|
||||
/**
|
||||
* `undefined` = legacy retrocompatible behavior. Usually it means `/file` =>
|
||||
* `/file/index.html`.
|
||||
* Can be considered as the path after the host. For example, `/metro/` is the
|
||||
* base URL of https://facebook.github.io/metro/. For URLs that have no path,
|
||||
* it should be set to `/`. Always has both leading and trailing slash.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#baseUrl
|
||||
*/
|
||||
baseUrl: string;
|
||||
/**
|
||||
* Path to your site favicon; must be a URL that can be used in link's href.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#favicon
|
||||
*/
|
||||
favicon?: string;
|
||||
/**
|
||||
* Allow to customize the presence/absence of a trailing slash at the end of
|
||||
* URLs/links, and how static HTML files are generated:
|
||||
*
|
||||
* - `undefined` (default): keeps URLs untouched, and emit
|
||||
* `/docs/myDoc/index.html` for `/docs/myDoc.md`
|
||||
* - `true`: add trailing slashes to URLs/links, and emit
|
||||
* `/docs/myDoc/index.html` for `/docs/myDoc.md`
|
||||
* - `false`: remove trailing slashes from URLs/links, and emit
|
||||
* `/docs/myDoc.html` for `/docs/myDoc.md`
|
||||
*
|
||||
* @see https://github.com/slorber/trailing-slash-guide
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#trailingSlash
|
||||
* @default undefined
|
||||
*/
|
||||
trailingSlash: boolean | undefined;
|
||||
/**
|
||||
* The i18n configuration object to [localize your
|
||||
* site](https://docusaurus.io/docs/i18n/introduction).
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#i18n
|
||||
*/
|
||||
i18n: I18nConfig;
|
||||
onBrokenLinks: ReportingSeverity;
|
||||
onBrokenMarkdownLinks: ReportingSeverity;
|
||||
onDuplicateRoutes: ReportingSeverity;
|
||||
/**
|
||||
* This option adds `<meta name="robots" content="noindex, nofollow">` to
|
||||
* every page to tell search engines to avoid indexing your site.
|
||||
*
|
||||
* @see https://moz.com/learn/seo/robots-meta-directives
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#noIndex
|
||||
* @default false
|
||||
*/
|
||||
noIndex: boolean;
|
||||
/**
|
||||
* The behavior of Docusaurus when it detects any broken link.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#onBrokenLinks
|
||||
* @default "throw"
|
||||
*/
|
||||
onBrokenLinks: ReportingSeverity;
|
||||
/**
|
||||
* The behavior of Docusaurus when it detects any broken markdown link.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#onBrokenMarkdownLinks
|
||||
* @default "warn"
|
||||
*/
|
||||
onBrokenMarkdownLinks: ReportingSeverity;
|
||||
/**
|
||||
* The behavior of Docusaurus when it detects any [duplicate
|
||||
* routes](https://docusaurus.io/docs/creating-pages#duplicate-routes).
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#onDuplicateRoutes
|
||||
* @default "warn"
|
||||
*/
|
||||
onDuplicateRoutes: ReportingSeverity;
|
||||
/**
|
||||
* The tagline for your website.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#tagline
|
||||
* @default ""
|
||||
*/
|
||||
tagline: string;
|
||||
/**
|
||||
* The GitHub user or organization that owns the repository. You don't need
|
||||
* this if you are not using the `docusaurus deploy` command.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#organizationName
|
||||
*/
|
||||
organizationName?: string;
|
||||
/**
|
||||
* The name of the GitHub repository. You don't need this if you are not using
|
||||
* the `docusaurus deploy` command.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#projectName
|
||||
*/
|
||||
projectName?: string;
|
||||
/**
|
||||
* The name of the branch to deploy the static files to. You don't need this
|
||||
* if you are not using the `docusaurus deploy` command.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#deploymentBranch
|
||||
*/
|
||||
deploymentBranch?: string;
|
||||
/**
|
||||
* The hostname of your server. Useful if you are using GitHub Enterprise. You
|
||||
* don't need this if you are not using the `docusaurus deploy` command.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#githubHost
|
||||
*/
|
||||
githubHost?: string;
|
||||
/**
|
||||
* The port of your server. Useful if you are using GitHub Enterprise. You
|
||||
* don't need this if you are not using the `docusaurus deploy` command.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#githubPort
|
||||
*/
|
||||
githubPort?: string;
|
||||
plugins: PluginConfig[];
|
||||
themes: PluginConfig[];
|
||||
presets: PresetConfig[];
|
||||
/**
|
||||
* The [theme configuration](https://docusaurus.io/docs/api/themes/configuration)
|
||||
* object to customize your site UI like navbar and footer.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#themeConfig
|
||||
* @default {}
|
||||
*/
|
||||
themeConfig: ThemeConfig;
|
||||
/**
|
||||
* List of plugins.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#plugins
|
||||
* @default []
|
||||
*/
|
||||
plugins: PluginConfig[];
|
||||
/**
|
||||
* List of themes.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#themes
|
||||
* @default []
|
||||
*/
|
||||
themes: PluginConfig[];
|
||||
/**
|
||||
* List of presets.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#presets
|
||||
* @default []
|
||||
*/
|
||||
presets: PresetConfig[];
|
||||
/**
|
||||
* Docusaurus guards `docusaurus.config.js` from unknown fields. To add a
|
||||
* custom field, define it on `customFields`.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#customFields
|
||||
* @default {}
|
||||
*/
|
||||
customFields?: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
/**
|
||||
* An array of paths, relative to the site's directory or absolute. Files
|
||||
* under these paths will be copied to the build output as-is.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#staticDirectories
|
||||
* @default ["static"]
|
||||
*/
|
||||
staticDirectories: string[];
|
||||
/**
|
||||
* An array of scripts to load. The values can be either strings or plain
|
||||
* objects of attribute-value maps. The `<script>` tags will be inserted in
|
||||
* the HTML `<head>`.
|
||||
*
|
||||
* Note that `<script>` added here are render-blocking, so you might want to
|
||||
* add `async: true`/`defer: true` to the objects.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#scripts
|
||||
* @default []
|
||||
*/
|
||||
scripts: (
|
||||
| string
|
||||
| {
|
||||
|
@ -97,9 +270,14 @@ export type DocusaurusConfig = {
|
|||
[key: string]: string | boolean | undefined;
|
||||
}
|
||||
)[];
|
||||
clientModules: string[];
|
||||
ssrTemplate?: string;
|
||||
staticDirectories: string[];
|
||||
/**
|
||||
* An array of CSS sources to load. The values can be either strings or plain
|
||||
* objects of attribute-value maps. The `<link>` tags will be inserted in the
|
||||
* HTML `<head>`.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#stylesheets
|
||||
* @default []
|
||||
*/
|
||||
stylesheets: (
|
||||
| string
|
||||
| {
|
||||
|
@ -107,8 +285,49 @@ export type DocusaurusConfig = {
|
|||
[key: string]: string | boolean | undefined;
|
||||
}
|
||||
)[];
|
||||
titleDelimiter?: string;
|
||||
/**
|
||||
* An array of [client modules](https://docusaurus.io/docs/advanced/client#client-modules)
|
||||
* to load globally on your site.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#clientModules
|
||||
* @default []
|
||||
*/
|
||||
clientModules: string[];
|
||||
/**
|
||||
* An HTML template written in [Eta's syntax](https://eta.js.org/docs/syntax#syntax-overview)
|
||||
* that will be used to render your application. This can be used to set
|
||||
* custom attributes on the `body` tags, additional `meta` tags, customize the
|
||||
* `viewport`, etc. Please note that Docusaurus will rely on the template to
|
||||
* be correctly structured in order to function properly, once you do
|
||||
* customize it, you will have to make sure that your template is compliant
|
||||
* with the requirements from upstream.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#ssrTemplate
|
||||
*/
|
||||
ssrTemplate?: string;
|
||||
/**
|
||||
* Will be used as title delimiter in the generated `<title>` tag.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#titleDelimiter
|
||||
* @default "|"
|
||||
*/
|
||||
titleDelimiter: string;
|
||||
/**
|
||||
* When enabled, will show a banner in case your site can't load its CSS or
|
||||
* JavaScript files, which is a very common issue, often related to a wrong
|
||||
* `baseUrl` in site config.
|
||||
*
|
||||
* @see https://docusaurus.io/docs/api/docusaurus-config#baseUrlIssueBanner
|
||||
* @default true
|
||||
*/
|
||||
baseUrlIssueBanner: boolean;
|
||||
/** Webpack-related options. */
|
||||
webpack?: {
|
||||
/**
|
||||
* Configuration for alternative JS loaders. "babel" will use the built-in
|
||||
* Babel loader and preset; otherwise, you can provide your custom Webpack
|
||||
* rule set.
|
||||
*/
|
||||
jsLoader: 'babel' | ((isServer: boolean) => RuleSetRule);
|
||||
};
|
||||
};
|
||||
|
@ -230,7 +449,7 @@ export type LoadContext = {
|
|||
outDir: string;
|
||||
/**
|
||||
* Duplicated from `siteConfig.baseUrl`, but probably worth keeping. We mutate
|
||||
* `siteConfig` to make `baseUrl` there localized as well, but that's mostly
|
||||
* `siteConfig` to make `baseUrl` there localized as well, but that's mostly
|
||||
* for client-side. `context.baseUrl` is still more convenient for plugins.
|
||||
*/
|
||||
baseUrl: string;
|
||||
|
|
|
@ -223,8 +223,8 @@ export const ConfigSchema = Joi.object({
|
|||
.items(Joi.string())
|
||||
.default(DEFAULT_CONFIG.clientModules),
|
||||
tagline: Joi.string().allow('').default(DEFAULT_CONFIG.tagline),
|
||||
titleDelimiter: Joi.string().default('|'),
|
||||
noIndex: Joi.bool().default(false),
|
||||
titleDelimiter: Joi.string().default(DEFAULT_CONFIG.titleDelimiter),
|
||||
noIndex: Joi.bool().default(DEFAULT_CONFIG.noIndex),
|
||||
webpack: Joi.object({
|
||||
jsLoader: Joi.alternatives()
|
||||
.try(Joi.string().equal('babel'), Joi.function())
|
||||
|
|
|
@ -52,7 +52,7 @@ module.exports = Promise.resolve({
|
|||
|
||||
- Type: `string`
|
||||
|
||||
Title for your website.
|
||||
Title for your website. Will be used in metadata and as browser tab title.
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
|
@ -72,11 +72,11 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
### `baseUrl` {#baseurl}
|
||||
### `baseUrl` {#baseUrl}
|
||||
|
||||
- Type: `string`
|
||||
|
||||
Base URL for your site. This can also be considered the path after the host. For example, `/metro/` is the base URL of https://facebook.github.io/metro/. For URLs that have no path, the baseUrl should be set to `/`. This field is related to the [url](#url) field.
|
||||
Base URL for your site. Can be considered as the path after the host. For example, `/metro/` is the base URL of https://facebook.github.io/metro/. For URLs that have no path, the baseUrl should be set to `/`. This field is related to the [url](#url) field. Always has both leading and trailing slash.
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
|
@ -90,7 +90,7 @@ module.exports = {
|
|||
|
||||
- Type: `string | undefined`
|
||||
|
||||
Path to your site favicon. For example, if your favicon is in `static/img/favicon.ico`:
|
||||
Path to your site favicon; must be a URL that can be used in link's href. For example, if your favicon is in `static/img/favicon.ico`:
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
|
@ -98,7 +98,7 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
### `trailingSlash` {#trailing-slash}
|
||||
### `trailingSlash` {#trailingSlash}
|
||||
|
||||
- Type: `boolean | undefined`
|
||||
|
||||
|
@ -149,16 +149,19 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
- `label`: the label to use for this locale
|
||||
- `direction`: `ltr` (default) or `rtl` (for [right-to-left languages](https://developer.mozilla.org/en-US/docs/Glossary/rtl) like Arabic, Hebrew, etc.)
|
||||
- `htmlLang`: BCP 47 language tag to use in `<html lang="...">` and in `<link ... hreflang="...">`
|
||||
- `calendar`: the [calendar](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar) used to calculate the date era. Note that it doesn't control the actual string displayed: `MM/DD/YYYY` and `DD/MM/YYYY` are both `gregory`. To choose the format (`DD/MM/YYYY` or `MM/DD/YYYY`), set your locale name to `en-GB` or `en-US` (`en` means `en-US`).
|
||||
- `defaultLocale`: The locale that (1) does not have its name in the base URL (2) gets started with `docusaurus start` without `--locale` option (3) will be used for the `<link hrefLang="x-default">` tag
|
||||
- `locales`: List of locales deployed on your site. Must contain `defaultLocale`.
|
||||
- `localeConfigs`: Individual options for each locale.
|
||||
- `label`: The label displayed for this locale in the locales dropdown.
|
||||
- `direction`: `ltr` (default) or `rtl` (for [right-to-left languages](https://developer.mozilla.org/en-US/docs/Glossary/rtl) like Arabic, Hebrew, etc.). Used to select the locale's CSS and html meta attribute.
|
||||
- `htmlLang`: BCP 47 language tag to use in `<html lang="...">` and in `<link ... hreflang="...">`
|
||||
- `calendar`: the [calendar](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Locale/calendar) used to calculate the date era. Note that it doesn't control the actual string displayed: `MM/DD/YYYY` and `DD/MM/YYYY` are both `gregory`. To choose the format (`DD/MM/YYYY` or `MM/DD/YYYY`), set your locale name to `en-GB` or `en-US` (`en` means `en-US`).
|
||||
|
||||
### `noIndex` {#noindex}
|
||||
### `noIndex` {#noIndex}
|
||||
|
||||
- Type: `boolean`
|
||||
|
||||
This option adds `<meta name="robots" content="noindex, nofollow">` in pages, to tell search engines to avoid indexing your site (more information [here](https://moz.com/learn/seo/robots-meta-directives)).
|
||||
This option adds `<meta name="robots" content="noindex, nofollow">` to every page to tell search engines to avoid indexing your site (more information [here](https://moz.com/learn/seo/robots-meta-directives)).
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -168,11 +171,11 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
### `onBrokenLinks` {#onbrokenlinks}
|
||||
### `onBrokenLinks` {#onBrokenLinks}
|
||||
|
||||
- Type: `'ignore' | 'log' | 'warn' | 'error' | 'throw'`
|
||||
|
||||
The behavior of Docusaurus, when it detects any broken link.
|
||||
The behavior of Docusaurus when it detects any broken link.
|
||||
|
||||
By default, it throws an error, to ensure you never ship any broken link, but you can lower this security if needed.
|
||||
|
||||
|
@ -182,15 +185,15 @@ The broken links detection is only available for a production build (`docusaurus
|
|||
|
||||
:::
|
||||
|
||||
### `onBrokenMarkdownLinks` {#onbrokenmarkdownlinks}
|
||||
### `onBrokenMarkdownLinks` {#onBrokenMarkdownLinks}
|
||||
|
||||
- Type: `'ignore' | 'log' | 'warn' | 'error' | 'throw'`
|
||||
|
||||
The behavior of Docusaurus, when it detects any broken markdown link.
|
||||
The behavior of Docusaurus when it detects any broken markdown link.
|
||||
|
||||
By default, it prints a warning, to let you know about your broken markdown link, but you can change this security if needed.
|
||||
|
||||
### `onDuplicateRoutes` {#onduplicateroutes}
|
||||
### `onDuplicateRoutes` {#onDuplicateRoutes}
|
||||
|
||||
- Type: `'ignore' | 'log' | 'warn' | 'error' | 'throw'`
|
||||
|
||||
|
@ -211,11 +214,11 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
### `organizationName` {#organizationname}
|
||||
### `organizationName` {#organizationName}
|
||||
|
||||
- Type: `string`
|
||||
|
||||
The GitHub user or organization that owns the repository. Used by the deployment command.
|
||||
The GitHub user or organization that owns the repository. You don't need this if you are not using the `docusaurus deploy` command.
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
|
@ -224,11 +227,11 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
### `projectName` {#projectname}
|
||||
### `projectName` {#projectName}
|
||||
|
||||
- Type: `string`
|
||||
|
||||
The name of the GitHub repository. Used by the deployment command.
|
||||
The name of the GitHub repository. You don't need this if you are not using the `docusaurus deploy` command.
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
|
@ -236,11 +239,11 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
### `deploymentBranch` {#deploymentbranch}
|
||||
### `deploymentBranch` {#deploymentBranch}
|
||||
|
||||
- Type: `string`
|
||||
|
||||
The name of the branch to deploy the static files to. Used by the deployment command.
|
||||
The name of the branch to deploy the static files to. You don't need this if you are not using the `docusaurus deploy` command.
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
|
@ -248,11 +251,11 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
### `githubHost` {#githubhost}
|
||||
### `githubHost` {#githubHost}
|
||||
|
||||
- Type: `string`
|
||||
|
||||
The hostname of your server. Useful if you are using GitHub Enterprise.
|
||||
The hostname of your server. Useful if you are using GitHub Enterprise. You don't need this if you are not using the `docusaurus deploy` command.
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
|
@ -264,7 +267,7 @@ module.exports = {
|
|||
|
||||
- Type: `string`
|
||||
|
||||
The port of your server. Useful if you are using GitHub Enterprise.
|
||||
The port of your server. Useful if you are using GitHub Enterprise. You don't need this if you are not using the `docusaurus deploy` command.
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
|
@ -272,11 +275,11 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
### `themeConfig` {#themeconfig}
|
||||
### `themeConfig` {#themeConfig}
|
||||
|
||||
- Type: `Object`
|
||||
|
||||
The [theme configuration](./themes/theme-configuration.md) object, to customize your site UI like navbar, footer.
|
||||
The [theme configuration](./themes/theme-configuration.md) object to customize your site UI like navbar and footer.
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -403,7 +406,7 @@ Attempting to add unknown fields in the config will lead to errors during build
|
|||
Error: The field(s) 'foo', 'bar' are not recognized in docusaurus.config.js
|
||||
```
|
||||
|
||||
### `staticDirectories` {#staticdirectories}
|
||||
### `staticDirectories` {#staticDirectories}
|
||||
|
||||
An array of paths, relative to the site's directory or absolute. Files under these paths will be copied to the build output as-is.
|
||||
|
||||
|
@ -421,7 +424,7 @@ module.exports = {
|
|||
|
||||
An array of scripts to load. The values can be either strings or plain objects of attribute-value maps. The `<script>` tags will be inserted in the HTML `<head>`.
|
||||
|
||||
Note that `<script>` added here are render-blocking so you might want to add `async: true`/`defer: true` to the objects.
|
||||
Note that `<script>` added here are render-blocking, so you might want to add `async: true`/`defer: true` to the objects.
|
||||
|
||||
- Type: `(string | Object)[]`
|
||||
|
||||
|
@ -441,9 +444,30 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
### `clientModules` {#clientmodules}
|
||||
### `stylesheets` {#stylesheets}
|
||||
|
||||
An array of [client modules](../advanced/client.md#client-modules) to load globally on your site:
|
||||
An array of CSS sources to load. The values can be either strings or plain objects of attribute-value maps. The `<link>` tags will be inserted in the HTML `<head>`.
|
||||
|
||||
- Type: `(string | Object)[]`
|
||||
|
||||
Example:
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
stylesheets: [
|
||||
// String format.
|
||||
'https://docusaurus.io/style.css',
|
||||
// Object format.
|
||||
{
|
||||
href: 'http://mydomain.com/style.css',
|
||||
},
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
### `clientModules` {#clientModules}
|
||||
|
||||
An array of [client modules](../advanced/client.md#client-modules) to load globally on your site.
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -456,9 +480,9 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
### `ssrTemplate` {#ssrtemplate}
|
||||
### `ssrTemplate` {#ssrTemplate}
|
||||
|
||||
An HTML template written in [Eta's syntax](https://eta.js.org/docs/syntax#syntax-overview) that will be used to render your application. This can be used to set custom attributes on the `body` tags, additional `meta` tags, customize the `viewport`, etc. Please note that Docusaurus will rely on the template to be correctly structured in order to function properly, once you do customize it, you will have to make sure that your template is compliant with the requirements from `upstream`.
|
||||
An HTML template written in [Eta's syntax](https://eta.js.org/docs/syntax#syntax-overview) that will be used to render your application. This can be used to set custom attributes on the `body` tags, additional `meta` tags, customize the `viewport`, etc. Please note that Docusaurus will rely on the template to be correctly structured in order to function properly, once you do customize it, you will have to make sure that your template is compliant with the requirements from upstream.
|
||||
|
||||
- Type: `string`
|
||||
|
||||
|
@ -500,32 +524,11 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
### `stylesheets` {#stylesheets}
|
||||
|
||||
An array of CSS sources to load. The values can be either strings or plain objects of attribute-value maps. The `<link>` tags will be inserted in the HTML `<head>`.
|
||||
|
||||
- Type: `(string | Object)[]`
|
||||
|
||||
Example:
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
module.exports = {
|
||||
stylesheets: [
|
||||
// String format.
|
||||
'https://docusaurus.io/style.css',
|
||||
// Object format.
|
||||
{
|
||||
href: 'http://mydomain.com/style.css',
|
||||
},
|
||||
],
|
||||
};
|
||||
```
|
||||
|
||||
### `titleDelimiter` {#titledelimiter}
|
||||
### `titleDelimiter` {#titleDelimiter}
|
||||
|
||||
- Type: `string`
|
||||
|
||||
A string that will be used as title delimiter in the generated `<title>` tag.
|
||||
Will be used as title delimiter in the generated `<title>` tag.
|
||||
|
||||
Example:
|
||||
|
||||
|
@ -535,7 +538,7 @@ module.exports = {
|
|||
};
|
||||
```
|
||||
|
||||
### `baseUrlIssueBanner` {#baseurlissuebanner}
|
||||
### `baseUrlIssueBanner` {#baseurlIssueBanner}
|
||||
|
||||
- Type: `boolean`
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ Accepted fields:
|
|||
|
||||
This plugin also respects some site config:
|
||||
|
||||
- [`noIndex`](../docusaurus.config.js.md#noindex): results in no sitemap generated
|
||||
- [`trailingSlash`](../docusaurus.config.js.md#trailing-slash): determines if the URLs in the sitemap have trailing slashes
|
||||
- [`noIndex`](../docusaurus.config.js.md#noIndex): results in no sitemap generated
|
||||
- [`trailingSlash`](../docusaurus.config.js.md#trailingSlash): determines if the URLs in the sitemap have trailing slashes
|
||||
|
||||
:::
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ By default, this will load your site at [http://localhost:3000/](http://localhos
|
|||
|
||||
## Trailing slash configuration {#trailing-slashes}
|
||||
|
||||
Docusaurus has a [`trailingSlash` config](./api/docusaurus.config.js.md#trailing-slash), to allow customizing URLs/links and emitted filename patterns.
|
||||
Docusaurus has a [`trailingSlash` config](./api/docusaurus.config.js.md#trailingSlash), to allow customizing URLs/links and emitted filename patterns.
|
||||
|
||||
The default value generally works fine. Unfortunately, each static hosting provider has a **different behavior**, and deploying the exact same site to various hosts can lead to distinct results. Depending on your host, it can be useful to change this config.
|
||||
|
||||
|
@ -56,7 +56,7 @@ Use [slorber/trailing-slash-guide](https://github.com/slorber/trailing-slash-gui
|
|||
|
||||
## Using environment variables {#using-environment-variables}
|
||||
|
||||
Putting potentially sensitive information in the environment is common practice. However, in a typical Docusaurus website, the `docusaurus.config.js` file is the only interface to the Node.js environment (see [our architecture overview](advanced/architecture.md)), while everything else—MDX pages, React components... are client side and do not have direct access to the `process` global. In this case, you can consider using [`customFields`](api/docusaurus.config.js.md#customfields) to pass environment variables to the client side.
|
||||
Putting potentially sensitive information in the environment is common practice. However, in a typical Docusaurus website, the `docusaurus.config.js` file is the only interface to the Node.js environment (see [our architecture overview](advanced/architecture.md)), while everything else—MDX pages, React components... are client side and do not have direct access to the `process` global. In this case, you can consider using [`customFields`](api/docusaurus.config.js.md#customFields) to pass environment variables to the client side.
|
||||
|
||||
```js title="docusaurus.config.js"
|
||||
// If you are using dotenv (https://www.npmjs.com/package/dotenv)
|
||||
|
|
|
@ -43,7 +43,7 @@ Using relative _file_ paths (with `.md` extensions) instead of relative _URL_ li
|
|||
- You can customize the files' slugs without having to update all the links
|
||||
- Moving files around the folders can be tracked by your editor, and some editors may automatically update file links
|
||||
- A [versioned doc](../docs/versioning.md) will link to another doc of the exact same version
|
||||
- Relative URL links are very likely to break if you update the [`trailingSlash` config](../../api/docusaurus.config.js.md#trailing-slash)
|
||||
- Relative URL links are very likely to break if you update the [`trailingSlash` config](../../api/docusaurus.config.js.md#trailingSlash)
|
||||
|
||||
:::warning
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue