Skip to content

Commit

Permalink
add beta 22, remove beta 20
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber committed Jul 8, 2022
1 parent 0ffa68a commit 252075f
Show file tree
Hide file tree
Showing 94 changed files with 1,073 additions and 555 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ When writing links in Markdown, you could either mean a _file path_, or a _URL p
- If the path has an `.md(x)` extension, Docusaurus would try to resolve that Markdown file to a URL, and replace the file path with a URL path.
- If the path has any other extension, Docusaurus would treat it as [an asset](../guides/markdown-features/markdown-features-assets.mdx) and bundle it.

The following directory structure may help you visualize this file -> URL mapping. Assume that there's no slug customization in any page.
The following directory structure may help you visualize this file URL mapping. Assume that there's no slug customization in any page.

<details>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ description: Docusaurus statically renders your React code into HTML, allowing f
In [architecture](architecture.md), we mentioned that the theme is run in Webpack. But beware: that doesn't mean it always has access to browser globals! The theme is built twice:

- During **server-side rendering**, the theme is compiled in a sandbox called [React DOM Server](https://reactjs.org/docs/react-dom-server.html). You can see this as a "headless browser", where there is no `window` or `document`, only React. SSR produces static HTML pages.
- During **client-side rendering**, the theme is compiled with standard React DOM, and has access to browser variables. CSR produces dynamic JavaScript.
- During **client-side rendering**, the theme is compiled to JavaScript that gets eventually executed in the browser, so it has access to browser variables.

:::info SSR or SSG?

_Server-side rendering_ and _static site generation_ can be different concepts, but we use them interchangeably.

Strictly speaking, Docusaurus is a static site generator, because there's no server-side runtime—we statically render to HTML files that are deployed on a CDN, instead of dynamically pre-rendering on each request. This differs from the working model of [Next.js](https://nextjs.org/).

:::

Therefore, while you probably know not to access Node globals like `process` ([or can we?](#node-env)) or the `'fs'` module, you can't freely access browser globals either.
Expand All @@ -34,9 +36,10 @@ ReferenceError: window is not defined

This is because during server-side rendering, the Docusaurus app isn't actually run in browser, and it doesn't know what `window` is.

```mdx-code-block
<details id="node-env">

<summary>What about <code>process.env.NODE_ENV</code>?</summary>
```

One exception to the "no Node globals" rule is `process.env.NODE_ENV`. In fact, you can use it in React, because Webpack injects this variable as a global:

Expand All @@ -56,8 +59,10 @@ During Webpack build, the `process.env.NODE_ENV` will be replaced with the value

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem';

```mdx-code-block
<Tabs>
<TabItem value="Development">
```

```diff
import React from 'react';
Expand All @@ -72,8 +77,10 @@ export default function expensiveComp() {
}
```

```mdx-code-block
</TabItem>
<TabItem value="Production">
```

```diff
import React from 'react';
Expand All @@ -88,9 +95,11 @@ export default function expensiveComp() {
}
```

```mdx-code-block
</TabItem>
</Tabs>
</details>
```

## Understanding SSR {#understanding-ssr}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
---
sidebar_position: 0
id: docusaurus.config.js
description: API reference for Docusaurus configuration file.
slug: /api/docusaurus-config
---
Expand Down Expand Up @@ -64,7 +63,7 @@ module.exports = {

- Type: `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. This field is related to the [baseUrl](#baseurl) field.
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. This field is related to the [`baseUrl`](#baseUrl) field.

```js title="docusaurus.config.js"
module.exports = {
Expand All @@ -76,7 +75,7 @@ module.exports = {

- Type: `string`

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.
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 = {
Expand Down Expand Up @@ -130,19 +129,22 @@ Example:
module.exports = {
i18n: {
defaultLocale: 'en',
locales: ['en', 'fr'],
locales: ['en', 'fa'],
path: 'i18n',
localeConfigs: {
en: {
label: 'English',
direction: 'ltr',
htmlLang: 'en-US',
calendar: 'gregory',
path: 'en',
},
fa: {
label: 'فارسی',
direction: 'rtl',
htmlLang: 'fa-IR',
calendar: 'persian',
path: 'fa',
},
},
},
Expand All @@ -151,11 +153,13 @@ module.exports = {

- `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`.
- `path`: Root folder which all locale folders are relative to. Can be absolute or relative to the config file. Defaults to `i18n`.
- `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.
- `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="...">`
- `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.

### `noIndex` {#noIndex}

Expand All @@ -173,7 +177,7 @@ module.exports = {

### `onBrokenLinks` {#onBrokenLinks}

- Type: `'ignore' | 'log' | 'warn' | 'error' | 'throw'`
- Type: `'ignore' | 'log' | 'warn' | 'throw'`

The behavior of Docusaurus when it detects any broken link.

Expand All @@ -187,15 +191,15 @@ The broken links detection is only available for a production build (`docusaurus

### `onBrokenMarkdownLinks` {#onBrokenMarkdownLinks}

- Type: `'ignore' | 'log' | 'warn' | 'error' | 'throw'`
- Type: `'ignore' | 'log' | 'warn' | '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.
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}

- Type: `'ignore' | 'log' | 'warn' | 'error' | 'throw'`
- Type: `'ignore' | 'log' | 'warn' | 'throw'`

The behavior of Docusaurus when it detects any [duplicate routes](/guides/creating-pages.md#duplicate-routes).

Expand Down Expand Up @@ -330,8 +334,9 @@ module.exports = {
// ... other links
],
logo: {
alt: 'Facebook Open Source Logo',
src: 'https://docusaurus.io/img/oss_logo.png',
alt: 'Meta Open Source Logo',
src: 'img/meta_oss_logo.png',
href: 'https://opensource.fb.com',
width: 160,
height: 51,
},
Expand Down Expand Up @@ -426,7 +431,7 @@ module.exports = {

### `scripts` {#scripts}

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>`.
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>`. If you use a plain object, the only required attribute is `src`, and any other attributes are permitted (each one should have boolean/string values).

Note that `<script>` added here are render-blocking, so you might want to add `async: true`/`defer: true` to the objects.

Expand All @@ -450,7 +455,7 @@ 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>`.
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>`. If you use an object, the only required attribute is `href`, and any other attributes are permitted (each one should have boolean/string values).

- Type: `(string | Object)[]`

Expand All @@ -469,6 +474,12 @@ module.exports = {
};
```

:::info

By default, the `<link>` tags will have `rel="stylesheet"`, but you can explicitly add a custom `rel` value to inject any kind of `<link>` tag, not necessarily stylesheets.

:::

### `clientModules` {#clientModules}

An array of [client modules](../advanced/client.md#client-modules) to load globally on your site.
Expand Down Expand Up @@ -542,7 +553,7 @@ module.exports = {
};
```

### `baseUrlIssueBanner` {#baseurlIssueBanner}
### `baseUrlIssueBanner` {#baseUrlIssueBanner}

- Type: `boolean`

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
sidebar_position: 0
title: '📦 create-docusaurus'
slug: '/api/misc/create-docusaurus'
slug: /api/misc/create-docusaurus
---

# 📦 create-docusaurus

A scaffolding utility to help you instantly set up a functional Docusaurus app.

## Usage {#usage}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
sidebar_position: 1
id: eslint-plugin
title: '📦 eslint-plugin'
slug: '/api/misc/@docusaurus/eslint-plugin'
slug: /api/misc/@docusaurus/eslint-plugin
---

# 📦 eslint-plugin

[ESLint](https://eslint.org/) is a tool that statically analyzes your code and reports problems or suggests best practices through editor hints and command line. Docusaurus provides an ESLint plugin to enforce best Docusaurus practices.

## Installation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
slug: '/api/misc/@docusaurus/eslint-plugin/no-untranslated-text'
slug: /api/misc/@docusaurus/eslint-plugin/no-untranslated-text
---

# no-untranslated-text
Expand Down Expand Up @@ -32,13 +32,17 @@ Examples of **correct** code for this rule:

Accepted fields:

```mdx-code-block
<APITable>
```

| Option | Type | Default | Description |
| --- | --- | --- | --- |
| `ignoredStrings` | `string[]` | `[]` | Text labels that only contain strings in this list will not be reported. |

```mdx-code-block
</APITable>
```

## When Not To Use It {#when-not-to-use}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
slug: '/api/misc/@docusaurus/eslint-plugin/string-literal-i18n-messages'
slug: /api/misc/@docusaurus/eslint-plugin/string-literal-i18n-messages
---

# string-literal-i18n-messages
Expand Down
Loading

0 comments on commit 252075f

Please sign in to comment.