mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-12 16:47:26 +02:00
docs: create Docusaurus v2.1.0 release docs + changelog + release blog post (#8036)
This commit is contained in:
parent
55de3ea04b
commit
56feb41445
97 changed files with 265 additions and 68 deletions
61
CHANGELOG.md
61
CHANGELOG.md
|
@ -1,5 +1,66 @@
|
||||||
# Docusaurus 2 Changelog
|
# Docusaurus 2 Changelog
|
||||||
|
|
||||||
|
## 2.1.0 (2022-09-01)
|
||||||
|
|
||||||
|
#### :rocket: New Feature
|
||||||
|
|
||||||
|
- `docusaurus-theme-classic`, `docusaurus-theme-common`
|
||||||
|
- [#8008](https://github.com/facebook/docusaurus/pull/8008) feat(theme): ability to use `<DocCardList>` without items prop, on any doc page ([@slorber](https://github.com/slorber))
|
||||||
|
- `docusaurus-plugin-content-docs`, `docusaurus-theme-classic`
|
||||||
|
- [#7963](https://github.com/facebook/docusaurus/pull/7963) feat(docs): allow to configure noIndex per doc version ([@slorber](https://github.com/slorber))
|
||||||
|
- [#7949](https://github.com/facebook/docusaurus/pull/7949) feat(plugin-docs): docs sidebar item link: support "autoAddBaseUrl" attribute ([@slorber](https://github.com/slorber))
|
||||||
|
- `docusaurus-theme-translations`
|
||||||
|
- [#7953](https://github.com/facebook/docusaurus/pull/7953) feat(theme): adds Ukrainian default theme translations ([@b-ovsepian](https://github.com/b-ovsepian))
|
||||||
|
|
||||||
|
#### :bug: Bug Fix
|
||||||
|
|
||||||
|
- `create-docusaurus`
|
||||||
|
- [#8032](https://github.com/facebook/docusaurus/pull/8032) fix(create-docusaurus): tutorial and init template improvements ([@slorber](https://github.com/slorber))
|
||||||
|
- `docusaurus-preset-classic`
|
||||||
|
- [#8029](https://github.com/facebook/docusaurus/pull/8029) fix(preset-classic): broken link in "unrecognized keys" error message ([@mdubus](https://github.com/mdubus))
|
||||||
|
- `docusaurus`
|
||||||
|
- [#7977](https://github.com/facebook/docusaurus/pull/7977) fix(core): preload should support encoded page links ([@adventure-yunfei](https://github.com/adventure-yunfei))
|
||||||
|
- [#7996](https://github.com/facebook/docusaurus/pull/7996) fix(core): CLI command write-translations should extract translations from @docu… ([@slorber](https://github.com/slorber))
|
||||||
|
- [#7952](https://github.com/facebook/docusaurus/pull/7952) fix(core): allow overriding ssr/dev template meta tags ([@slorber](https://github.com/slorber))
|
||||||
|
- `docusaurus-plugin-sitemap`
|
||||||
|
- [#7964](https://github.com/facebook/docusaurus/pull/7964) fix(sitemap): filter all routes with robots meta containing noindex ([@slorber](https://github.com/slorber))
|
||||||
|
- `docusaurus-theme-classic`
|
||||||
|
- [#7910](https://github.com/facebook/docusaurus/pull/7910) fix(theme-classic): code block line number display with line wrapping ([@yzhe819](https://github.com/yzhe819))
|
||||||
|
- [#7786](https://github.com/facebook/docusaurus/pull/7786) fix: collapse siblings when first category is selected ([@whiteand](https://github.com/whiteand))
|
||||||
|
|
||||||
|
#### :nail_care: Polish
|
||||||
|
|
||||||
|
- `docusaurus-theme-classic`
|
||||||
|
- [#7982](https://github.com/facebook/docusaurus/pull/7982) fix(theme): add aria-label to skip to content link region ([@YoniChechik](https://github.com/YoniChechik))
|
||||||
|
- [#7940](https://github.com/facebook/docusaurus/pull/7940) refactor(theme-classic): split AnnouncementBar, increase z-index, use shadow ([@slorber](https://github.com/slorber))
|
||||||
|
- [#7876](https://github.com/facebook/docusaurus/pull/7876) refactor(theme-classic): make tag text visually certered ([@Kosai106](https://github.com/Kosai106))
|
||||||
|
- `docusaurus-utils`
|
||||||
|
- [#7941](https://github.com/facebook/docusaurus/pull/7941) feat(core): add new Webpack file-loader extensions: avif, mov, mkv, mpg, avi... ([@slorber](https://github.com/slorber))
|
||||||
|
- `docusaurus-theme-classic`, `docusaurus-types`
|
||||||
|
- [#7942](https://github.com/facebook/docusaurus/pull/7942) feat(theme-classic): use lang attribute in navbar locale dropdown items ([@slorber](https://github.com/slorber))
|
||||||
|
- `docusaurus-theme-translations`
|
||||||
|
- [#7928](https://github.com/facebook/docusaurus/pull/7928) chore(theme-translations): complete vi translations ([@datlechin](https://github.com/datlechin))
|
||||||
|
|
||||||
|
#### :memo: Documentation
|
||||||
|
|
||||||
|
- `create-docusaurus`
|
||||||
|
- [#8032](https://github.com/facebook/docusaurus/pull/8032) fix(create-docusaurus): tutorial and init template improvements ([@slorber](https://github.com/slorber))
|
||||||
|
- `docusaurus-plugin-content-blog`, `docusaurus-plugin-content-docs`, `docusaurus-plugin-content-pages`, `docusaurus-plugin-debug`, `docusaurus-plugin-google-analytics`, `docusaurus-plugin-google-gtag`, `docusaurus-plugin-ideal-image`, `docusaurus-plugin-sitemap`, `docusaurus-theme-classic`
|
||||||
|
- [#7905](https://github.com/facebook/docusaurus/pull/7905) docs: remove mention of beta ([@Josh-Cena](https://github.com/Josh-Cena))
|
||||||
|
|
||||||
|
#### Committers: 10
|
||||||
|
|
||||||
|
- Bagdasar Ovsepyan ([@b-ovsepian](https://github.com/b-ovsepian))
|
||||||
|
- Joshua Chen ([@Josh-Cena](https://github.com/Josh-Cena))
|
||||||
|
- Kevin Østerkilde ([@Kosai106](https://github.com/Kosai106))
|
||||||
|
- Morgane Dubus ([@mdubus](https://github.com/mdubus))
|
||||||
|
- Ngô Quốc Đạt ([@datlechin](https://github.com/datlechin))
|
||||||
|
- Sébastien Lorber ([@slorber](https://github.com/slorber))
|
||||||
|
- Yoni Chechik ([@YoniChechik](https://github.com/YoniChechik))
|
||||||
|
- [@whiteand](https://github.com/whiteand)
|
||||||
|
- [@yzhe819](https://github.com/yzhe819)
|
||||||
|
- adventure-yunfei ([@adventure-yunfei](https://github.com/adventure-yunfei))
|
||||||
|
|
||||||
## 2.0.1 (2022-08-01)
|
## 2.0.1 (2022-08-01)
|
||||||
|
|
||||||
Fix bad npm publish of 2.0.0
|
Fix bad npm publish of 2.0.0
|
||||||
|
|
BIN
website/blog/2022-09-01-docusaurus-2.1/img/doc-card-list.png
Normal file
BIN
website/blog/2022-09-01-docusaurus-2.1/img/doc-card-list.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 172 KiB |
BIN
website/blog/2022-09-01-docusaurus-2.1/img/social-card.png
Normal file
BIN
website/blog/2022-09-01-docusaurus-2.1/img/social-card.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 69 KiB |
85
website/blog/2022-09-01-docusaurus-2.1/index.mdx
Normal file
85
website/blog/2022-09-01-docusaurus-2.1/index.mdx
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
---
|
||||||
|
title: Docusaurus 2.1
|
||||||
|
authors:
|
||||||
|
- slorber
|
||||||
|
tags: [release]
|
||||||
|
image: ./img/social-card.png
|
||||||
|
---
|
||||||
|
|
||||||
|
We are happy announce **Docusaurus 2.1**, our very first minor version release.
|
||||||
|
|
||||||
|
The upgrade should be easy: as explained in our [release process documentation](/community/release-process), minor versions respect [Semantic Versioning](https://semver.org/).
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
<!--truncate-->
|
||||||
|
|
||||||
|
## Highlights
|
||||||
|
|
||||||
|
### DocCardList improvements
|
||||||
|
|
||||||
|
In [#8008](https://github.com/facebook/docusaurus/pull/8008), we simplified the usage of the`<DocCardList>` component, that is notably used on sidebar category generated index pages.
|
||||||
|
|
||||||
|
The `items` prop is now optional, and will be automatically inferred from the content of the parent sidebar category:
|
||||||
|
|
||||||
|
```diff
|
||||||
|
import DocCardList from '@theme/DocCardList';
|
||||||
|
- import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
||||||
|
|
||||||
|
- <DocCardList items={useCurrentSidebarCategory().items}/>
|
||||||
|
+ <DocCardList/>
|
||||||
|
```
|
||||||
|
|
||||||
|
Also, we made it possible to use it on any document, including regular docs not linked to any sidebar category.
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
### `noindex` improvements
|
||||||
|
|
||||||
|
We improved the support of the [`noindex` meta `robots` directive](https://developers.google.com/search/docs/advanced/crawling/block-indexing), a way to signal search engines you don't want a specific page to be indexed.
|
||||||
|
|
||||||
|
In [#7963](https://github.com/facebook/docusaurus/pull/7963), we allow `noindex` to be configured on a per-docs-version basis.
|
||||||
|
|
||||||
|
Use the following plugin options to tell crawlers you don't want the `1.0.0` version to be indexed:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
const options = {
|
||||||
|
versions: {
|
||||||
|
'1.0.0': {
|
||||||
|
noIndex: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
In practice, Docusaurus will add the following meta to each page of that version:
|
||||||
|
|
||||||
|
```html
|
||||||
|
<meta name="robots" content="noindex, nofollow" />
|
||||||
|
```
|
||||||
|
|
||||||
|
In [#7964](https://github.com/facebook/docusaurus/pull/7964), we also fixed a bug where the sitemap plugin would still contain pages that have a `noindex` directive. Now the sitemap plugin will reliably filter out all the pages containing `noindex` directives.
|
||||||
|
|
||||||
|
### Overriding default meta tags
|
||||||
|
|
||||||
|
In [#7952](https://github.com/facebook/docusaurus/pull/7952), it becomes possible to override default html meta tags you couldn't before:
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
<>
|
||||||
|
{siteConfig.noIndex && <meta name="robots" content="nofollow, noindex" />}
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
</>
|
||||||
|
```
|
||||||
|
|
||||||
|
It is now possible to use `<Head>` or `themeConfig.metadata`:
|
||||||
|
|
||||||
|
- to override the `viewport` meta
|
||||||
|
- to override the `robots` meta: you could mark your site as `noIndex`, but except for specific pages that should be indexed
|
||||||
|
|
||||||
|
### Ukrainian translations
|
||||||
|
|
||||||
|
In [#7953](https://github.com/facebook/docusaurus/pull/7953), we added default classic theme translations for the Ukrainian language.
|
||||||
|
|
||||||
|
## Other changes
|
||||||
|
|
||||||
|
Check the [2.1.0 changelog entry](/changelog/2.1.0) for an exhaustive list of changes.
|
|
@ -4,9 +4,8 @@ This section is not going to be very structured, but we will cover the following
|
||||||
|
|
||||||
```mdx-code-block
|
```mdx-code-block
|
||||||
import DocCardList from '@theme/DocCardList';
|
import DocCardList from '@theme/DocCardList';
|
||||||
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
||||||
|
|
||||||
<DocCardList items={useCurrentSidebarCategory().items}/>
|
<DocCardList />
|
||||||
```
|
```
|
||||||
|
|
||||||
We will assume that you have finished the guides, and know the basics like how to configure plugins, how to write React components, etc. These sections will have plugin authors and code contributors in mind, so we may occasionally refer to [plugin APIs](../api/plugin-methods/README.md) or other architecture details. Don't panic if you don't understand everything😉
|
We will assume that you have finished the guides, and know the basics like how to configure plugins, how to write React components, etc. These sections will have plugin authors and code contributors in mind, so we may occasionally refer to [plugin APIs](../api/plugin-methods/README.md) or other architecture details. Don't panic if you don't understand everything😉
|
|
@ -157,7 +157,7 @@ module.exports = {
|
||||||
- `localeConfigs`: Individual options for each locale.
|
- `localeConfigs`: Individual options for each locale.
|
||||||
- `label`: The label displayed for this locale in the locales dropdown.
|
- `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 Farsi, Arabic, Hebrew, etc.). Used to select the locale's CSS and HTML meta attribute.
|
- `direction`: `ltr` (default) or `rtl` (for [right-to-left languages](https://developer.mozilla.org/en-US/docs/Glossary/rtl) like Farsi, 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="...">`
|
- `htmlLang`: BCP 47 language tag to use in `<html lang="...">` (or any other DOM tag name) 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`).
|
- `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`).
|
||||||
- `path`: Root folder that all plugin localization folders of this locale are relative to. Will be resolved against `i18n.path`. Defaults to the locale's name. Note: this has no effect on the locale's `baseUrl`—customization of base URL is a work-in-progress.
|
- `path`: Root folder that all plugin localization folders of this locale are relative to. Will be resolved against `i18n.path`. Defaults to the locale's name. Note: this has no effect on the locale's `baseUrl`—customization of base URL is a work-in-progress.
|
||||||
|
|
||||||
|
@ -509,15 +509,11 @@ module.exports = {
|
||||||
<html <%~ it.htmlAttributes %>>
|
<html <%~ it.htmlAttributes %>>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<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, nofollow" />
|
|
||||||
<% } %>
|
|
||||||
<%~ it.headTags %>
|
|
||||||
<% it.metaAttributes.forEach((metaAttribute) => { %>
|
<% it.metaAttributes.forEach((metaAttribute) => { %>
|
||||||
<%~ metaAttribute %>
|
<%~ metaAttribute %>
|
||||||
<% }); %>
|
<% }); %>
|
||||||
|
<%~ it.headTags %>
|
||||||
<% it.stylesheets.forEach((stylesheet) => { %>
|
<% it.stylesheets.forEach((stylesheet) => { %>
|
||||||
<link rel="stylesheet" href="<%= it.baseUrl %><%= stylesheet %>" />
|
<link rel="stylesheet" href="<%= it.baseUrl %><%= stylesheet %>" />
|
||||||
<% }); %>
|
<% }); %>
|
Before Width: | Height: | Size: 92 KiB After Width: | Height: | Size: 92 KiB |
|
@ -142,23 +142,25 @@ type CategoryIndexMatcher = (param: {
|
||||||
#### `VersionsConfig` {#VersionsConfig}
|
#### `VersionsConfig` {#VersionsConfig}
|
||||||
|
|
||||||
```ts
|
```ts
|
||||||
type VersionsConfig = {
|
type VersionConfig = {
|
||||||
[versionName: string]: {
|
/**
|
||||||
/**
|
* The base path of the version, will be appended to `baseUrl` +
|
||||||
* The base path of the version, will be appended to `baseUrl` +
|
* `routeBasePath`.
|
||||||
* `routeBasePath`.
|
*/
|
||||||
*/
|
path?: string;
|
||||||
path?: string;
|
/** The label of the version to be used in badges, dropdowns, etc. */
|
||||||
/** The label of the version to be used in badges, dropdowns, etc. */
|
label?: string;
|
||||||
label?: string;
|
/** The banner to show at the top of a doc of that version. */
|
||||||
/** The banner to show at the top of a doc of that version. */
|
banner?: 'none' | 'unreleased' | 'unmaintained';
|
||||||
banner?: 'none' | 'unreleased' | 'unmaintained';
|
/** Show a badge with the version label at the top of each doc. */
|
||||||
/** Show a badge with the version label at the top of each doc. */
|
badge?: boolean;
|
||||||
badge?: boolean;
|
/** Prevents search engines from indexing this version */
|
||||||
/** Add a custom class name to the <html> element of each doc */
|
noIndex?: boolean;
|
||||||
className?: string;
|
/** Add a custom class name to the <html> element of each doc */
|
||||||
};
|
className?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type VersionsConfig = {[versionName: string]: VersionConfig};
|
||||||
```
|
```
|
||||||
|
|
||||||
### Example configuration {#ex-config}
|
### Example configuration {#ex-config}
|
|
@ -142,7 +142,7 @@ The [`standalone` strategy](https://petelepage.com/blog/2019/07/is-my-pwa-instal
|
||||||
|
|
||||||
### `injectManifestConfig` {#injectmanifestconfig}
|
### `injectManifestConfig` {#injectmanifestconfig}
|
||||||
|
|
||||||
[Workbox options](https://developers.google.com/web/tools/workbox/reference-docs/latest/module-workbox-build#.injectManifest) to pass to `workbox.injectManifest()`. This gives you control over which assets will be precached, and be available offline.
|
[Workbox options](https://developer.chrome.com/docs/workbox/reference/workbox-build/#type-InjectManifestOptions) to pass to `workbox.injectManifest()`. This gives you control over which assets will be precached, and be available offline.
|
||||||
|
|
||||||
- Type: `InjectManifestOptions`
|
- Type: `InjectManifestOptions`
|
||||||
- Default: `{}`
|
- Default: `{}`
|
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 68 KiB |
|
@ -320,14 +320,14 @@ GIT_USER=<GITHUB_USERNAME> yarn deploy
|
||||||
cmd /C "set "GIT_USER=<GITHUB_USERNAME>" && yarn deploy"
|
cmd /C "set "GIT_USER=<GITHUB_USERNAME>" && yarn deploy"
|
||||||
```
|
```
|
||||||
|
|
||||||
````mdx-code-block
|
```mdx-code-block
|
||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem value="powershell" label="PowerShell">
|
<TabItem value="powershell" label="PowerShell">
|
||||||
```mdx-code-block
|
```
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
cmd /C 'set "GIT_USER=<GITHUB_USERNAME>" && yarn deploy'
|
cmd /C 'set "GIT_USER=<GITHUB_USERNAME>" && yarn deploy'
|
||||||
````
|
```
|
||||||
|
|
||||||
```mdx-code-block
|
```mdx-code-block
|
||||||
</TabItem>
|
</TabItem>
|
|
@ -35,9 +35,8 @@ This section serves as an overview of miscellaneous features of the doc sidebar.
|
||||||
|
|
||||||
```mdx-code-block
|
```mdx-code-block
|
||||||
import DocCardList from '@theme/DocCardList';
|
import DocCardList from '@theme/DocCardList';
|
||||||
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
||||||
|
|
||||||
<DocCardList items={useCurrentSidebarCategory().items}/>
|
<DocCardList />
|
||||||
```
|
```
|
||||||
|
|
||||||
## Default sidebar {#default-sidebar}
|
## Default sidebar {#default-sidebar}
|
|
@ -8,6 +8,7 @@ slug: /sidebar/items
|
||||||
```mdx-code-block
|
```mdx-code-block
|
||||||
import Tabs from '@theme/Tabs';
|
import Tabs from '@theme/Tabs';
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
|
import BrowserWindow from '@site/src/components/BrowserWindow';
|
||||||
```
|
```
|
||||||
|
|
||||||
We have introduced three types of item types in the example in the previous section: `doc`, `category`, and `link`, whose usages are fairly intuitive. We will formally introduce their APIs. There's also a fourth type: `autogenerated`, which we will explain in detail later.
|
We have introduced three types of item types in the example in the previous section: `doc`, `category`, and `link`, whose usages are fairly intuitive. We will formally introduce their APIs. There's also a fourth type: `autogenerated`, which we will explain in detail later.
|
||||||
|
@ -291,18 +292,23 @@ See it in action on the [i18n introduction page](../../../i18n/i18n-introduction
|
||||||
|
|
||||||
#### Embedding generated index in doc page {#embedding-generated-index-in-doc-page}
|
#### Embedding generated index in doc page {#embedding-generated-index-in-doc-page}
|
||||||
|
|
||||||
You can embed the generated cards list in a normal doc page as well, as long as the doc is used as a category index page. To do so, you need to use the `DocCardList` component, paired with the `useCurrentSidebarCategory` hook.
|
You can embed the generated cards list in a normal doc page as well with the `DocCardList` component. It will display all the sidebar items of the parent category of the current document.
|
||||||
|
|
||||||
```jsx title="a-category-index-page.md"
|
```md title="docs/sidebar/index.md"
|
||||||
import DocCardList from '@theme/DocCardList';
|
import DocCardList from '@theme/DocCardList';
|
||||||
import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
|
|
||||||
|
|
||||||
In this section, we will introduce the following concepts:
|
<DocCardList />
|
||||||
|
|
||||||
<DocCardList items={useCurrentSidebarCategory().items}/>
|
|
||||||
```
|
```
|
||||||
|
|
||||||
See this in action on the [sidebar guides page](index.md).
|
```mdx-code-block
|
||||||
|
<BrowserWindow>
|
||||||
|
|
||||||
|
import DocCardList from '@theme/DocCardList';
|
||||||
|
|
||||||
|
<DocCardList />
|
||||||
|
|
||||||
|
</BrowserWindow>
|
||||||
|
```
|
||||||
|
|
||||||
### Collapsible categories {#collapsible-categories}
|
### Collapsible categories {#collapsible-categories}
|
||||||
|
|
|
@ -11,7 +11,7 @@ import Tabs from '@theme/Tabs';
|
||||||
import TabItem from '@theme/TabItem';
|
import TabItem from '@theme/TabItem';
|
||||||
import Admonition from '@theme/Admonition';
|
import Admonition from '@theme/Admonition';
|
||||||
|
|
||||||
In addition to the basic Markdown syntax, we use [remark-admonitions](https://github.com/elviswolcott/remark-admonitions) alongside MDX to add support for admonitions. Admonitions are wrapped by a set of 3 colons.
|
In addition to the basic Markdown syntax, we have a special admonitions syntax by wrapping text with a set of 3 colons, followed by a label denoting its type.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -107,7 +107,7 @@ Hello world
|
||||||
|
|
||||||
## Specifying title {#specifying-title}
|
## Specifying title {#specifying-title}
|
||||||
|
|
||||||
You may also specify an optional title
|
You may also specify an optional title.
|
||||||
|
|
||||||
```md
|
```md
|
||||||
:::note Your Title
|
:::note Your Title
|
||||||
|
@ -204,3 +204,53 @@ The types that are accepted are the same as above: `note`, `tip`, `danger`, `inf
|
||||||
</Admonition>
|
</Admonition>
|
||||||
</BrowserWindow>
|
</BrowserWindow>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Customizing admonitions {#customizing-admonitions}
|
||||||
|
|
||||||
|
There are two kinds of customizations possible with admonitions: **parsing** and **rendering**.
|
||||||
|
|
||||||
|
### Customizing rendering behavior {#customizing-rendering-behavior}
|
||||||
|
|
||||||
|
You can customize how each individual admonition type is rendered through [swizzling](../../swizzling.md). You can often achieve your goal through a simple wrapper. For example, in the follow example, we swap out the icon for `info` admonitions only.
|
||||||
|
|
||||||
|
```jsx title="src/theme/Admonition.js"
|
||||||
|
import React from 'react';
|
||||||
|
import Admonition from '@theme-original/Admonition';
|
||||||
|
import MyIcon from '@site/static/img/info.svg';
|
||||||
|
|
||||||
|
export default function AdmonitionWrapper(props) {
|
||||||
|
if (props.type !== 'info') {
|
||||||
|
return <Admonition {...props} />;
|
||||||
|
}
|
||||||
|
return <Admonition icon={<MyIcon />} {...props} />;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Customizing parsing behavior {#customizing-parsing-behavior}
|
||||||
|
|
||||||
|
Admonitions are implemented with a [Remark plugin](./markdown-features-plugins.mdx). The plugin is designed to be configurable. To customize the Remark plugin for a specific content plugin (docs, blog, pages), pass the options through the `admonitions` key.
|
||||||
|
|
||||||
|
```js title="docusaurus.config.js"
|
||||||
|
module.exports = {
|
||||||
|
presets: [
|
||||||
|
[
|
||||||
|
'@docusaurus/preset-classic',
|
||||||
|
{
|
||||||
|
docs: {
|
||||||
|
admonitions: {
|
||||||
|
tag: ':::',
|
||||||
|
keywords: ['note', 'tip', 'info', 'caution', 'danger'],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
The plugin accepts two options:
|
||||||
|
|
||||||
|
- `tag`: The tag that encloses the admonition. Defaults to `:::`.
|
||||||
|
- `keywords`: An array of keywords that can be used as the type for the admonition. Note that if you override this, the default values will not be applied.
|
||||||
|
|
||||||
|
The `keyword` will be passed as the `type` prop of the `Admonition` component. If you register more types than the default, you are also responsible for providing their implementation—including the container's style, icon, default title text, etc. You would usually need to [eject](../../swizzling.md#ejecting) the `@theme/Admonition` component, so you could re-use the same infrastructure as the other types.
|
|
@ -25,7 +25,7 @@ If you play with the [MDX playground](https://mdx-git-renovate-babel-monorepo-md
|
||||||
|
|
||||||
:::tip
|
:::tip
|
||||||
|
|
||||||
Use plugins to introduce shorter syntax for the most commonly used JSX elements in your project. The [admonition](./markdown-features-admonitions.mdx) syntax that we offer is also generated by a [Remark plugin](https://github.com/elviswolcott/remark-admonitions), and you could do the same for your own use case.
|
Use plugins to introduce shorter syntax for the most commonly used JSX elements in your project. The [admonition](./markdown-features-admonitions.mdx) syntax that we offer is also generated by a Remark plugin, and you could do the same for your own use case.
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
|
@ -65,11 +65,9 @@ import LiteYouTubeEmbed from 'react-lite-youtube-embed';
|
||||||
</div>
|
</div>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Disclaimer {#disclaimer}
|
## Migrating from v1 {#migrating-from-v1}
|
||||||
|
|
||||||
Docusaurus v2 is **beta** but already quite stable and widely used.
|
Docusaurus v2 has been a total rewrite from Docusaurus v1, taking advantage of a completely modernized toolchain. After [v2's official release](https://docusaurus.io/blog/2022/08/01/announcing-docusaurus-2.0), we highly encourage you to **use Docusaurus v2 over Docusaurus v1**, as Docusaurus v1 has been deprecated.
|
||||||
|
|
||||||
We highly encourage you to **use Docusaurus v2 over Docusaurus v1**, as Docusaurus v1 will be deprecated soon.
|
|
||||||
|
|
||||||
A [lot of users](/showcase) are already using Docusaurus v2 ([trends](https://www.npmtrends.com/docusaurus-vs-@docusaurus/core)).
|
A [lot of users](/showcase) are already using Docusaurus v2 ([trends](https://www.npmtrends.com/docusaurus-vs-@docusaurus/core)).
|
||||||
|
|
||||||
|
@ -83,7 +81,9 @@ A [lot of users](/showcase) are already using Docusaurus v2 ([trends](https://ww
|
||||||
**Use [Docusaurus v1](https://v1.docusaurus.io/) if:**
|
**Use [Docusaurus v1](https://v1.docusaurus.io/) if:**
|
||||||
|
|
||||||
- :x: You don't want a single-page application (SPA)
|
- :x: You don't want a single-page application (SPA)
|
||||||
- :x: You need support for IE11
|
- :x: You need support for IE11 (...do you? IE [has already reached end-of-life](https://docs.microsoft.com/en-us/lifecycle/products/internet-explorer-11) and is no longer officially supported)
|
||||||
|
|
||||||
|
For existing v1 users that are seeking to upgrade to v2, you can follow our [migration guide](./migration/migration-overview.md).
|
||||||
|
|
||||||
## Features {#features}
|
## Features {#features}
|
||||||
|
|
|
@ -124,7 +124,11 @@ Read more about the robots file in [the Google documentation](https://developers
|
||||||
|
|
||||||
:::caution
|
:::caution
|
||||||
|
|
||||||
**Important**: the `robots.txt` file does **not** prevent HTML pages from being indexed. Use `<meta name="robots" content="noindex">` as [page metadata](#single-page-metadata) to prevent it from appearing in search results entirely.
|
**Important**: the `robots.txt` file does **not** prevent HTML pages from being indexed.
|
||||||
|
|
||||||
|
To prevent your whole Docusaurus site from being indexed, use the [`noIndex`](./api/docusaurus.config.js.md#noIndex) site config. Some [hosting providers](./deployment.mdx) may also let you configure a `X-Robots-Tag: noindex` HTTP header (GitHub Pages does not support this).
|
||||||
|
|
||||||
|
To prevent a single page from being indexed, use `<meta name="robots" content="noindex">` as [page metadata](#single-page-metadata). Read more about the [robots meta tag](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag).
|
||||||
|
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
@ -132,6 +136,20 @@ Read more about the robots file in [the Google documentation](https://developers
|
||||||
|
|
||||||
Docusaurus provides the [`@docusaurus/plugin-sitemap`](./api/plugins/plugin-sitemap.md) plugin, which is shipped with `preset-classic` by default. It autogenerates a `sitemap.xml` file which will be available at `https://example.com/[baseUrl]/sitemap.xml` after the production build. This sitemap metadata helps search engine crawlers crawl your site more accurately.
|
Docusaurus provides the [`@docusaurus/plugin-sitemap`](./api/plugins/plugin-sitemap.md) plugin, which is shipped with `preset-classic` by default. It autogenerates a `sitemap.xml` file which will be available at `https://example.com/[baseUrl]/sitemap.xml` after the production build. This sitemap metadata helps search engine crawlers crawl your site more accurately.
|
||||||
|
|
||||||
|
:::tip
|
||||||
|
|
||||||
|
The sitemap plugin automatically filters pages containing a `noindex` [robots meta directive](https://developers.google.com/search/docs/advanced/robots/robots_meta_tag).
|
||||||
|
|
||||||
|
For example, [`/examples/noIndex`](/examples/noIndex) is not included in the [Docusaurus sitemap.xml file](pathname:///sitemap.xml) because it contains the following [page metadata](#single-page-metadata):
|
||||||
|
|
||||||
|
```html
|
||||||
|
<head>
|
||||||
|
<meta name="robots" content="noindex, nofollow" />
|
||||||
|
</head>
|
||||||
|
```
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
## Human readable links {#human-readable-links}
|
## Human readable links {#human-readable-links}
|
||||||
|
|
||||||
Docusaurus uses your file names as links, but you can always change that using slugs, see this [tutorial](./guides/docs/docs-introduction.md#document-id) for more details.
|
Docusaurus uses your file names as links, but you can always change that using slugs, see this [tutorial](./guides/docs/docs-introduction.md#document-id) for more details.
|
|
@ -180,26 +180,6 @@ module.exports = {
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
In addition to these plugins and themes, `@docusaurus/theme-classic` adds [`remark-admonitions`](https://github.com/elviswolcott/remark-admonitions) as a remark plugin to `@docusaurus/plugin-content-blog` and `@docusaurus/plugin-content-docs`.
|
|
||||||
|
|
||||||
The `admonitions` key will be passed as the [options](https://github.com/elviswolcott/remark-admonitions#options) to `remark-admonitions`. Passing `false` will prevent the plugin from being added to MDX.
|
|
||||||
|
|
||||||
```js title="docusaurus.config.js"
|
|
||||||
module.exports = {
|
|
||||||
presets: [
|
|
||||||
[
|
|
||||||
'@docusaurus/preset-classic',
|
|
||||||
{
|
|
||||||
docs: {
|
|
||||||
// options for remark-admonitions
|
|
||||||
admonitions: {},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
],
|
|
||||||
],
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### Installing presets {#installing-presets}
|
### Installing presets {#installing-presets}
|
||||||
|
|
||||||
A preset is usually an npm package, so you install them like other npm packages using npm.
|
A preset is usually an npm package, so you install them like other npm packages using npm.
|
|
@ -1,4 +1,4 @@
|
||||||
[
|
[
|
||||||
"2.0.1",
|
"2.1.0",
|
||||||
"2.0.0-rc.1"
|
"2.0.1"
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"2.0.0-rc.1": "https://6310933e91a4590008bcd3ee--docusaurus-2.netlify.app/docs/2.0.0-rc.1",
|
||||||
"2.0.0-beta.22": "https://62e6a82f2c09f60009c53522--docusaurus-2.netlify.app/docs/2.0.0-beta.22",
|
"2.0.0-beta.22": "https://62e6a82f2c09f60009c53522--docusaurus-2.netlify.app/docs/2.0.0-beta.22",
|
||||||
"2.0.0-beta.21": "https://62d02ff810c1170009a4fa0c--docusaurus-2.netlify.app/docs/2.0.0-beta.21",
|
"2.0.0-beta.21": "https://62d02ff810c1170009a4fa0c--docusaurus-2.netlify.app/docs/2.0.0-beta.21",
|
||||||
"2.0.0-beta.20": "https://62c814ff3641af00082fe735--docusaurus-2.netlify.app/docs/2.0.0-beta.20",
|
"2.0.0-beta.20": "https://62c814ff3641af00082fe735--docusaurus-2.netlify.app/docs/2.0.0-beta.20",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue