mirror of
https://github.com/facebook/docusaurus.git
synced 2025-04-29 10:17:55 +02:00
v1.3.3 (#912)
* v1.3.3 * nits changelog * run npm update & yarn update * run prettier
This commit is contained in:
parent
6004fef658
commit
2fa67bbc13
13 changed files with 4081 additions and 3051 deletions
19
CHANGELOG.md
19
CHANGELOG.md
|
@ -6,19 +6,26 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
Welcome to our newest user, [atalaya](https://atalaya.io/), [Reaction Commerce](https://docs.reactioncommerce.com/) and [nteract](https://docs.nteract.io/).
|
||||
## [1.3.3] - 2018-08-22
|
||||
|
||||
Welcome to our newest users, [atalaya](https://atalaya.io/), [Reaction Commerce](https://docs.reactioncommerce.com/), [Plus (ThinkSNS+)](https://slimkit.github.io) and [nteract](https://docs.nteract.io/).
|
||||
|
||||
Thank you to the following contributors who helped with this release:
|
||||
|
||||
- @endiliey
|
||||
- @joelmarcey
|
||||
- @yangshun
|
||||
- @apuravchauhan
|
||||
- @dballance
|
||||
- @helloworld
|
||||
- @jreese
|
||||
- @machikoyasuda
|
||||
- @medz
|
||||
- @mikalai-silivonik
|
||||
- @miralemd
|
||||
- @monkeywithacupcake
|
||||
- @parano
|
||||
- @patapizza
|
||||
- @shaform
|
||||
- @steevehook
|
||||
- @theletterf
|
||||
|
@ -37,12 +44,16 @@ Thank you to the following contributors who helped with this release:
|
|||
- Fix failure to copy static image if image compression fail [\#887](https://github.com/facebook/Docusaurus/pull/887)
|
||||
- Fix: correct docs linking for custom `defaultVersionShown` [\#894](https://github.com/facebook/Docusaurus/pull/894)
|
||||
- Fix incorrect sitemap url for non default baseUrl [\#902](https://github.com/facebook/Docusaurus/pull/902)
|
||||
- Stricter `css/main.css` routing on development server [\#904](https://github.com/facebook/Docusaurus/pull/904)
|
||||
- Fix console error when onPageNav !== 'separate' [\#909](https://github.com/facebook/Docusaurus/pull/909)
|
||||
|
||||
**Docs**
|
||||
- Add documentation regarding usage of nested docs/ subdirectory [\#860](https://github.com/facebook/Docusaurus/pull/860)
|
||||
- Improve baseUrl documentation with an example [\#863](https://github.com/facebook/Docusaurus/pull/863)
|
||||
- Fix Table of contents documentation typo [\#873](https://github.com/facebook/Docusaurus/pull/873)
|
||||
- Update installation doc [\#888](https://github.com/facebook/Docusaurus/pull/888)
|
||||
- Update installation doc [\#888](https://github.com/facebook/Docusaurus/pull/888) [\#900](https://github.com/facebook/Docusaurus/pull/900)
|
||||
- Update guides-translations.md for CircleCI 2.0 [92f95d](https://github.com/facebook/Docusaurus/commit/92f95df934ab4034c49d66cd82ad5dbbcdee508d)
|
||||
|
||||
|
||||
**Chore and Maintenance**
|
||||
- Add ESLint [\#836](https://github.com/facebook/Docusaurus/pull/836) [\#837](https://github.com/facebook/Docusaurus/pull/837) [\#841](https://github.com/facebook/Docusaurus/pull/841) [\#846](https://github.com/facebook/Docusaurus/pull/846)
|
||||
|
@ -51,10 +62,12 @@ Thank you to the following contributors who helped with this release:
|
|||
- Improve readme [\#866](https://github.com/facebook/Docusaurus/pull/866)
|
||||
- Add prerelease script for Docusaurus [\#876](https://github.com/facebook/Docusaurus/pull/876)
|
||||
- Remove unused files [\#881](https://github.com/facebook/Docusaurus/pull/881)
|
||||
- Update [code of conduct](https://github.com/facebook/Docusaurus/commit/3c1363da1bd445029d7034b0575f69a7077321c3)
|
||||
- Update code of conduct [3c1363d](https://github.com/facebook/Docusaurus/commit/3c1363da1bd445029d7034b0575f69a7077321c3)
|
||||
- Update jest to v23 [\#885](https://github.com/facebook/Docusaurus/pull/885)
|
||||
- Activating Open Collective [\#883](https://github.com/facebook/Docusaurus/pull/883)
|
||||
- Fix Jest tests that fail on Windows [\#896](https://github.com/facebook/Docusaurus/pull/896)
|
||||
- Rename Sonar to Flipper [\#905](https://github.com/facebook/Docusaurus/pull/905)
|
||||
|
||||
|
||||
## [1.3.2] - 2018-07-06
|
||||
|
||||
|
|
|
@ -159,16 +159,13 @@ function execute() {
|
|||
// Manually add 'Help Translate' to en.json
|
||||
translations['pages-strings'][
|
||||
'Help Translate|recruit community translators for your project'
|
||||
] =
|
||||
'Help Translate';
|
||||
] = 'Help Translate';
|
||||
translations['pages-strings'][
|
||||
'Edit this Doc|recruitment message asking to edit the doc source'
|
||||
] =
|
||||
'Edit';
|
||||
] = 'Edit';
|
||||
translations['pages-strings'][
|
||||
'Translate this Doc|recruitment message asking to translate the docs'
|
||||
] =
|
||||
'Translate';
|
||||
] = 'Translate';
|
||||
translations['pages-strings'] = Object.assign(
|
||||
translations['pages-strings'],
|
||||
customTranslations['pages-strings']
|
||||
|
|
5381
package-lock.json
generated
5381
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "docusaurus",
|
||||
"description": "Easy to Maintain Open Source Documentation Websites",
|
||||
"version": "1.3.2",
|
||||
"version": "1.3.3",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"documentation",
|
||||
|
@ -55,7 +55,7 @@
|
|||
"docusaurus-rename-version": "./lib/rename-version.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"autoprefixer": "^9.0.0",
|
||||
"autoprefixer": "^9.1.3",
|
||||
"babel-plugin-transform-class-properties": "^6.24.1",
|
||||
"babel-plugin-transform-object-rest-spread": "^6.26.0",
|
||||
"babel-polyfill": "^6.26.0",
|
||||
|
|
|
@ -42,7 +42,8 @@ class Users extends React.Component {
|
|||
Docusaurus powers some of Facebook's popular{' '}
|
||||
<a href="https://code.facebook.com/projects/">
|
||||
open source projects
|
||||
</a>.
|
||||
</a>
|
||||
.
|
||||
</p>
|
||||
</div>
|
||||
<div className="logos">{fbShowcase}</div>
|
||||
|
|
209
website/versioned_docs/version-1.3.3/api-doc-markdown.md
Normal file
209
website/versioned_docs/version-1.3.3/api-doc-markdown.md
Normal file
|
@ -0,0 +1,209 @@
|
|||
---
|
||||
id: version-1.3.3-doc-markdown
|
||||
title: Markdown Features
|
||||
original_id: doc-markdown
|
||||
---
|
||||
|
||||
Find out more about Docusaurus-specific fields when writing Markdown.
|
||||
|
||||
## Markdown Headers
|
||||
|
||||
### Documents
|
||||
|
||||
Documents use the following markdown header fields that are enclosed by a line `---` on either side:
|
||||
|
||||
`id`: A unique document id. If this field is not present, the document's `id` will default to its file name (without the extension).
|
||||
|
||||
`title`: The title of your document. If this field is not present, the document's `title` will default to its `id`.
|
||||
|
||||
`hide_title`: Whether to hide the title at the top of the doc.
|
||||
|
||||
`sidebar_label`: The text shown in the document sidebar for this document. If this field is not present, the document's `sidebar_label` will default to its `title`.
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
---
|
||||
id: doc1
|
||||
title: My Document
|
||||
sidebar_label: Document
|
||||
---
|
||||
```
|
||||
|
||||
Versioned documents have their ids altered to include the version number when they get copied. The new `id` is `version-${version}-${id}` where `${version}` is the version number of that document and `${id}` is the original `id`. Additionally, versioned documents get an added `original_id` field with the original document id.
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
---
|
||||
id: version-1.0.0-doc1
|
||||
title: My Document
|
||||
sidebar_label: Document
|
||||
original_id: doc1
|
||||
---
|
||||
```
|
||||
|
||||
`custom_edit_url`: The URL for editing this document. If this field is not present, the document's edit URL will fall back to `editUrl` from optional fields of `siteConfig.js`. See [siteConfig.js](site-config.md) docs for more information.
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
---
|
||||
id: doc-markdown
|
||||
title: Markdown Features
|
||||
custom_edit_url: https://github.com/facebook/Docusaurus/edit/master/docs/api-doc-markdown.md
|
||||
---
|
||||
```
|
||||
|
||||
### Blog Posts
|
||||
|
||||
Blog posts use the following markdown header fields that are enclosed by a line `---` on either side:
|
||||
|
||||
`title`: The title of this blog post.
|
||||
|
||||
`author`: The author of this blog post. If this field is omitted, no author name will be shown.
|
||||
|
||||
`authorURL`: A page to link to when a site user clicks the author's name. If this field is omitted, the author's name will not link to anything.
|
||||
|
||||
`authorFBID`: The author's Facebook id, used only to get the author's profile picture to display with the blog post. If this field is omitted, no author picture will be shown for the blog post.
|
||||
|
||||
For example:
|
||||
|
||||
```yaml
|
||||
---
|
||||
title: My First Blog Post
|
||||
author: Frank Li
|
||||
authorURL: http://twitter.com/franchementli
|
||||
authorFBID: 100002976521003
|
||||
---
|
||||
```
|
||||
|
||||
## Extra Features
|
||||
|
||||
Docusaurus supports some extra features when writing documentation in markdown.
|
||||
|
||||
### Linking other Documents
|
||||
|
||||
You can use relative URLs to other documentation files which will automatically get converted to the corresponding HTML links when they get rendered.
|
||||
|
||||
Example:
|
||||
|
||||
```md
|
||||
[This links to another document](other-document.md)
|
||||
```
|
||||
|
||||
This markdown will automatically get converted into a link to `/docs/other-document.html` (or the appropriately translated/versioned link) once it gets rendered.
|
||||
|
||||
This can help when you want to navigate through docs on GitHub since the links there will be functional links to other documents (still on GitHub), but the documents will have the correct HTML links when they get rendered.
|
||||
|
||||
### Linking to Images and Other Assets
|
||||
|
||||
Static assets can be linked to in the same way that documents are, using relative URLs. Static assets used in documents and blogs should go into `docs/assets` and `website/blog/assets`, respectively. The markdown will get converted into correct link paths so that these paths will work for documents of all languages and versions.
|
||||
|
||||
Example:
|
||||
|
||||
```md
|
||||

|
||||
```
|
||||
|
||||
### Generating Table of Contents
|
||||
|
||||
You can make an auto-generated list of links, which can be useful as a table of contents for API docs.
|
||||
|
||||
In your markdown file, insert a line with the text `<AUTOGENERATED_TABLE_OF_CONTENTS>`. Write your documentation using `h3` headers for each function inside a code block. These will be found by Docusaurus and a list of links to these sections will inserted at the text `<AUTOGENERATED_TABLE_OF_CONTENTS>`.
|
||||
|
||||
Example:
|
||||
|
||||
```md
|
||||
### `docusaurus.function(a, b)`
|
||||
|
||||
Text describing my function
|
||||
|
||||
### `docdoc(file)`
|
||||
|
||||
Text describing my function
|
||||
```
|
||||
|
||||
will lead to a table of contents of the functions:
|
||||
|
||||
```md
|
||||
- `docusaurus.function(a, b)`
|
||||
- `docdoc(file)`
|
||||
```
|
||||
|
||||
and each function will link to their corresponding sections in the page.
|
||||
|
||||
## Syntax Highlighting
|
||||
|
||||
Syntax highlighting is enabled by default on fenced code blocks. The language should be detected automatically, but you can sometimes get better results by specifying the language. You can do so using an [info string](https://github.github.com/gfm/#example-111), following the three opening backticks. The following JavaScript example...
|
||||
|
||||
```js
|
||||
ReactDOM.render(<h1>Hello, world!</h1>, document.getElementById('root'));
|
||||
```
|
||||
|
||||
...would be rendered with syntax highlighting like so:
|
||||
|
||||
```js
|
||||
ReactDOM.render(<h1>Hello, world!</h1>, document.getElementById('root'));
|
||||
```
|
||||
|
||||
Highlighting is provided by [Highlight.js](https://highlightjs.org) using the theme specified in your `siteConfig.js` file as part of the `highlight` key:
|
||||
|
||||
```js
|
||||
{
|
||||
...
|
||||
highlight: {
|
||||
theme: 'default'
|
||||
}
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
You can find the full list of supported themes in the Highlight.js [`styles`](https://github.com/isagalaev/highlight.js/tree/master/src/styles) directory.
|
||||
|
||||
### Registering additional languages
|
||||
|
||||
While Highlight.js provides support for [many popular languages out of the box](https://highlightjs.org/static/demo/), you may find the need to register additional language support. For these cases, we provide an escape valve by exposing the `hljs` constant as part of the `highlight` config key. This in turn allows you to call [`registerLanguage`](http://highlightjs.readthedocs.io/en/latest/api.html#registerlanguage-name-language):
|
||||
|
||||
```js
|
||||
{
|
||||
...
|
||||
highlight: {
|
||||
theme: 'default',
|
||||
hljs: function(hljs) {
|
||||
hljs.registerLanguage('galacticbasic', function(hljs) {
|
||||
// ...
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Using Prism as additional syntax highlighter
|
||||
|
||||
You can also opt to use Prism to syntax highlight certain languages available in the list [here](https://github.com/PrismJS/prism/tree/master/components). Include those languages in `usePrism` field in your [siteConfig.js](api-site-config.md)
|
||||
|
||||
Example:
|
||||
|
||||
```
|
||||
// siteConfig.js
|
||||
usePrism: ['jsx']
|
||||
```
|
||||
|
||||
Notice that the code block below uses JSX syntax highlighting from Prism.
|
||||
|
||||
```jsx
|
||||
class Example extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<View style={{flex: 1, alignItems: 'center', justifyContent: 'center'}}>
|
||||
<Text>Docusaurus</Text>
|
||||
<Button
|
||||
title="Click me"
|
||||
onPress={() => this.props.navigation.push('Docusaurus')}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
268
website/versioned_docs/version-1.3.3/api-site-config.md
Normal file
268
website/versioned_docs/version-1.3.3/api-site-config.md
Normal file
|
@ -0,0 +1,268 @@
|
|||
---
|
||||
id: version-1.3.3-site-config
|
||||
title: siteConfig.js
|
||||
original_id: site-config
|
||||
---
|
||||
|
||||
A large part of site configuration is done by editing the `siteConfig.js` file.
|
||||
|
||||
## User Showcase
|
||||
|
||||
The `users` array is used to store objects for each project/user that you want to show on your site. Currently this field is used by example the `pages/en/index.js` and `pages/en/users.js` files provided. Each user object should have `caption`, `image`, `infoLink`, and `pinned` fields. The `caption` is the text showed when someone hovers over the `image` of that user, and the `infoLink` is where clicking the image will bring someone. The `pinned` field determines whether or not it shows up on the `index` page.
|
||||
|
||||
Currently this `users` array is used only by the `index.js` and `users.js` example files. If you do not wish to have a users page or show users on the `index` page, you may remove this section.
|
||||
|
||||
## siteConfig Fields
|
||||
|
||||
The `siteConfig` object contains the bulk of the configuration settings for your website.
|
||||
|
||||
### Mandatory Fields
|
||||
|
||||
`baseUrl` - baseUrl for your site. For example, `/pages/org/project/` is the baseUrl of https://git.facebook.com/pages/org/project/
|
||||
|
||||
`colors` - Color configurations for the site.
|
||||
|
||||
* `primaryColor` is the color used the header navigation bar and sidebars.
|
||||
* `secondaryColor` is the color seen in the second row of the header navigation bar when the site window is narrow (including on mobile).
|
||||
* Custom color configurations can also be added. For example, if user styles are added with colors specified as `$myColor`, then adding a `myColor` field to `colors` will allow you to easily configure this color.
|
||||
|
||||
`copyright` - The copyright string at footer of site and within feed
|
||||
|
||||
`favicon` - URL for site favicon.
|
||||
|
||||
`headerIcon` - URL for icon used in header navigation bar.
|
||||
|
||||
`headerLinks` - Links that will be used in the header navigation bar. The `label` field of each object will be the link text and will also be translated for each language.
|
||||
|
||||
Example Usage:
|
||||
|
||||
```js
|
||||
headerLinks: [
|
||||
// Links to document with id doc1 for current language/version
|
||||
{ doc: "doc1", label: "Getting Started" },
|
||||
// Link to page found at pages/en/help.js or if that does not exist, pages/help.js, for current language
|
||||
{ page: "help", label: "Help" },
|
||||
// Links to href destination
|
||||
{ href: "https://github.com/", label: "GitHub" },
|
||||
// Links to blog generated by Docusaurus (${baseUrl}blog)
|
||||
{ blog: true, label: "Blog" },
|
||||
// Determines search bar position among links
|
||||
{ search: true },
|
||||
// Determines language drop down position among links
|
||||
{ languages: true }
|
||||
],
|
||||
```
|
||||
|
||||
`noIndex` - Boolean. If true, Docusaurus will politely ask crawlers and search engines to avoid indexing your site. This is done with a header tag and so only applies to docs and pages. Will not attempt to hide static resources. This is a best effort request. Malicious crawlers can and will still index your site.
|
||||
|
||||
`organizationName` - GitHub username of the organization or user hosting this project. This is used by the publishing script to determine where your GitHub pages website will be hosted.
|
||||
|
||||
`projectName` - Project name. This must match your GitHub repository project name (case-sensitive).
|
||||
|
||||
`tagline` - Tagline for your website.
|
||||
|
||||
`title` - Title for your website.
|
||||
|
||||
`url` - URL for your website.
|
||||
|
||||
### Optional Fields
|
||||
|
||||
`algolia` - Information for Algolia search integration. If this field is excluded, the search bar will not appear in the header. You must specify two values for this field, and one (`appId`) is optional.
|
||||
|
||||
* `apiKey` - the Algolia provided API key for your search.
|
||||
* `indexName` - the Algolia provided index name for your search (usually this is the project name)
|
||||
* `appId` - Algolia provides a default scraper for your docs. If you provide your own, you will probably get this id from them.
|
||||
|
||||
`blogSidebarCount` - Control the number of blog posts that show up in the sidebar. See the [adding a blog docs](guides-blog.md#changing-how-many-blog-posts-show-on-sidebar) for more information.
|
||||
|
||||
`blogSidebarTitle` - Control the title of the blog sidebar. See the [adding a blog docs](guides-blog.md#changing-the-sidebar-title) for more information.
|
||||
|
||||
`cleanUrl` - If `true`, allow URLs with no `html` extension. For example, a request to URL https://docusaurus.io/docs/installation will returns the same result as https://docusaurus.io/docs/installation.html.
|
||||
|
||||
`cname` - The CNAME for your website. It will go into a `CNAME` file when your site is built.
|
||||
|
||||
`customDocsPath` - By default, Docusaurus expects your documentation to be in a directory called `docs`. This directory is at the same level as the `website` directory (i.e., not inside the `website` directory). You can specify a custom path to your documentation with this field.
|
||||
|
||||
```js
|
||||
customDocsPath: 'docs/site';
|
||||
```
|
||||
|
||||
```js
|
||||
customDocsPath: 'website-docs';
|
||||
```
|
||||
|
||||
`defaultVersionShown` - The default version for the site to be shown. If this is not set, the latest version will be shown.
|
||||
|
||||
`disableHeaderTitle` - An option to disable showing the title in the header next to the header icon. Exclude this field to keep the header as normal, otherwise set to `true`.
|
||||
|
||||
`disableTitleTagline` - An option to disable showing the tagline in the title of main pages. Exclude this field to keep page titles as `Title • Tagline`. Set to `true` to make page titles just `Title`.
|
||||
|
||||
`editUrl` - URL for editing docs, usage example: `editUrl + 'en/doc1.md'`. If this field is omitted, there will be no "Edit this Doc" button for each document.
|
||||
|
||||
`facebookAppId` - If you want Facebook Like/Share buttons in the footer and at the bottom of your blog posts, provide a [Facebook application id](https://www.facebook.com/help/audiencenetwork/804209223039296).
|
||||
|
||||
`facebookComments` - Set this to `true` if you want to enable Facebook comments at the bottom of your blog post. `facebookAppId` has to be also set.
|
||||
|
||||
`facebookPixelId` - [Facebook Pixel](https://www.facebook.com/business/a/facebook-pixel) ID to track page views.
|
||||
|
||||
`fonts` - Font-family CSS configuration for the site. If a font family is specified in `siteConfig.js` as `$myFont`, then adding a `myFont` key to an array in `fonts` will allow you to configure the font. Items appearing earlier in the array will take priority of later elements, so ordering of the fonts matter.
|
||||
|
||||
In the below example, we have two sets of font configurations, `myFont` and `myOtherFont`. `Times New Roman` is the preferred font in `myFont`. `-apple-system` is the preferred in `myOtherFont`.
|
||||
|
||||
```js
|
||||
fonts: {
|
||||
myFont: [
|
||||
'Times New Roman',
|
||||
'Serif'
|
||||
],
|
||||
myOtherFont: [
|
||||
'-apple-system',
|
||||
'system-ui'
|
||||
]
|
||||
},
|
||||
```
|
||||
|
||||
The above fonts would be represented in your CSS file(s) as variables `$myFont` and `$myOtherFont`.
|
||||
|
||||
```css
|
||||
h1 {
|
||||
font-family: $myFont;
|
||||
}
|
||||
```
|
||||
|
||||
`footerIcon` - URL for a footer icon. Currently used in the `core/Footer.js` file provided as an example, but it can be removed from that file.
|
||||
|
||||
`gaTrackingId` - Google Analytics tracking ID to track page views.
|
||||
|
||||
`gaGtag` - Set this to `true` if you want to use [global site tags (gtag.js)](https://developers.google.com/gtagjs/) for Google analytics instead of `analytics.js`.
|
||||
|
||||
`githubHost` - Hostname of your server. Useful if you are using GitHub Enterprise.
|
||||
|
||||
`highlight` - [Syntax highlighting](api-doc-markdown.md) options:
|
||||
|
||||
* `theme` is the name of the theme used by Highlight.js when highlighting code. You can find the [list of supported themes here](https://github.com/isagalaev/highlight.js/tree/master/src/styles).
|
||||
* `version` specifies a particular version of Highlight.js to be used.
|
||||
* `hljs` provides an escape valve by passing an instance of Highlight.js to the function specified here, allowing additional languages to be registered for syntax highlighting.
|
||||
* `defaultLang` defines a default language. It will be used if one is not specified at the top of the code block. You can find the [list of supported languages here](https://github.com/isagalaev/highlight.js/tree/master/src/languages).
|
||||
* `themeUrl` is the custom URL of CSS theme file that you want to use with Highlight.js. If this is provided, the `theme` and `version` fields will be ignored.
|
||||
|
||||
`markdownPlugins` - An array of plugins to be loaded by Remarkable, the markdown parser and renderer used by Docusaurus. The plugin will receive a reference to the Remarkable instance, allowing custom parsing and rendering rules to be defined.
|
||||
|
||||
`ogImage` - Local path to an Open Graph image (e.g., `img/myImage.png`). This image will show up when your site is shared on Facebook and other websites/apps where the Open Graph protocol is supported.
|
||||
|
||||
`onPageNav` - If you want a visible navigation option for representing topics on the current page. Currently, there is one accepted value for this option:
|
||||
|
||||
* `separate` - The secondary navigation is a separate pane defaulting on the right side of a document. See http://docusaurus.io/docs/en/translation.html for an example.
|
||||
|
||||
`scripts` - Array of JavaScript sources to load. The script tag will be inserted in the HTML head.
|
||||
|
||||
`separateCss` - Directories inside which any `css` files will not be processed and concatenated to Docusaurus' styles. This is to support static `html` pages that may be separate from Docusaurus with completely separate styles.
|
||||
|
||||
`scrollToTop` - Set this to `true` if you want to enable the scroll to top button at the bottom of your site.
|
||||
|
||||
`scrollToTopOptions` - Optional options configuration for the scroll to top button. You do not need to use this, even if you set `scrollToTop` to `true`; it just provides you more configuration control of the button. You can find more options [here](https://github.com/vfeskov/vanilla-back-to-top/blob/v7.1.14/OPTIONS.md). By default, we set the zIndex option to 100.
|
||||
|
||||
`stylesheets` - Array of CSS sources to load. The link tag will be inserted in the HTML head.
|
||||
|
||||
`translationRecruitingLink` - URL for the `Help Translate` tab of language selection when languages besides English are enabled. This can be included you are using translations but does not have to be.
|
||||
|
||||
`twitter` - Set this to `true` if you want a Twitter social button to appear at the bottom of your blog posts.
|
||||
|
||||
`twitterUsername` - If you want a Twitter follow button at the bottom of your page, provide a Twitter username to follow. For example: `docusaurus`.
|
||||
|
||||
`twitterImage` - Local path to your Twitter card image (e.g., `img/myImage.png`). This image will show up on the Twitter card when your site is shared on Twitter.
|
||||
|
||||
`useEnglishUrl` - If you do not have [translations](guides-translation.md) enabled (e.g., by having a `languages.js` file), but still want a link of the form `/docs/en/doc.html` (with the `en`), set this to `true`.
|
||||
|
||||
`users` - The `users` array mentioned earlier.
|
||||
|
||||
`usePrism` - Array of languages to use Prism syntax highlighter. Refer to [Using Prism as additional syntax highlighter](api-doc-markdown.md#using-prism-as-additional-syntax-highlighter). Set it to `true` to use Prism on all languages.
|
||||
|
||||
`wrapPagesHTML` - Boolean flag to indicate whether `html` files in `/pages` should be wrapped with Docusaurus site styles, header and footer. This feature is experimental and relies on the files being `html` fragments instead of complete pages. It inserts the contents of your `html` file with no extra processing. Defaults to `false`.
|
||||
|
||||
Users can also add their own custom fields if they wish to provide some data across different files.
|
||||
|
||||
## Example siteConfig.js with many available fields
|
||||
|
||||
```js
|
||||
const users = [
|
||||
{
|
||||
caption: 'User1',
|
||||
image: '/test-site/img/docusaurus.svg',
|
||||
infoLink: 'https://www.example.com',
|
||||
pinned: true,
|
||||
},
|
||||
];
|
||||
|
||||
const siteConfig = {
|
||||
title: 'Docusaurus',
|
||||
tagline: 'Generate websites!',
|
||||
url: 'https://docusaurus.io',
|
||||
baseUrl: '/',
|
||||
// For github.io type URLS, you would combine the URL and baseUrl like:
|
||||
// url: 'https://reasonml.github.io',
|
||||
// baseUrl: '/reason-react/',
|
||||
defaultVersionShown: '1.0.0',
|
||||
organizationName: 'facebook',
|
||||
projectName: 'docusaurus',
|
||||
noIndex: false,
|
||||
// For no header links in the top nav bar -> headerLinks: [],
|
||||
headerLinks: [
|
||||
{doc: 'doc1', label: 'Docs'},
|
||||
{page: 'help', label: 'Help'},
|
||||
{search: true},
|
||||
{blog: true},
|
||||
],
|
||||
headerIcon: 'img/docusaurus.svg',
|
||||
favicon: 'img/favicon.png',
|
||||
colors: {
|
||||
primaryColor: '#2E8555',
|
||||
secondaryColor: '#205C3B',
|
||||
},
|
||||
editUrl: 'https://github.com/facebook/docusaurus/edit/master/docs/',
|
||||
// Users variable set above
|
||||
users,
|
||||
disableHeaderTitle: true,
|
||||
disableTitleTagline: true,
|
||||
separateCss: ['static/css/non-docusaurus', 'static/assets/separate-css'],
|
||||
footerIcon: 'img/docusaurus.svg',
|
||||
translationRecruitingLink: 'https://crowdin.com/project/docusaurus',
|
||||
algolia: {
|
||||
apiKey: '0f9f28b9ab9efae89810921a351753b5',
|
||||
indexName: 'github',
|
||||
},
|
||||
gaTrackingId: 'UA-12345678-9',
|
||||
highlight: {
|
||||
theme: 'default',
|
||||
},
|
||||
markdownPlugins: [
|
||||
function foo(md) {
|
||||
md.renderer.rules.fence_custom.foo = function(
|
||||
tokens,
|
||||
idx,
|
||||
options,
|
||||
env,
|
||||
instance
|
||||
) {
|
||||
return '<div class="foo">bar</div>';
|
||||
};
|
||||
},
|
||||
],
|
||||
scripts: ['https://docusaurus.io/slash.js'],
|
||||
stylesheets: ['https://docusaurus.io/style.css'],
|
||||
facebookAppId: '1615782811974223',
|
||||
facebookComments: true,
|
||||
facebookPixelId: '352490515235776',
|
||||
twitter: 'true',
|
||||
twitterUsername: 'docusaurus',
|
||||
twitterImage: 'img/docusaurus.png',
|
||||
ogImage: 'img/docusaurus.png',
|
||||
cleanUrl: true,
|
||||
scrollToTop: true,
|
||||
scrollToTopOptions: {
|
||||
zIndex: 100,
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = siteConfig;
|
||||
```
|
|
@ -0,0 +1,119 @@
|
|||
---
|
||||
id: version-1.3.3-installation
|
||||
title: Installation
|
||||
original_id: installation
|
||||
---
|
||||
|
||||
Docusaurus was designed from the ground up to be easily installed and used to get your website up and running quickly.
|
||||
|
||||
## Installing Docusaurus
|
||||
|
||||
We have created an easy script that will get all of the infrastructure set up for you:
|
||||
|
||||
1. Ensure you have the latest version of [Node](https://nodejs.org/en/download/) installed. We also recommend you install [Yarn](https://yarnpkg.com/en/docs/install) as well.
|
||||
|
||||
> You have to be on Node >= 8.x and Yarn >= 1.5.
|
||||
|
||||
1. Create a project, if none exists, and change your the directory to this project's root.
|
||||
|
||||
You will be creating the docs in this directory. The root directory may
|
||||
contain other files. The Docusaurus installation script will create two new
|
||||
directories: `docs-examples-from-docusaurus` and `website`.
|
||||
|
||||
> Commonly, either an existing or newly created GitHub project will be the location for your Docusaurus site, but that is not mandatory to use Docusaurus.
|
||||
|
||||
1. Run the Docusaurus installation script: `npx docusaurus-init`.
|
||||
|
||||
> If you don't have Node 8.2+ or if you prefer to install Docusaurus globally, run `yarn global add docusaurus-init` or `npm install --global docusaurus-init`. After that, run `docusaurus-init`.
|
||||
|
||||
## Verifying Installation
|
||||
|
||||
Along with previously existing files and directories, your root directory will now contain a structure similar to:
|
||||
|
||||
```bash
|
||||
root-directory
|
||||
├── docs-examples-from-docusaurus
|
||||
│ ├── doc1.md
|
||||
│ ├── doc2.md
|
||||
│ ├── doc3.md
|
||||
│ ├── exampledoc4.md
|
||||
│ └── exampledoc5.md
|
||||
└── website
|
||||
├── blog-examples-from-docusaurus
|
||||
│ ├── 2016-03-11-blog-post.md
|
||||
│ ├── 2017-04-10-blog-post-two.md
|
||||
│ ├── 2017-09-25-testing-rss.md
|
||||
│ ├── 2017-09-26-adding-rss.md
|
||||
│ └── 2017-10-24-new-version-1.0.0.md
|
||||
├── core
|
||||
│ └── Footer.js
|
||||
├── package.json
|
||||
├── pages
|
||||
├── sidebars.json
|
||||
├── siteConfig.js
|
||||
└── static
|
||||
```
|
||||
|
||||
## Running the example website
|
||||
|
||||
After running the Docusaurus initialization script, `docusaurus-init` as
|
||||
described in the [Installation](#installing-docusaurus) section, you will have a
|
||||
runnable, example website to use as your site's base. To run:
|
||||
|
||||
1. In your root, rename `docs-examples-from-docusaurus` to `docs`.
|
||||
1. `cd website`
|
||||
1. Rename `blog-examples-from-docusaurus` to `blog`.
|
||||
1. From within the `website` directory, run the local webserver using
|
||||
`yarn start` or `npm start`.
|
||||
1. Load the example site at http://localhost:3000 if it did not already open
|
||||
automatically.
|
||||
|
||||
You should see the example site loaded in your web browser. There's also a LiveReload server running and any changes made to the docs and files in the `website` directory will cause the page to refresh.
|
||||
|
||||

|
||||
|
||||
### Launching the server behind a proxy
|
||||
|
||||
If you are behind a corporate proxy, you need to disable it for the development server requests. It can be done using the `NO_PROXY` environment variable.
|
||||
|
||||
```sh
|
||||
SET NO_PROXY=localhost
|
||||
yarn start (or npm run start)
|
||||
```
|
||||
|
||||
## Updating Your Docusaurus Version
|
||||
|
||||
At any time after Docusaurus is installed, you can check your current version of Docusaurus by going into the `website` directory and typing `yarn outdated docusaurus` or `npm outdated docusaurus`.
|
||||
|
||||
You will see something like this:
|
||||
|
||||
```
|
||||
$ yarn outdated
|
||||
Using globally installed version of Yarn
|
||||
yarn outdated v1.5.1
|
||||
warning package.json: No license field
|
||||
warning No license field
|
||||
info Color legend :
|
||||
"<red>" : Major Update backward-incompatible updates
|
||||
"<yellow>" : Minor Update backward-compatible features
|
||||
"<green>" : Patch Update backward-compatible bug fixes
|
||||
Package Current Wanted Latest Package Type URL
|
||||
docusaurus 1.0.9 1.2.0 1.2.0 devDependencies https://github.com/facebook/Docusaurus#readme
|
||||
✨ Done in 0.41s.
|
||||
```
|
||||
|
||||
> If there is no noticeable version output from the `outdated` commands, then you are up-to-date.
|
||||
|
||||
You can update to the [latest version](https://www.npmjs.com/package/docusaurus) of Docusaurus by:
|
||||
|
||||
```
|
||||
yarn upgrade docusaurus --latest
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```
|
||||
npm update docusaurus
|
||||
```
|
||||
|
||||
> If you are finding that you are getting errors after your upgrade, try to either clear your Babel cache (usually it's in a [temporary directory](https://babeljs.io/docs/en/babel-register/#environment-variables) or run the Docusaurus server (e.g., `yarn start`) with the `BABEL_DISABLE_CACHE=1` environment configuration.
|
|
@ -0,0 +1,64 @@
|
|||
---
|
||||
id: version-1.3.3-site-preparation
|
||||
title: Site Preparation
|
||||
original_id: site-preparation
|
||||
---
|
||||
|
||||
After [installing Docusaurus](getting-started-installation.md), you now have a skeleton to work from for your specific website. The following discusses the rest of the Docusaurus structure in order for you to prepare your site.
|
||||
|
||||
## Directory Structure
|
||||
|
||||
As shown after you [installed Docusaurus](getting-started-installation.md), the initialization script created a directory structure similar to:
|
||||
|
||||
```bash
|
||||
root-directory
|
||||
├── docs-examples-from-docusaurus
|
||||
│ ├── doc1.md
|
||||
│ ├── doc2.md
|
||||
│ ├── doc3.md
|
||||
│ ├── exampledoc4.md
|
||||
│ └── exampledoc5.md
|
||||
└── website
|
||||
├── blog-examples-from-docusaurus
|
||||
│ ├── 2016-03-11-blog-post.md
|
||||
│ ├── 2017-04-10-blog-post-two.md
|
||||
│ ├── 2017-09-25-testing-rss.md
|
||||
│ ├── 2017-09-26-adding-rss.md
|
||||
│ └── 2017-10-24-new-version-1.0.0.md
|
||||
├── core
|
||||
│ └── Footer.js
|
||||
├── package.json
|
||||
├── pages
|
||||
├── sidebars.json
|
||||
├── siteConfig.js
|
||||
└── static
|
||||
```
|
||||
|
||||
> You may have already renamed the example blog (`website/blog-examples-from-docusaurus` to `website/blog`) and document (`docs-examples-from-docusaurus` to `docs`) directories when you [verified the installation](getting-started-installation.md##verifying-installation).
|
||||
|
||||
### Directory Descriptions
|
||||
|
||||
* **Documentation Source Files**: The `docs-examples-from-docusaurus` directory
|
||||
contains example documentation files written in Markdown.
|
||||
* **Blog**: The `website/blog-examples-from-docusaurus` directory contains examples of blog posts written in markdown.
|
||||
* **Pages**: The `website/pages` directory contains example top-level pages for the site.
|
||||
* **Static files and images**: The `website/static` directory contains static assets used by the example site.
|
||||
|
||||
### Key Files
|
||||
|
||||
* **Footer**: The `website/core/Footer.js` file is a React component that acts
|
||||
as the footer for the site generated by Docusaurus and should be customized by the user.
|
||||
* **Configuration file**: The `website/siteConfig.js` file is the main
|
||||
configuration file used by Docusaurus.
|
||||
* **Sidebars**: The `sidebars.json` file contains the structure and ordering
|
||||
of the documentation files.
|
||||
|
||||
## Preparation Notes
|
||||
|
||||
You will need to keep the `website/siteConfig.js` and `website/core/Footer.js`
|
||||
files, but may edit them as you wish.
|
||||
|
||||
You should keep the `website/pages` and `website/static` directories, but may
|
||||
change the content inside them as you wish. At the bare minimum you should have
|
||||
an `en/index.js` or `en/index.html` file inside `website/pages` and an image to
|
||||
use as your header icon inside `website/static`.
|
69
website/versioned_docs/version-1.3.3/guides-search.md
Normal file
69
website/versioned_docs/version-1.3.3/guides-search.md
Normal file
|
@ -0,0 +1,69 @@
|
|||
---
|
||||
id: version-1.3.3-search
|
||||
title: Enabling Search
|
||||
original_id: search
|
||||
---
|
||||
|
||||
Docusaurus supports search using [Algolia DocSearch](https://community.algolia.com/docsearch/). Once your website is online, you can [submit it to DocSearch](https://community.algolia.com/docsearch/). Algolia will then send you credentials you can add to your `siteConfig.js`.
|
||||
|
||||
DocSearch works by crawling the content of your website every 24 hours and putting all the content in an Algolia index. This content is then queried directly from your front-end using the Algolia API. Note that your website need to be publicly available for this to work (ie. not behind a firewall). This service is free.
|
||||
|
||||
## Enabling the Search Bar
|
||||
|
||||
Enter your API key and index name (sent by Algolia) into `siteConfig.js` in the `algolia` section to enable search for your site.
|
||||
|
||||
```js
|
||||
const siteConfig = {
|
||||
...
|
||||
algolia: {
|
||||
apiKey: 'my-api-key',
|
||||
indexName: 'my-index-name',
|
||||
algoliaOptions: {} // Optional, if provided by Algolia
|
||||
},
|
||||
...
|
||||
};
|
||||
```
|
||||
|
||||
## Extra Search Options
|
||||
|
||||
You can also specify extra [search options used by Algolia](https://community.algolia.com/docsearch/documentation/) by using an `algoliaOptions` field in `algolia`. This may be useful if you want to provide different search results for the different versions or languages of your docs. Any occurrences of "VERSION" or "LANGUAGE" will be replaced by the version or language of the current page, respectively. More details about search options can be [found here](https://www.algolia.com/doc/api-reference/api-parameters/#overview).
|
||||
|
||||
```js
|
||||
const siteConfig = {
|
||||
...
|
||||
algolia: {
|
||||
...
|
||||
algoliaOptions: {
|
||||
facetFilters: [ "language:LANGUAGE", "version:VERSION" ]
|
||||
}
|
||||
},
|
||||
};
|
||||
```
|
||||
|
||||
Algolia might provide you with [extra search options](https://community.algolia.com/docsearch/documentation/). If so, you should add them to the `algoliaOptions` object.
|
||||
|
||||
## Controlling the Location of the Search Bar
|
||||
|
||||
By default, the search bar will be the rightmost element in the top navigation bar.
|
||||
|
||||
If you want to change the default location, add the `searchBar` flag in the `headerLinks` field of `siteConfig.js` in your desired location. For example, you may want the search bar between your internal and external links.
|
||||
|
||||
```js
|
||||
const siteConfig = {
|
||||
...
|
||||
headerLinks: [
|
||||
{...}
|
||||
{...}
|
||||
{ search: true }
|
||||
{...}
|
||||
{...}
|
||||
],
|
||||
...
|
||||
};
|
||||
```
|
||||
|
||||
## Disabling the Search Bar
|
||||
|
||||
To disable the search bar, comment out (recommended) or delete the `algolia` section in the `siteConfig.js` file.
|
||||
|
||||
Also, if you have customized the location of the search bar in `headerLinks`, set `search: false`.
|
295
website/versioned_docs/version-1.3.3/guides-translation.md
Normal file
295
website/versioned_docs/version-1.3.3/guides-translation.md
Normal file
|
@ -0,0 +1,295 @@
|
|||
---
|
||||
id: version-1.3.3-translation
|
||||
title: Translations & Localization
|
||||
original_id: translation
|
||||
---
|
||||
|
||||
Docusaurus allows for easy translation functionality using [Crowdin](https://crowdin.com/). Documentation files written in English are uploaded to Crowdin for translation by users within a community. Top-level pages written with English strings can be translated by wrapping any strings you want to translate in a `<translate>` tag. Other titles and labels will also be found and properly translated.
|
||||
|
||||
## Docusaurus Translation Configurations
|
||||
|
||||
To generate example files for translations with Docusaurus, run the `examples` script with the command line argument `translations`:
|
||||
|
||||
```bash
|
||||
npm run examples translations
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
yarn examples translations
|
||||
```
|
||||
|
||||
This will create the following files:
|
||||
|
||||
```bash
|
||||
pages/en/help-with-translations.js
|
||||
languages.js
|
||||
../crowdin.yaml
|
||||
```
|
||||
|
||||
* The `pages/en/help-with-translations.js` file includes the same starter help page generated by the `examples` script, but now includes translation tags.
|
||||
|
||||
> Generally, you will use `help-with-translations.js` as a guide to enable translations in your other pages, but not actually commit the file to your repo (i.e., you can delete it). However, if you want a Help page, and you currently do not have one, you can rename this file to `help.js` and use it as a starting point.
|
||||
|
||||
* The `languages.js` file tells Docusaurus what languages you want to enable for your site. By default, we expect English to be enabled.
|
||||
|
||||
* The `crowdin.yaml` file is used to configure Crowdin integration, and is copied up one level into your Docusaurus project repo. If your Docusaurus project resides in `/project/website`, then `crowdin.yaml` will be copied to `/project/crowdin.yaml`.
|
||||
|
||||
## Translating Your Existing Docs
|
||||
|
||||
Your documentation files (e.g., the `.md` files that live in your `docs` directory) do not need to be changed or moved to support translations. They will be uploaded to Crowdin to be translated directly.
|
||||
|
||||
## Enabling Translations on Pages
|
||||
|
||||
Pages allow you to customize layout and specific content of pages like a custom index page or help page.
|
||||
|
||||
Pages with text that you want translated should be placed in `website/pages/en` directory.
|
||||
|
||||
Wrap strings you want translated in a `<translate>` tag, and add the following `require` statement to the top of the file:
|
||||
|
||||
```jsx
|
||||
...
|
||||
const translate = require('../../server/translate.js').translate;
|
||||
...
|
||||
<h2>
|
||||
<translate>This header will be translated</translate>
|
||||
</h2>
|
||||
...
|
||||
```
|
||||
|
||||
You can also include an optional description attribute to give more context to a translator about how to translate the string:
|
||||
|
||||
```jsx
|
||||
<p>
|
||||
<translate desc="flower, not verb">Rose</translate>
|
||||
<p>
|
||||
```
|
||||
|
||||
> The `<translate>` tag generally works well on pure strings. If you have a string like "Docusaurus currently provides support to help your website use [translations](${siteConfig.baseUrl}docs/${this.props.language}/translation.html)", wrapping the `<translation>` tag around that entire string will cause issues because of the markdown linking, etc. Your options are to not translate those strings, or spread a bunch of `<translate>` tags amongst the pure substrings of that string.
|
||||
|
||||
## Gathering Strings to Translate
|
||||
|
||||
The strings within localized Pages must be extracted and provided to Crowdin.
|
||||
|
||||
Add the following script to your `website/package.json` file, if it does not exist already:
|
||||
|
||||
```js
|
||||
{
|
||||
...
|
||||
"scripts": {
|
||||
"write-translations": "docusaurus-write-translations"
|
||||
},
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
Running the script will generate a `website/i18n/en.json` file containing all the strings that will be translated from English into other languages.
|
||||
|
||||
The script will include text from the following places:
|
||||
|
||||
* `title` and `sidebar_label` strings in document markdown headers
|
||||
* category names in `sidebars.json`
|
||||
* tagline in `siteConfig.js`
|
||||
* header link `label` strings in `siteConfig.js`
|
||||
* strings wrapped in the `<translate>` tag in any `.js` files inside `pages`
|
||||
|
||||
### Custom Translation Strings
|
||||
|
||||
If you want to add additional custom translation strings, or override any of the strings that get produced by the script that creates the `website/i18n/en.json` file, you can add a `website/data/custom-translation-strings.json` file. The file should have form of:
|
||||
|
||||
```json
|
||||
{
|
||||
"localized-strings": {
|
||||
"id": "string",
|
||||
"id2": "string2"
|
||||
},
|
||||
"pages-strings" : {
|
||||
"id3": "string3",
|
||||
"id4": "string4"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
where `localized-strings` represent strings in your documentation content and `pages-strings` represents metadata in your documentation (e.g., title, links, etc).
|
||||
|
||||
Here is an example:
|
||||
|
||||
```json
|
||||
{
|
||||
"_comment": "This file is used to provide custom strings for translations, including overriding defaults",
|
||||
"localized-strings": {
|
||||
"translation": "Translations and Localization"
|
||||
},
|
||||
"pages-strings" : {
|
||||
"Help Translate|recruit community translators for your project": "Help Us Translate"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
See the generated `website/i18n/en.json` for an example.
|
||||
|
||||
## How Strings Get Translated
|
||||
|
||||
Docusaurus itself does not do any translation from one language to another. Instead, it integrates [Crowdin](https://crowdin.com/) to upload translations and then downloads the appropriately translated files from Crowdin.
|
||||
|
||||
## How Docusaurus Uses String Translations
|
||||
|
||||
This section provides context about how translations in Docusaurus works.
|
||||
|
||||
### Strings
|
||||
|
||||
A Docusaurus site has many strings used throughout it that require localization. However, maintaining a list of strings used through out a site can be laborious. Docusaurus simplifies this by centralizing strings.
|
||||
|
||||
The header navigation, for example can have links to 'Home' or your 'Blog'. This and other strings found in the headers and sidebars of pages are extracted and placed into `i18n/en.json`. When your files are translated, say into Spanish, a `i18n/es-ES.json` file will be downloaded from Crowdin. Then, when the Spanish pages are generated, Docusaurus will replace the English version of corresponding strings with translated strings from the corresponding localized strings file (e.g. In a Spanish enabled site 'Help' will become 'Ayuda').
|
||||
|
||||
### Markdown Files
|
||||
|
||||
For documentation files themselves, translated versions of these files are downloaded and then rendered through the proper layout template.
|
||||
|
||||
### Other Pages
|
||||
|
||||
For other pages, Docusaurus will automatically transform all `<translate>` tags it finds into function calls that return the translated strings from the corresponding localized file _`locale.json`_.
|
||||
|
||||
## Crowdin
|
||||
|
||||
Crowdin is a company that provides translation services. For Open Source projects, Crowdin provides free string translations.
|
||||
|
||||
Create your translation project on [Crowdin](https://crowdin.com/). You can use [Crowdin's guides](https://support.crowdin.com/translation-process-overview/) to learn more about the translations work flow. _We suggest that you deselect and do not include "English" as a translatable language to prevent the creation of `en-US` localization files as this can lead to confusion._
|
||||
|
||||
> Ensure in your Crowdin settings, in the Translations section, that "Duplicate Strings" are set to ["Hide - all duplicates will share the same translation"](https://support.crowdin.com/api/create-project/). This setting will ensure that identical strings between versions share a single translation.
|
||||
|
||||
Your project will need a `crowdin.yaml` file generated. If you ran `yarn examples translations` or `npm run examples translations`, this file was created for you on the same level as your `website` directory.
|
||||
|
||||
> You will need to install the `crowdin` command line interface. Please follow the [installation directions](https://support.crowdin.com/cli-tool/).
|
||||
|
||||
The example below can be automatically generated by the Docusaurus cli with the `examples` script. It should be placed in the top level of your project directory to configure how and what files are uploaded/downloaded.
|
||||
|
||||
Below is an example Crowdin configuration for the respective languages: German, Spanish, French, Japanese, Korean, Bahasa Indonesia, Portuguese Brazilian, Chinese Simplified, and Chinese Traditional.
|
||||
|
||||
```yaml
|
||||
project_identifier_env: CROWDIN_DOCUSAURUS_PROJECT_ID
|
||||
api_key_env: CROWDIN_DOCUSAURUS_API_KEY
|
||||
base_path: "./"
|
||||
preserve_hierarchy: true
|
||||
|
||||
files:
|
||||
-
|
||||
source: '/docs/**/*.md'
|
||||
translation: '/website/translated_docs/%locale%/**/%original_file_name%'
|
||||
languages_mapping: &anchor
|
||||
locale:
|
||||
'de': 'de'
|
||||
'es-ES': 'es-ES'
|
||||
'fr': 'fr'
|
||||
'ja': 'ja'
|
||||
'ko': 'ko'
|
||||
'mr': 'mr-IN'
|
||||
'pt-BR': 'pt-BR'
|
||||
'zh-CN': 'zh-CN'
|
||||
'zh-TW': 'zh-TW'
|
||||
```
|
||||
|
||||
You can go [here](https://support.crowdin.com/configuration-file/) to learn more about customizing your `crowdin.yaml` file.
|
||||
|
||||
### Setup the Crowdin Scripts
|
||||
|
||||
You will want to manually sync your files to and from Crowdin. The sync process will upload any markdown files in `/docs` as well as translatable strings in `website/i18n/en.json`. (These strings can be generated by running `yarn write-translations`.)
|
||||
|
||||
You can add the following to your `package.json` to manually trigger Crowdin.
|
||||
|
||||
```js
|
||||
"scripts": {
|
||||
"crowdin-upload": "crowdin --config ../crowdin.yaml upload sources --auto-update -b master",
|
||||
"crowdin-download": "crowdin --config ../crowdin.yaml download -b master"
|
||||
},
|
||||
```
|
||||
|
||||
### Manual File Sync
|
||||
|
||||
You will always want to upload your markdown files and translatable strings first and the download the translations section. So run the commands in this order:
|
||||
|
||||
```bash
|
||||
CROWDIN_DOCUSAURUS_PROJECT_ID=YOUR_CROWDIN_PROJECT_ID CROWDIN_DOCUSAURUS_API_KEY=YOUR_CROWDIN_API_KEY yarn run crowdin-upload
|
||||
CROWDIN_DOCUSAURUS_PROJECT_ID=YOUR_CROWDIN_PROJECT_ID CROWDIN_DOCUSAURUS_API_KEY=YOUR_CROWDIN_API_KEY yarn run crowdin-download
|
||||
```
|
||||
|
||||
> `YOUR_CROWDIN_PROJECT_ID` is the name of your Crowdin project. e.g., for https://crowdin.com/project/docusaurus/, that variable would be set to `docusaurus`. `YOUR_CROWDIN_API_KEY` is a unique key that is like a password. You can find it in the `API` tab of your Crowdin project's `Settings`.
|
||||
|
||||
> These commands require having an environment variable set with your Crowdin project id and api key (`CROWDIN_PROJECT_ID`, `CROWDIN_API_KEY`). You can preface them inline as done above or add them permanently to your `.bashrc` or `.bash_profile`.
|
||||
|
||||
> If you run more than one localized Docusaurus project on your computer, you should change the name of the environment variables to something unique (`CROWDIN_PROJECTNAME_PROJECT_ID`, `CROWDIN_PROJECTNAME_API_KEY`).
|
||||
|
||||
> Since the files are generated, you do not need to have any files in your `website/i18n` or `website/translated_docs` directory as part of your repo. So you can can add `website/i18n/*` and `website/translated_docs` to your `.gitignore` file.
|
||||
|
||||
### Automated File Sync Using CircleCI
|
||||
|
||||
You can automate pulling down and uploading translations for your files using the [CircleCI](https://circleci.com) web continuous integration service.
|
||||
|
||||
First, update the `.circleci/config.yml` file in your project directory to include steps to upload English files to be translated and download translated files using the Crowdin CLI. Here is an example `.circleci/config.yml` file:
|
||||
|
||||
```yaml
|
||||
# If you only want circle to run on direct commits to master, you can uncomment this out
|
||||
# and uncomment the filters: *filter-only-master down below too
|
||||
#
|
||||
# aliases:
|
||||
# - &filter-only-master
|
||||
# branches:
|
||||
# only:
|
||||
# - master
|
||||
|
||||
version: 2
|
||||
jobs:
|
||||
deploy-website:
|
||||
docker:
|
||||
# specify the version you desire here
|
||||
- image: circleci/node:8.11.1
|
||||
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Deploying to GitHub Pages
|
||||
command: |
|
||||
git config --global user.email "<GITHUB_USERNAME>@users.noreply.github.com"
|
||||
git config --global user.name "<YOUR_NAME>"
|
||||
echo "machine github.com login <GITHUB_USERNAME> password $GITHUB_TOKEN" > ~/.netrc
|
||||
# install Docusaurus and generate file of English strings
|
||||
- cd website && yarn install && yarn run write-translations && cd ..
|
||||
# crowdin install
|
||||
- sudo apt-get install default-jre
|
||||
- wget https://artifacts.crowdin.com/repo/deb/crowdin.deb -O crowdin.deb
|
||||
- sudo dpkg -i crowdin.deb
|
||||
# translations upload/download
|
||||
- crowdin --config crowdin.yaml upload sources --auto-update -b master
|
||||
- crowdin --config crowdin.yaml download -b master
|
||||
# build and publish website
|
||||
cd website && GIT_USER=<GIT_USER> yarn run publish-gh-pages
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build_and_deploy:
|
||||
jobs:
|
||||
- deploy-website:
|
||||
# filters: *filter-only-master
|
||||
```
|
||||
|
||||
The `crowdin` command uses the `crowdin.yaml` file generated with the `examples` script. It should be placed in your project directory to configure how and what files are uploaded/downloaded.
|
||||
|
||||
Note that in the `crowdin.yaml` file, `CROWDIN_PROJECT_ID` and `CROWDIN_API_KEY` are environment variables set-up in Circle for your Crowdin project. They can be found in your Crowdin project settings.
|
||||
|
||||
Now, Circle will help you automatically get translations prior to building your website. The provided `crowdin.yaml` file will copy translated documents into `website/translated_docs/`, and translated versions of the `i18n/en.json` strings file will into `i18n/${language}.json`.
|
||||
|
||||
If you wish to use Crowdin on your machine locally, you can install the [Crowdin CLI tool](https://support.crowdin.com/cli-tool/) and run the same commands found in the `circle.yaml` file. The only difference is that you must set `project_identifier` and `api_key` values in the `crowdin.yaml` file since you will not have Circle environment variables set up.
|
||||
|
||||
## Versioned Translations
|
||||
|
||||
If you wish to have translation and versioning for your documentation, add the following section to the end of your `crowdin.yaml` file:
|
||||
|
||||
```yaml
|
||||
-
|
||||
source: '/website/versioned_docs/**/*.md'
|
||||
translation: '/website/translated_docs/%locale%/**/%original_file_name%'
|
||||
languages_mapping: *anchor
|
||||
```
|
||||
|
||||
Translated, versioned documents will be copied into `website/translated_docs/${language}/${version}/`.
|
|
@ -1,4 +1,5 @@
|
|||
[
|
||||
"1.3.3",
|
||||
"1.3.2",
|
||||
"1.3.1",
|
||||
"1.3.0",
|
||||
|
|
Loading…
Add table
Reference in a new issue