mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-24 22:46:57 +02:00
misc: add command to run prettier on docs (#2102)
* misc: add command to run prettier on docs * Fix GH issue template * Fix tests * Add prettier-docs command to precommit
This commit is contained in:
parent
cfc313d7c7
commit
55e676cb25
141 changed files with 1181 additions and 968 deletions
|
@ -42,7 +42,10 @@ List the installed [themes](using-themes.md), [plugins](using-plugins.md), and [
|
|||
// docusaurus.config.js
|
||||
module.exports = {
|
||||
// ...
|
||||
plugins: ['@docusaurus/plugin-content-blog', '@docusaurus/plugin-content-pages'],
|
||||
plugins: [
|
||||
'@docusaurus/plugin-content-blog',
|
||||
'@docusaurus/plugin-content-pages',
|
||||
],
|
||||
themes: ['@docusaurus/theme-classic'],
|
||||
};
|
||||
```
|
||||
|
|
|
@ -87,11 +87,13 @@ There are two more optional parameters that are set as environment variables:
|
|||
Finally, to deploy your site to GitHub Pages, run:
|
||||
|
||||
**Bash**
|
||||
|
||||
```bash
|
||||
GIT_USER=<GITHUB_USERNAME> yarn deploy
|
||||
```
|
||||
|
||||
**Windows**
|
||||
|
||||
```batch
|
||||
cmd /C "set GIT_USER=<GITHUB_USERNAME> && yarn deploy"
|
||||
```
|
||||
|
|
|
@ -272,7 +272,8 @@ module.exports = {
|
|||
'https://docusaurus.io/script.js',
|
||||
// Object format.
|
||||
{
|
||||
src: 'https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js',
|
||||
src:
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js',
|
||||
async: true,
|
||||
},
|
||||
],
|
||||
|
@ -294,7 +295,7 @@ module.exports = {
|
|||
// String format.
|
||||
'https://docusaurus.io/style.css',
|
||||
// Object format.
|
||||
{
|
||||
{
|
||||
href: 'http://mydomain.com/style.css',
|
||||
type: 'text/css',
|
||||
},
|
||||
|
|
|
@ -24,7 +24,6 @@ Example:
|
|||
npx @docusaurus/init@next init my-website classic
|
||||
```
|
||||
|
||||
|
||||
If you do not specify `name` or `template`, it will prompt you for them. We recommend the `classic` template so that you can get started quickly and it contains features found in Docusaurus 1. The `classic` template contains `@docusaurus/preset-classic` which includes standard documentation, a blog, custom pages, and a CSS framework (with dark mode support). You can get up and running extremely quickly with the classic template and customize things later on when you have gained more familiarity with Docusaurus.
|
||||
|
||||
## Project structure
|
||||
|
|
|
@ -59,7 +59,7 @@ Our shared goal — to help your users find what they need fast, and understand
|
|||
- Share your code in live editors to get your users love your products on the spot
|
||||
- 🔍 **Search** Your full site is searchable
|
||||
- 🌍 **i18n** (_coming soon_)
|
||||
- 💾 **Document Versioning** Helps you keep documentation in sync with project releases.
|
||||
- 💾 **Document Versioning** Helps you keep documentation in sync with project releases.
|
||||
|
||||
Docusaurus 2 is born to be compassionately accessible to all your users, and lightning fast.
|
||||
|
||||
|
|
|
@ -514,17 +514,21 @@ For any questions, you can ask in the [`#docusaurus-1-to-2-migration` Discord ch
|
|||
> ⚠️ Although we've implemented docs versioning since 2.0.0-alpha.37, we'd like to test it out for v2 users first before we recommend v1 users to migrate to v2. There are some changes in how v2 versioning works compared to v1. In the future, we might create a script to migrate your versioned docs easier. However, if you are adventurous enough to manually migrate, feel free to do so. Be warned though, the manual migration requires lot of work.
|
||||
|
||||
## Changes from v1
|
||||
|
||||
- Read up https://v2.docusaurus.io/blog/2018/09/11/Towards-Docusaurus-2#versioning first for reasoning on v1's problem
|
||||
|
||||
### Migrate your versioned_docs frontmatter
|
||||
|
||||
- Unlike v1, The markdown header for each versioned doc is no longer altered by using `version-${version}-${original_id}` as the value for the actual id field. See scenario below for better explanation.
|
||||
|
||||
Example, you have a `docs/hello.md`.
|
||||
Example, you have a `docs/hello.md`.
|
||||
|
||||
```md
|
||||
---
|
||||
id: hello
|
||||
title: Hello, World !
|
||||
---
|
||||
|
||||
Hi, Endilie here :)
|
||||
```
|
||||
|
||||
|
@ -538,6 +542,7 @@ id: version-1.0.0-hello
|
|||
title: Hello, World !
|
||||
original_id: hello
|
||||
---
|
||||
|
||||
Hi, Endilie here :)
|
||||
```
|
||||
|
||||
|
@ -548,6 +553,7 @@ In comparison, Docusaurus 2 `website/versioned_docs/version-1.0.0/hello.md` look
|
|||
id: hello
|
||||
title: Hello, World !
|
||||
---
|
||||
|
||||
Hi, Endilie here :)
|
||||
```
|
||||
|
||||
|
@ -565,22 +571,23 @@ title: Hello, World !
|
|||
Hi, Endilie here :)
|
||||
```
|
||||
|
||||
|
||||
### Migrate your versioned_sidebars
|
||||
|
||||
- Refer to versioned_docs id as `version-${version}/${id}` (v2) instead of `version-${version}-${original_id}` (v1).
|
||||
- Refer to versioned_docs id as `version-${version}/${id}` (v2) instead of `version-${version}-${original_id}` (v1).
|
||||
|
||||
Because in v1 there is a good chance someone created a new file with front matter id `"version-${version}-${id}"` that can conflict with versioned_docs id.
|
||||
|
||||
Example, Docusaurus 1 can't differentiate `docs/xxx.md`
|
||||
|
||||
```md
|
||||
---
|
||||
id: version-1.0.0-hello
|
||||
---
|
||||
|
||||
Another content
|
||||
```
|
||||
|
||||
and `website/versioned_docs/version-1.0.0/hello.md`
|
||||
and `website/versioned_docs/version-1.0.0/hello.md`
|
||||
|
||||
```md
|
||||
---
|
||||
|
@ -588,6 +595,7 @@ id: version-1.0.0-hello
|
|||
title: Hello, World !
|
||||
original_id: hello
|
||||
---
|
||||
|
||||
Hi, Endilie here :)
|
||||
```
|
||||
|
||||
|
@ -596,6 +604,7 @@ Since we don't allow `/` in v1 & v2 for frontmatter, conflicts are less likely t
|
|||
So v1 users need to migrate their versioned_sidebars file
|
||||
|
||||
Example `versioned_sidebars/version-1.0.0-sidebars.json`:
|
||||
|
||||
```json {2-3,5-6,9-10}
|
||||
{
|
||||
+ "version-1.0.0/docs": {
|
||||
|
@ -617,12 +626,10 @@ Example `versioned_sidebars/version-1.0.0-sidebars.json`:
|
|||
In v2, we use snapshot approach on documentation versioning. **Every versioned docs does not depends on other version**. It is possible to have `foo.md` in `version-1.0.0` but it doesn't exist in `version-1.2.0`. This is not possible in previous version due to Docusaurus v1 fallback functionality (https://docusaurus.io/docs/en/versioning#fallback-functionality).
|
||||
|
||||
For example, if your `versions.json` looks like this in v1
|
||||
|
||||
```json
|
||||
// versions.json
|
||||
[
|
||||
"1.1.0",
|
||||
"1.0.0"
|
||||
]
|
||||
["1.1.0", "1.0.0"]
|
||||
```
|
||||
|
||||
Docusaurus v1 creates versioned docs **if and only if the doc content is different**. Your docs structure might look like this if the only doc changed from v1.0.0 to v1.1.0 is `hello.md`.
|
||||
|
@ -656,4 +663,4 @@ website
|
|||
├── versioned_sidebars
|
||||
│ ├── version-1.1.0-sidebars.json
|
||||
│ └── version-1.0.0-sidebars.json
|
||||
```
|
||||
```
|
||||
|
|
|
@ -30,15 +30,16 @@ A sidebar object is defined like this.
|
|||
|
||||
```typescript
|
||||
type Sidebar = {
|
||||
[sidebarId: string]: {
|
||||
[sidebarCategory: string]: SidebarItem[];
|
||||
} | SidebarItem[];
|
||||
}
|
||||
[sidebarId: string]:
|
||||
| {
|
||||
[sidebarCategory: string]: SidebarItem[];
|
||||
}
|
||||
| SidebarItem[];
|
||||
};
|
||||
```
|
||||
|
||||
Below is an example of a sidebar object. The key `docs` is the id of the sidebar (can be renamed to something else) and `Getting Started` is a category within the sidebar. `greeting` and `doc1` are both [sidebar item](#sidebar-item).
|
||||
|
||||
|
||||
```js
|
||||
// sidebars.js
|
||||
module.exports = {
|
||||
|
@ -121,10 +122,12 @@ As the name implies, `SidebarItem` is an item defined in a Sidebar. There are a
|
|||
### Doc
|
||||
|
||||
```typescript
|
||||
type SidebarItemDoc = string | {
|
||||
type: 'doc';
|
||||
id: string;
|
||||
};
|
||||
type SidebarItemDoc =
|
||||
| string
|
||||
| {
|
||||
type: 'doc';
|
||||
id: string;
|
||||
};
|
||||
```
|
||||
|
||||
Sidebar item type that links to a doc page. Example:
|
||||
|
@ -204,7 +207,7 @@ type SidebarItemCategory = {
|
|||
type: 'category';
|
||||
label: string; // Sidebar label text.
|
||||
items: SidebarItem[]; // Array of sidebar items.
|
||||
}
|
||||
};
|
||||
```
|
||||
|
||||
As an example, here's how we created the subcategory for "Docs" under "Guides" in this site:
|
||||
|
|
|
@ -193,7 +193,7 @@ module.exports = {
|
|||
|
||||
### `@docusaurus/plugin-content-docs`
|
||||
|
||||
Provides the [Docs](markdown-features.mdx) functionality and is the default docs plugin for Docusaurus.
|
||||
Provides the [Docs](markdown-features.mdx) functionality and is the default docs plugin for Docusaurus.
|
||||
|
||||
**Installation**
|
||||
|
||||
|
@ -407,10 +407,9 @@ import thumbnail from './path/to/img.png';
|
|||
| Option | Type | Default | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| `name` | `string` | `ideal-img/[name].[hash:hex:7].[width].[ext]` | Filename template for output files. |
|
||||
| `sizes` | `array` | _original size_ | Specify all widths you want to use. If a specified size exceeds the original image's width, the latter will be used (i.e. images won't be scaled up).|
|
||||
| `sizes` | `array` | _original size_ | Specify all widths you want to use. If a specified size exceeds the original image's width, the latter will be used (i.e. images won't be scaled up). |
|
||||
| `size` | `integer` | _original size_ | Specify one width you want to use; if the specified size exceeds the original image's width, the latter will be used (i.e. images won't be scaled up) |
|
||||
| `min` | `integer` | | As an alternative to manually specifying `sizes`, you can specify `min`, `max` and `steps`, and the sizes will be generated for you. |
|
||||
| `max` | `integer` | | See `min` above |
|
||||
| `steps` | `integer` | `4` | Configure the number of images generated between `min` and `max` (inclusive) |
|
||||
| `quality` | `integer` | `85` | JPEG compression quality |
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue