mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-04 11:52:39 +02:00
parent
a33e3ec362
commit
c9243e8922
8 changed files with 1173 additions and 1 deletions
46
CHANGELOG.md
46
CHANGELOG.md
|
@ -6,6 +6,52 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.5.1] - 2018-11-03
|
||||
|
||||
A release where we had many external contributors! Very excited to see the community being involved in the project.
|
||||
|
||||
Welcome to our newest users, Create React App, Stackery, Vasern, Noderize, React 360 and Formik.
|
||||
|
||||
Thank you to the following contributors who helped with this release:
|
||||
|
||||
- @yangshun
|
||||
- @endiliey
|
||||
- @JoelMarcey
|
||||
- @tanhauhau
|
||||
- @fiennyangeln
|
||||
- @vikr01
|
||||
- @alexdriedger
|
||||
- @hobofan
|
||||
- @bildungsroman
|
||||
- @tirthbodawala
|
||||
- @M4rk9696
|
||||
- @sinodko
|
||||
- @aenuros
|
||||
- @SleepWalker
|
||||
- @pdyx2828
|
||||
- @phated
|
||||
- @huguestennier
|
||||
- @gtoprak
|
||||
- @Rajekevin
|
||||
- @sunitasen
|
||||
- @shahednasser
|
||||
|
||||
### Fixed/Changed
|
||||
|
||||
- Throw error when forgot to pass in GIT_USER ([#1035](https://github.com/facebook/Docusaurus/pull/1035))
|
||||
- Exclude file movements for last updated time ([#1023](https://github.com/facebook/Docusaurus/pull/1023))
|
||||
- Update support for Web App Manifest ([#1046](https://github.com/facebook/Docusaurus/pull/1046))
|
||||
- Render proper HTML instead of raw markdown in og:description ([#1054](https://github.com/facebook/Docusaurus/pull/1054))
|
||||
|
||||
### Added
|
||||
|
||||
- New feature of displaying the last contributor to each document ([#980](https://github.com/facebook/Docusaurus/pull/980))
|
||||
- Document how to add "Copy" button to code blocks ([#1047](https://github.com/facebook/Docusaurus/pull/1047))
|
||||
- Support reference-style linking in documents ([#1048](https://github.com/facebook/Docusaurus/pull/1048))
|
||||
- Add caption to user page links ([#1075](https://github.com/facebook/Docusaurus/pull/1075))
|
||||
|
||||
### Removed
|
||||
|
||||
## [1.5.0] - 2018-10-13
|
||||
|
||||
This version introduces a big improvement to the sidebar, where you can now have subcategories.
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "docusaurus",
|
||||
"description": "Easy to Maintain Open Source Documentation Websites",
|
||||
"version": "1.5.0",
|
||||
"version": "1.5.1",
|
||||
"license": "MIT",
|
||||
"keywords": ["documentation", "websites", "open source", "docusaurus"],
|
||||
"repository": {
|
||||
|
|
173
v1/website/versioned_docs/version-1.5.1/api-commands.md
Normal file
173
v1/website/versioned_docs/version-1.5.1/api-commands.md
Normal file
|
@ -0,0 +1,173 @@
|
|||
---
|
||||
id: version-1.5.1-commands
|
||||
title: CLI Commands
|
||||
original_id: commands
|
||||
---
|
||||
|
||||
Docusaurus provides a set of scripts to help you generate, serve, and deploy your website. These scripts can be invoked with the `run` command when using Yarn or npm. Some common commands are:
|
||||
|
||||
* [`yarn run start`](api-commands.md#docusaurus-start-port-number): build and serve the website from a local server
|
||||
* [`yarn run examples`](api-commands.md#docusaurus-examples): create example configuration files
|
||||
|
||||
## Running from the command line
|
||||
|
||||
The scripts can be run using either Yarn or npm. If you've already gone through our Getting Started guide, you may already be familiar with the `start` command. It's the command that tells Docusaurus to run the `docusaurus-start` script which generates the site and starts up a server, and it's usually invoked like so:
|
||||
|
||||
```bash
|
||||
yarn run start
|
||||
```
|
||||
|
||||
The same script can be invoked using npm:
|
||||
|
||||
```bash
|
||||
npm run start
|
||||
```
|
||||
|
||||
To run a particular script, just replace the `start` command in the examples above with the command associated with your script.
|
||||
|
||||
## Using arguments
|
||||
|
||||
Some commands support optional arguments. For example, to start a server on port 8080, you can specify the `--port` argument when running `start`:
|
||||
|
||||
```bash
|
||||
yarn run start --port 8080
|
||||
```
|
||||
|
||||
If you run Docusaurus using npm, you can still use the command line arguments by inserting a `--` between `npm run <command>` and the command arguments:
|
||||
|
||||
```bash
|
||||
npm run start -- --port 8080
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
These scripts are set up under the `"scripts"` key in your `website/package.json` file as part of the installation process. If you need help setting them up again, please refer to the [Installation guide](getting-started-installation.md).
|
||||
|
||||
Docusaurus provides some default mappings to allow you to run commands following Node conventions. Instead of typing `docusaurus-start` every time, you can type `yarn run start` or `npm start` to achieve the same.
|
||||
|
||||
## Commands
|
||||
|
||||
<AUTOGENERATED_TABLE_OF_CONTENTS>
|
||||
|
||||
---
|
||||
|
||||
## Reference
|
||||
|
||||
### `docusaurus-build`
|
||||
|
||||
Alias: `build`.
|
||||
|
||||
| Options | Default | Description |
|
||||
| -------------------------- | ------- | --------------------------------------------------------------------------------------------------------------------- |
|
||||
| `--skip-image-compression` | `false` | Skip compression of image assets. You usually won't want to skip this unless your images have already been optimized. |
|
||||
|
||||
Generates the static website, applying translations if necessary. Useful for building the website prior to deployment.
|
||||
|
||||
See also [`docusaurus-start`](api-commands.md#docusaurus-start).
|
||||
|
||||
---
|
||||
|
||||
### `docusaurus-examples`
|
||||
|
||||
Alias: `examples`
|
||||
|
||||
| Arguments | Default | Description |
|
||||
| ----------- | ------- | ---------------------------------------------------------------------------------------------------- |
|
||||
| `<feature>` | - | Specify a feature `translations` or `versions` to generate the extra example files for that feature. |
|
||||
|
||||
**Example**
|
||||
|
||||
```bash
|
||||
docusaurus-examples <feature>
|
||||
```
|
||||
|
||||
When no feature is specified, sets up a minimally configured example website in your project. This command is covered in depth in the [Site Preparation guide](getting-started-preparation.md).
|
||||
|
||||
---
|
||||
|
||||
### `docusaurus-publish`
|
||||
|
||||
Alias: `publish-gh-pages`
|
||||
|
||||
[Builds](api-commands.md#docusaurus-build), then deploys the static website to GitHub Pages. This command is meant to be run during the deployment step in Circle CI, and therefore expects a few environment variables to be defined:
|
||||
|
||||
The following environment variables are generally set manually by the user in the CircleCI `config.yml` file.
|
||||
|
||||
* `GIT_USER`: The git user to be associated with the deploy commit.
|
||||
* `USE_SSH`: Whether to use SSH instead of HTTPS for your connection to the GitHub repo.
|
||||
|
||||
**Example**
|
||||
|
||||
```bash
|
||||
GIT_USER=docusaurus-bot USE_SSH=true yarn run publish-gh-pages
|
||||
```
|
||||
|
||||
The following environment variables are [set by CircleCI](https://circleci.com/docs/1.0/environment-variables/) during the build process.
|
||||
|
||||
* `CIRCLE_BRANCH`: The git branch associated with the commit that triggered the CI run.
|
||||
* `CI_PULL_REQUEST`: Expected to be truthy if the current CI run was triggered by a commit in a pull request.
|
||||
|
||||
The following should be set by you in `siteConfig.js` as `organizationName` and `projectName`, respectively. If they are not set in your site configuration, they fall back to the [CircleCI environment](https://circleci.com/docs/1.0/environment-variables/).
|
||||
|
||||
* `CIRCLE_PROJECT_USERNAME`: The GitHub username or organization name that hosts the Git repo, e.g. "facebook".
|
||||
* `CIRCLE_PROJECT_REPONAME`: The name of the Git repo, e.g. "Docusaurus".
|
||||
|
||||
You can learn more about configuring automatic deployments with CircleCI in the [Publishing guide](getting-started-publishing.md).
|
||||
|
||||
---
|
||||
|
||||
### `docusaurus-rename-version`
|
||||
|
||||
Alias: `rename-version`
|
||||
|
||||
Renames an existing version of the docs to a new version name.
|
||||
|
||||
| Arguments | Default | Description |
|
||||
| ------------------ | ------- | ------------------------- |
|
||||
| `<currentVersion>` | - | Version to be renamed. |
|
||||
| `<newVersion>` | - | Version to be renamed to. |
|
||||
|
||||
**Example**
|
||||
|
||||
```bash
|
||||
docusaurus-rename-version <currentVersion> <newVersion>
|
||||
```
|
||||
|
||||
See the [Versioning guide](guides-versioning.md#renaming-existing-versions) to learn more.
|
||||
|
||||
---
|
||||
|
||||
### `docusaurus-start`
|
||||
|
||||
Alias: `start`.
|
||||
|
||||
This command will build the static website, apply translations if necessary, and then start a local server.
|
||||
|
||||
| Options | Default | Description |
|
||||
| ----------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `--port <number>` | `3000` | The website will be served from port 3000 by default, but if the port is taken up, Docusaurus will attempt to find an available one. |
|
||||
| `--watch` | - | Whether to watch the files and live reload the page when files are changed. Defaults to true. Disable this by using `--no-watch`. |
|
||||
|
||||
You can specify the browser application to be opened by setting the `BROWSER` environment variable before the command, e.g.:
|
||||
|
||||
```
|
||||
$ BROWSER=firefox yarn start
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### `docusaurus-version <version>`
|
||||
|
||||
Alias: `version`
|
||||
|
||||
Generates a new version of the docs. This will result in a new copy of your site being generated and stored in its own versioned directory. Useful for capturing snapshots of API docs that map to specific versions of your software. Accepts any string as a version number.
|
||||
|
||||
See the [Versioning guide](guides-versioning.md) to learn more.
|
||||
|
||||
---
|
||||
|
||||
### `docusaurus-write-translations`
|
||||
|
||||
Alias: `write-translations`
|
||||
|
||||
Writes the English for any strings that need to be translated into an `website/i18n/en.json` file. The script will go through every file in `website/pages/en` and through the `siteConfig.js` file and other config files to fetch English strings that will then be translated on Crowdin. See the [Translation guide](guides-translation.md) to learn more.
|
213
v1/website/versioned_docs/version-1.5.1/api-doc-markdown.md
Normal file
213
v1/website/versioned_docs/version-1.5.1/api-doc-markdown.md
Normal file
|
@ -0,0 +1,213 @@
|
|||
---
|
||||
id: version-1.5.1-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>
|
||||
);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Adding Copy Code Buttons
|
||||
|
||||
Docusaurus allows for adding buttons to copy code within fenced code blocks. Please follow the instructions [here](https://gist.github.com/yangshun/55db997ed0f8f4e6527571fc3bee4675) to add "Copy" buttons to your code blocks.
|
410
v1/website/versioned_docs/version-1.5.1/api-site-config.md
Normal file
410
v1/website/versioned_docs/version-1.5.1/api-site-config.md
Normal file
|
@ -0,0 +1,410 @@
|
|||
---
|
||||
id: version-1.5.1-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` [string]
|
||||
|
||||
baseUrl for your site. This can also be considered the path after the host. For example, `/metro/` is the baseUrl 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` field](#url-string).
|
||||
|
||||
#### `colors` [object]
|
||||
|
||||
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` [string]
|
||||
|
||||
The copyright string at footer of site and within feed
|
||||
|
||||
#### `favicon` [string]
|
||||
|
||||
URL for site favicon.
|
||||
|
||||
#### `headerIcon` [string]
|
||||
|
||||
URL for icon used in header navigation bar.
|
||||
|
||||
#### `headerLinks` [array]
|
||||
|
||||
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]
|
||||
|
||||
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` [string]
|
||||
|
||||
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` [string]
|
||||
|
||||
Project name. This must match your GitHub repository project name (case-sensitive).
|
||||
|
||||
#### `tagline` [string]
|
||||
|
||||
Tagline for your website.
|
||||
|
||||
#### `title` [string]
|
||||
|
||||
Title for your website.
|
||||
|
||||
#### `url` [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` field](#baseurl-string).
|
||||
|
||||
### Optional Fields
|
||||
|
||||
#### `algolia` [object]
|
||||
|
||||
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` [number]
|
||||
|
||||
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` [string]
|
||||
|
||||
Control the title of the blog sidebar. See the [adding a blog docs](guides-blog.md#changing-the-sidebar-title) for more information.
|
||||
|
||||
#### `cleanUrl` [string]
|
||||
|
||||
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` [string]
|
||||
|
||||
The CNAME for your website. It will go into a `CNAME` file when your site is built.
|
||||
|
||||
#### `customDocsPath` [string]
|
||||
|
||||
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` [string]
|
||||
|
||||
The default version for the site to be shown. If this is not set, the latest version will be shown.
|
||||
|
||||
#### `disableHeaderTitle` [boolean]
|
||||
|
||||
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` [boolean]
|
||||
|
||||
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` [string]
|
||||
|
||||
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.
|
||||
|
||||
#### `enableUpdateBy` [boolean]
|
||||
|
||||
An option to enable the docs showing the author who last updated the doc. Set to `true` to show a line at the bottom right corner of each doc page as `Last updated by <Author Name>`.
|
||||
|
||||
#### `enableUpdateTime` [boolean]
|
||||
|
||||
An option to enable the docs showing last update time. Set to `true` to show a line at the bottom right corner of each doc page as `Last updated on <date>`.
|
||||
|
||||
#### `facebookAppId` [string]
|
||||
|
||||
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` [boolean]
|
||||
|
||||
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` [string]
|
||||
|
||||
[Facebook Pixel](https://www.facebook.com/business/a/facebook-pixel) ID to track page views.
|
||||
|
||||
#### `fonts` [object]
|
||||
|
||||
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` [string]
|
||||
|
||||
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` [string]
|
||||
|
||||
Google Analytics tracking ID to track page views.
|
||||
|
||||
#### `gaGtag` [boolean]
|
||||
|
||||
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` [string]
|
||||
|
||||
Hostname of your server. Useful if you are using GitHub Enterprise.
|
||||
|
||||
#### `highlight`
|
||||
|
||||
[Syntax highlighting](api-doc-markdown.md) options:
|
||||
|
||||
```js
|
||||
{
|
||||
// ...
|
||||
highlight: {
|
||||
// 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
|
||||
theme: 'default',
|
||||
|
||||
// The particular version of Highlight.js to be used.
|
||||
version: '9.12.0',
|
||||
|
||||
// Escape valve by passing an instance of Highlight.js to the function specified here, allowing additional languages to be registered for syntax highlighting.
|
||||
hljs: function(highlightJsInstance) {
|
||||
// do something here
|
||||
},
|
||||
|
||||
// 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
|
||||
|
||||
defaultLang: 'javascript',
|
||||
|
||||
// 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.
|
||||
themeUrl: 'http://foo.bar/custom.css'
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
#### `manifest` [string]
|
||||
|
||||
Path to your web app manifest (e.g., `manifest.json`). This will add a `<link>` tag to `<head>` with `rel` as `"manifest"` and `href` as the provided path.
|
||||
|
||||
#### `markdownPlugins` [array]
|
||||
|
||||
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` [string]
|
||||
|
||||
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` [string]
|
||||
|
||||
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]
|
||||
|
||||
Array of JavaScript sources to load. The values can be either strings or plain objects of attribute-value maps. Refer to the example below. The script tag will be inserted in the HTML head.
|
||||
|
||||
#### `separateCss` [string]
|
||||
|
||||
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` [boolean]
|
||||
|
||||
Set this to `true` if you want to enable the scroll to top button at the bottom of your site.
|
||||
|
||||
#### `scrollToTopOptions` [object]
|
||||
|
||||
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]
|
||||
|
||||
Array of CSS sources to load. The values can be either strings or plain objects of attribute-value maps. The link tag will be inserted in the HTML head.
|
||||
|
||||
#### `translationRecruitingLink` [string]
|
||||
|
||||
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` [boolean]
|
||||
|
||||
Set this to `true` if you want a Twitter social button to appear at the bottom of your blog posts.
|
||||
|
||||
#### `twitterUsername` [string]
|
||||
|
||||
If you want a Twitter follow button at the bottom of your page, provide a Twitter username to follow. For example: `docusaurus`.
|
||||
|
||||
#### `twitterImage` [string]
|
||||
|
||||
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` [string]
|
||||
|
||||
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` [array]
|
||||
|
||||
The `users` array mentioned earlier.
|
||||
|
||||
#### `usePrism` [array]
|
||||
|
||||
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]
|
||||
|
||||
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',
|
||||
{
|
||||
src:
|
||||
'https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js',
|
||||
async: true,
|
||||
},
|
||||
],
|
||||
stylesheets: [
|
||||
'https://docusaurus.io/style.css',
|
||||
{
|
||||
href: 'http://css.link',
|
||||
type: 'text/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,234 @@
|
|||
---
|
||||
id: version-1.5.1-publishing
|
||||
title: Publishing your site
|
||||
original_id: publishing
|
||||
---
|
||||
|
||||
You should now have a [site up and running locally](getting-started-site-creation.md). Once you have [customized](api-site-config.md) it to your liking, it's time to publish it. Docusaurus generates a static HTML website that is ready to be served by your favorite web server or online hosting solution.
|
||||
|
||||
## Building Static HTML Pages
|
||||
|
||||
To create a static build of your website, run the following script from the `website` directory:
|
||||
|
||||
```bash
|
||||
yarn run build # or `npm run build`
|
||||
```
|
||||
|
||||
This will generate a `build` directory inside the `website` directory containing the `.html` files from all of your docs and other pages included in `pages`.
|
||||
|
||||
## Hosting Static HTML Pages
|
||||
|
||||
At this point, you can grab all of the files inside the `website/build` directory and copy them over to your favorite web server's `html` directory.
|
||||
|
||||
> For example, both Apache and nginx serve content from `/var/www/html` by default. That said, choosing a web server or provider is outside the scope of Docusaurus.
|
||||
|
||||
> When serving the site from your own web server, ensure the web server is serving the asset files with the proper HTTP headers. CSS files should be served with the `content-type` header of `text/css`. In the case of nginx, this would mean setting `include /etc/nginx/mime.types;` in your `nginx.conf` file. See [this issue](https://github.com/facebook/Docusaurus/issues/602) for more info.
|
||||
|
||||
### Hosting on a Service:
|
||||
|
||||
* [GitHub Pages](#using-github-pages)
|
||||
* [Netlify](#hosting-on-netlify)
|
||||
|
||||
### Using GitHub Pages
|
||||
|
||||
Docusaurus was designed to work really well with one of the most popular hosting solutions for open source projects: [GitHub Pages](https://pages.github.com/).
|
||||
|
||||
#### Deploying to GitHub Pages
|
||||
|
||||
1. Docusaurus supports deploying as [project pages or user/organization pages](https://help.github.com/articles/user-organization-and-project-pages), your code repository does not even need to be public.
|
||||
|
||||
> Even if your repository is private, anything published to a `gh-pages` branch will be [public](https://help.github.com/articles/user-organization-and-project-pages/).
|
||||
|
||||
__Note:__ When you deploy as user/organization page, the publish script will deploy these sites to the root of the __`master`__ branch of the _username_.github.io repo. In this case, note that you will want to have the Docusaurus infra, your docs, etc. either in __another branch of the _username_.github.io repo__ (e.g., maybe call it `source`), or in another, separate repo (e.g. in the same as the documented source code).
|
||||
|
||||
2. You will need to modify the file `website/siteConfig.js` and add the required parameters.
|
||||
|
||||
| Name | Description |
|
||||
| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `organizationName` | The GitHub user or organization that owns the repository. If you are the owner, then it is your GitHub username. In the case of Docusaurus, that would be the "_facebook_" GitHub organization. |
|
||||
| `projectName` | The name of the GitHub repository for your project. For example, the source code for Docusaurus is hosted at https://github.com/facebook/docusaurus, so our project name in this case would be "docusaurus". |
|
||||
| `url` | Your website's URL. For projects hosted on GitHub pages, this will be "https://_username_.github.io" |
|
||||
| `baseUrl` | Base URL for your project. For projects hosted on GitHub pages, it follows the format "/_projectName_/". For https://github.com/facebook/docusaurus, `baseUrl` is `/docusaurus/`. |
|
||||
|
||||
|
||||
```js
|
||||
const siteConfig = {
|
||||
...
|
||||
url: 'https://__userName__.github.io', // Your website URL
|
||||
baseUrl: '/testProject',
|
||||
projectName: 'testProject',
|
||||
organizationName: 'userName'
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
In case you want to deploy as a user or organization site, specify the project name as "<username>.github.io" or "<orgname>.github.io". E.g. If your GitHub username is "user42" then _user42.github.io_, or in the case of an organization name of "org123", it will be _org123.github.io_.
|
||||
|
||||
__Note:__ Not setting the `url` and `baseUrl` of your project might result in incorrect file paths generated which can cause broken links to assets paths like stylesheets and images.
|
||||
|
||||
> While we recommend setting the `projectName` and `organizationName` in `siteConfig.js`, you can also use environment variables `ORGANIZATION_NAME` and `PROJECT_NAME`.
|
||||
|
||||
3. Now you have to specify the git user as an environment variable, and run the script [`publish-gh-pages`](./api-commands.md#docusaurus-publish)
|
||||
|
||||
| Name | Description |
|
||||
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
||||
| `GIT_USER` | The username for a GitHub account that has commit access to this repo. For your own repositories, this will usually be your own GitHub username. The specified `GIT_USER` must have push access to the repository specified in the combination of `organizationName` and `projectName`. |
|
||||
|
||||
To run the script directly from the command-line, you can use the following, filling in the parameter values as appropriate.
|
||||
|
||||
```bash
|
||||
GIT_USER=<GIT_USER> \
|
||||
CURRENT_BRANCH=master \
|
||||
USE_SSH=true \
|
||||
yarn run publish-gh-pages # or `npm run publish-gh-pages`
|
||||
```
|
||||
|
||||
There are also two optional parameters that are set as environment variables:
|
||||
|
||||
| Name | Description |
|
||||
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| `USE_SSH` | If this is set to `true`, then SSH is used instead of HTTPS for the connection to the GitHub repo. HTTPS is the default if this variable is not set. |
|
||||
| `CURRENT_BRANCH` | The branch that contains the latest docs changes that will be deployed. Usually, the branch will be `master`, but it could be any branch (default or otherwise) except for `gh-pages`. If nothing is set for this variable, then the current branch will be used. |
|
||||
|
||||
If you run into issues related to SSH keys, visit [GitHub's authentication documentation](https://help.github.com/articles/connecting-to-github-with-ssh/).
|
||||
|
||||
You should now be able to load your website by visiting its GitHub Pages URL, which could be something along the lines of https://_username_.github.io/_projectName_, or a custom domain if you have set that up. For example, Docusaurus' own GitHub Pages URL is https://facebook.github.io/Docusaurus (but it can also be accessed via https://docusaurus.io/ because of a CNAME), because it is served from the `gh-pages` branch of the https://github.com/facebook/docusaurus GitHub repository. We highly encourage reading through the [GitHub Pages documentation](https://pages.github.com) to learn more about how this hosting solution works.
|
||||
|
||||
You can run the command above any time you update the docs and wish to deploy the changes to your site. Running the script manually may be fine for sites where the documentation rarely changes and it is not too much of an inconvenience to remember to manually deploy changes.
|
||||
|
||||
However, you can automate the publishing process with continuous integration (CI).
|
||||
|
||||
## Automating Deployments Using Continuous Integration
|
||||
|
||||
Continuous integration (CI) services are typically used to perform routine tasks whenever new commits are checked in to source control. These tasks can be any combination of running unit tests and integration tests, automating builds, publishing packages to NPM, and yes, deploying changes to your website. All you need to do to automate deployment of your website is to invoke the `publish-gh-pages` script whenever your docs get updated. In the following section we'll be covering how to do just that using [Circle CI](https://circleci.com/), a popular continuous integration service provider.
|
||||
|
||||
### Using Circle CI 2.0
|
||||
|
||||
If you haven't done so already, you can [setup CircleCI](https://circleci.com/signup/) for your open source project. Afterwards, in order to enable automatic deployment of your site and documentation via CircleCI, just configure Circle to run the `publish-gh-pages` script as part of the deployment step. You can follow the steps below to get that setup.
|
||||
|
||||
1. Ensure the GitHub account that will be set as the `GIT_USER` has `write` access to the repository that contains the documentation, by checking `Settings | Collaborators & teams` in the repository.
|
||||
1. Log into GitHub as the `GIT_USER`.
|
||||
1. Go to https://github.com/settings/tokens for the `GIT_USER` and generate a new [personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/), granting it full control of private repositories through the `repository` access scope. Store this token in a safe place, making sure to not share it with anyone. This token can be used to authenticate GitHub actions on your behalf in place of your GitHub password.
|
||||
1. Open your Circle CI dashboard, and navigate to the Settings page for your repository, then select "Environment variables". The URL looks like https://circleci.com/gh/ORG/REPO/edit#env-vars, where "ORG/REPO" should be replaced with your own GitHub organization/repository.
|
||||
1. Create a new environment variable named `GITHUB_TOKEN`, using your newly generated access token as the value.
|
||||
1. Create a `.circleci` directory and create a `config.yml` under that directory.
|
||||
1. Copy the text below into `.circleci/config.yml`.
|
||||
|
||||
```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
|
||||
cd website && yarn install && GIT_USER=<GIT_USER> yarn run publish-gh-pages
|
||||
|
||||
workflows:
|
||||
version: 2
|
||||
build_and_deploy:
|
||||
jobs:
|
||||
- deploy-website:
|
||||
# filters: *filter-only-master
|
||||
```
|
||||
|
||||
Make sure to replace all `<....>` in the `command:` sequence with appropriate values. For `<GIT_USER>`, it should be a GitHub account that has access to push documentation to your GitHub repository. Many times `<GIT_USER>` and `<GITHUB_USERNAME>` will be the same.
|
||||
|
||||
**DO NOT** place the actual value of `$GITHUB_TOKEN` in `circle.yml`. We already configured that as an environment variable back in Step 3.
|
||||
|
||||
> If you want to use SSH for your GitHub repository connection, you can set `USE_SSH=true`. So the above command would look something like: `cd website && npm install && GIT_USER=<GIT_USER> USE_SSH=true npm run publish-gh-pages`.
|
||||
|
||||
> Unlike when you run the `publish-gh-pages` script manually, when the script runs within the Circle environment, the value of `CURRENT_BRANCH` is already defined as an [environment variable within CircleCI](https://circleci.com/docs/1.0/environment-variables/) and will be picked up by the script automatically.
|
||||
|
||||
Now, whenever a new commit lands in `master`, CircleCI will run your suite of tests and, if everything passes, your website will be deployed via the `publish-gh-pages` script.
|
||||
|
||||
> If you would rather use a deploy key instead of a personal access token, you can by starting with the Circle CI [instructions](https://circleci.com/docs/1.0/adding-read-write-deployment-key/) for adding a read/write deploy key.
|
||||
|
||||
### Tips & Tricks
|
||||
|
||||
When initially deploying to a `gh-pages` branch using Circle CI, you may notice that some jobs triggered by commits to the `gh-pages` branch fail to run successfully due to a lack of tests. You can easily work around this by creating a basic Circle CI config with the following contents:
|
||||
|
||||
```yaml
|
||||
# Circle CI 2.0 Config File
|
||||
# This config file will prevent tests from being run on the gh-pages branch.
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
machine: true
|
||||
branches:
|
||||
ignore: gh-pages
|
||||
steps:
|
||||
- run: echo "Skipping tests on gh-pages branch"
|
||||
```
|
||||
|
||||
Save this file as `config.yml` and place it in a `.circleci` directory inside your `website/static` directory.
|
||||
|
||||
### Using Travis CI
|
||||
|
||||
1. Go to https://github.com/settings/tokens and generate a new [personal access token](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/)
|
||||
1. Using your GitHub account, [add the Travis CI app](https://github.com/marketplace/travis-ci) to the repository you want to activate.
|
||||
1. Open your Travis CI dashboard. The URL looks like https://travis-ci.com/USERNAME/REPO, and navigate to the `More options` > `Setting` > `Environment Variables` section of your repository.
|
||||
1. Create a new environment variable named `GH_TOKEN` with your newly generated token as its value, then `GH_EMAIL` (your email address) and `GH_NAME` (your GitHub username).
|
||||
1. Create a `.travis.yml` on the root of your repository with below text.
|
||||
|
||||
```yaml
|
||||
# .travis.yml
|
||||
language: node_js
|
||||
node_js:
|
||||
- '8'
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
cache:
|
||||
yarn: true
|
||||
script:
|
||||
- git config --global user.name "${GH_NAME}"
|
||||
- git config --global user.email "${GH_EMAIL}"
|
||||
- echo "machine github.com login ${GH_NAME} password ${GH_TOKEN}" > ~/.netrc
|
||||
- cd website && yarn install && GIT_USER="${GH_NAME}" yarn run publish-gh-pages
|
||||
```
|
||||
|
||||
Now, whenever a new commit lands in `master`, Travis CI will run your suite of tests and, if everything passes, your website will be deployed via the `publish-gh-pages` script.
|
||||
|
||||
### Hosting on Netlify
|
||||
|
||||
Steps to configure your Docusaurus-powered site on Netlify.
|
||||
|
||||
1. Select **New site from Git**
|
||||
1. Connect to your preferred Git provider.
|
||||
1. Select the branch to deploy. Default is `master`
|
||||
1. Configure your build steps:
|
||||
|
||||
* For your build command enter: `cd website; npm install; npm run build;`
|
||||
* For publish directory: `website/build/<projectName>` (use the `projectName` from your `siteConfig`)
|
||||
|
||||
1. Click **Deploy site**
|
||||
|
||||
You can also configure Netlify to rebuild on every commit to your repository, or only `master` branch commits.
|
||||
|
||||
### Publishing to GitHub Enterprise
|
||||
|
||||
GitHub enterprise installations should work in the same manner as github.com; you only need to identify the organization's GitHub Enterprise host.
|
||||
|
||||
| Name | Description |
|
||||
| ------------- | ---------------------------------------------- |
|
||||
| `GITHUB_HOST` | The hostname for the GitHub enterprise server. |
|
||||
|
||||
Alter your `siteConfig.js` to add a property `'githubHost'` which represents the GitHub Enterprise hostname. Alternatively, set an environment variable `GITHUB_HOST` when executing the publish command.
|
|
@ -0,0 +1,95 @@
|
|||
---
|
||||
id: version-1.5.1-site-creation
|
||||
title: Creating your site
|
||||
original_id: site-creation
|
||||
---
|
||||
|
||||
Docusaurus was created to hopefully make it super simple for you to create a site and documentation for your open source project.
|
||||
|
||||
After [installation](getting-started-installation.md) and [preparation](getting-started-preparation.md), much of the work to create a basic site for your docs is already complete.
|
||||
|
||||
## Site Structure
|
||||
|
||||
Your site structure looks like the following:
|
||||
|
||||
```bash
|
||||
root-directory
|
||||
├── docs
|
||||
└── website
|
||||
├── blog
|
||||
├── core
|
||||
│ └── Footer.js
|
||||
├── package.json
|
||||
├── pages
|
||||
├── sidebars.json
|
||||
├── siteConfig.js
|
||||
└── static
|
||||
```
|
||||
|
||||
> This assumes that you removed the example `.md` files that were installed with the [initialization](getting-started-installation.md) script.
|
||||
|
||||
All of your documentation files should be placed inside the `docs` directory as markdown `.md` files. Any blog posts should be inside the `blog` directory.
|
||||
|
||||
> The blog posts must be formatted as `YYYY-MM-DD-your-file-name.md`
|
||||
|
||||
## Create Your Basic Site
|
||||
|
||||
To create a fully functional site, you only need to do a few steps:
|
||||
|
||||
1. Add your documentation to the `/docs` directory as `.md` files, ensuring you have the proper [header](api-doc-markdown.md#documents) in each file. The simplest header would be the following, where `id` is the link name (e.g., `docs/intro.html`) and the `title` is the webpage's title.
|
||||
|
||||
```yaml
|
||||
---
|
||||
id: intro
|
||||
title: Getting Started
|
||||
---
|
||||
|
||||
My new content here..
|
||||
```
|
||||
|
||||
1. Add zero or more docs to the [`sidebars.json`](guides-navigation.md#adding-docs-to-a-sidebar) file so that your documentation is rendered in a sidebar, if you choose them to be.
|
||||
|
||||
> If you do not add your documentation to the `sidebars.json` file, the docs will be rendered, but they can only be linked to from other documentation and visited with the known URL.
|
||||
|
||||
3. Modify the `website/siteConfig.js` file to [configure your site](api-site-config.md), following the comments included in the [docs](api-site-config.md) and the `website/siteConfig.js` to guide you.
|
||||
1. Create any [custom pages](guides-custom-pages.md#customizing-your-site-footer) and/or [customize](guides-custom-pages.md#customizing-your-site-footer) the `website/core/Footer.js` file that provides the footer for your site.
|
||||
1. Place assets, such as images, in the `website/static/` directory.
|
||||
1. Run the site to see the results of your changes.
|
||||
|
||||
```bash
|
||||
cd website
|
||||
yarn run start # or `npm run start`
|
||||
# Navigate to http://localhost:3000
|
||||
```
|
||||
|
||||
## Special Customization
|
||||
|
||||
### Docs Landing Page
|
||||
|
||||
If you prefer to have your landing page be straight to your documentation, you can do this through a redirect.
|
||||
|
||||
1. Remove the `index.js` file from the `website/pages` directory, if it exists.
|
||||
1. Add a [custom static `index.html` page](guides-custom-pages.md#adding-static-pages) in the `website/static` directory with the following contents:
|
||||
|
||||
```html
|
||||
<!DOCTYPE HTML>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="refresh" content="0; url=docs/id-of-doc-to-land-on.html">
|
||||
<script type="text/javascript">
|
||||
window.location.href = 'docs/id-of-doc-to-land-on.html';
|
||||
</script>
|
||||
<title>Your Site Title Here</title>
|
||||
</head>
|
||||
<body>
|
||||
If you are not redirected automatically, follow this <a href="docs/id-of-doc-to-land-on.html">link</a>.
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
||||
> You will get the `id` of the document to land on the `.md` metadata of that doc page.
|
||||
|
||||
### Blog Only
|
||||
|
||||
You can also use Docusaurus to host your [blog only](guides-blog.md#i-want-to-run-in-blog-only-mode).
|
|
@ -1,4 +1,5 @@
|
|||
[
|
||||
"1.5.1",
|
||||
"1.5.0",
|
||||
"1.4.0",
|
||||
"1.3.3",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue