Publish v1.5.0 (#1030)

* v1.5.0

* Add version 1.5.0
This commit is contained in:
Yangshun Tay 2018-10-13 12:17:26 -07:00 committed by GitHub
parent 76e2d3bf17
commit f22aa221f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 809 additions and 13 deletions

View file

@ -0,0 +1,356 @@
---
id: version-1.5.0-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. For example, `/pages/org/project/` is the baseUrl of https://git.facebook.com/pages/org/project/
#### `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.
### 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.
#### `enableUpdateTime` [string]
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: dd/mm/yyyy hh:MM:ss Z`.
#### `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 `content` 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;
```

View file

@ -0,0 +1,119 @@
---
id: version-1.5.0-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 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.
![](/img/getting-started-preparation-verify.png)
### 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.

View file

@ -0,0 +1,275 @@
---
id: version-1.5.0-navigation
title: Navigation and Sidebars
original_id: navigation
---
## Referencing Site Documents
If you want to reference another document in your `docs` directory (or the location you set via the [optional `customDocsPath`](https://docusaurus.io/docs/en/site-config.html#optional-fields) path site configuration option), then you just use the name of the document you want to reference.
For example, if you are in `doc2.md` and you want to reference `doc1.md`:
```md
I am referencing a [document](doc1.md).
```
## How Documents are Linked
New markdown files within `docs` will show up as pages on the website. Links to those documents are created first by using the `id` in the header of each document. If there is no `id` field, then the name of the file will serve as the link name.
For example, creating an empty file such as `docs/getting-started.md` will enable the new page URL as `/docs/getting-started.html`.
Suppose you add this to your document:
```yaml
id: intro
title: Getting Started
---
My new content here..
```
If you set the `id` field in the markdown header of the file, the doc will then be accessed from a URL of the form `/docs/intro.html`.
> You need an `id` field to be able to add the document to the sidebar.
## Adding Documents to a Sidebar
Many times, you will want to add a document to a sidebar that will be associated with one of the headers in the top navigation bar of the website. The most common sidebar, and the one that comes installed when Docusaurus is initialized, is the `docs` sidebar.
> "docs" is just a name. It has no inherent meaning. You can change it as you wish.
You configure the contents of the sidebar, and the order of its documents, in the `website/sidebars.json` file.
> Until you add your document to `website/sidebars.json`, they will only be accessible via a direct URL. The doc will not show up in any sidebar.
Within `sidebars.json`, add the `id` you used in the document header to existing sidebar/category. In the below case, `docs` is the name of the sidebar and `Getting Started` is a category within the sidebar.
```js
{
"docs": {
"Getting Started": [
"getting-started"
],
...
},
...
}
```
Or you can create a new category within the sidebar:
```js
{
"docs": {
"My New Sidebar Category": [
"getting-started"
],
...
},
...
}
```
However, for a document located in a docs subdirectory like below:
```bash
docs
└── dir1
└── getting-started.md
```
You should provide `directory/id` instead of `id` in `sidebars.json`.
```js
{
"docs": {
"My New Sidebar Category": [
"dir1/getting-started"
],
...
},
...
}
```
### Adding Subcategories
It is possible to add subcategories to a sidebar. Instead of using IDs as the contents of the category array like the previous examples, you can pass an object where the keys will be the subcategory name and the value an array of IDs for that subcategory.
```js
{
"docs": {
"My Example Category": [
"examples",
{
"type": "subcategory",
"label": "My Example Subcategory",
"ids": [
"my-examples",
...
]
},
{
"type": "subcategory",
"label": "My Next Subcategory",
"ids": [
"some-other-examples"
]
},
"even-more-examples",
...
],
...
}
}
/*
The above will generate:
- My Example Category
- examples
- My Example Subcategory
- my-examples
...
- My Next Subcategory
- some-other-examples
- even-more-examples
...
*/
```
### Adding New Sidebars
You can also put a document in a new sidebar. In the following example, we are creating an `examples-sidebar` sidebar within `sidebars.json` that has a category called `My Example Category` containing a document with an `id` of `my-examples`.
```js
{
"examples-sidebar": {
"My Example Category": [
"my-examples"
],
...
},
...
}
```
It is important to note that until you [add a document from the `"examples-sidebar"` sidebar to the nav bar](#additions-to-the-site-navigation-bar), it will be hidden.
## Additions to the Site Navigation Bar
To expose sidebars, you will add click-able labels to the site navigation bar at the top of the website. You can add documents, pages and external links.
### Adding Documents
After creating a new sidebar for the site by [adding](#adding-new-sidebars) it to `sidebars.json`, you can expose the new sidebar from the top navigation bar by editing the `headerLinks` field of `siteConfig.js`.
```js
{
headerLinks: [
...
{ doc: 'my-examples', label: 'Examples' },
...
],
...
}
```
A label called `Examples` will be added to the site navigation bar and when you click on it at the top of your site, the `examples-sidebar` will be shown and the default document will be `my-examples`.
### Adding Custom Pages
To add custom pages to the site navigation bar, entries can be added to the `headerLinks` of `siteConfig.js`. For example, if we have a page within `website/pages/help.js`, we can link to it by adding the following:
```js
{
headerLinks: [
...
{ page: 'help', label: 'Help' },
...
],
...
}
```
A label called `Help` will be added to the site navigation bar and when you click on it at the top of your site, the content from the `help.js` page will be shown.
### Adding External Links
Custom links can be added to the site navigation bar with the following entry in `siteConfig.js`:
```js
{
headerLinks: [
...
{ href: 'https://github.com/facebook/Docusaurus', label: 'GitHub' },
...
],
...
}
```
A label called `GitHub` will be added to the site navigation bar and when you click on it at the top of your site, the content of the external link will be shown.
> To open external links in a new tab, provide an `external: true` flag within the header link config.
## Site Navigation Bar Positioning
You have limited control where the search and languages dropdown elements are shown in the site navigation bar at the top of your website.
### Search
If search is enabled on your site, your search bar will appear to the right of your links. If you want to put the search bar between links in the header, add a search entry in the `headerLinks` config array:
```js
{
headerLinks: [
{ doc: 'foo', label: 'Foo' },
{ search: true },
{ doc: 'bar', label: 'Bar' },
],
...
}
```
### Languages Dropdown
If translations is enabled on your site, the language dropdown will appear to the right of your links (and to the left of the search bar, if search is enabled). If you want to put the language selection drop down between links in the header, add a languages entry in the `headerLinks` config array:
```js
{
headerLinks: [
{ doc: 'foo', label: 'Foo' },
{ languages: true },
{ doc: 'bar', label: 'Bar' },
],
...
}
```
## Active Links In Site Navigation Bar
The links in the top navigation bar get `siteNavItemActive` and `siteNavGroupActive` class names to allow you to style the currently active link different from the others. `siteNavItemActive` is applied when there's an exact match between the navigation link and the currently displayed web page.
> This does not include links of type `href` which are meant for external links only. If you manually set an `href` in your `headerLinks` to an internal page, document, or blog post, it will not get the `siteNavItemActive` class even if that page is being displayed.
The `siteNavGroupActive` class will be added to these links:
- `doc` links that belong to the same sidebar as the currently displayed document
- The blog link when a blog post, or the blog listing page is being displayed
These are two separate class names so you can have the active styles applied to either exact matches only or a bit more broadly for docs that belong together. If you don't want to make this distinction you can add both classes to the same CSS rule.
## Secondary On-Page Navigation
We support secondary on-page navigation so you can more easily see the topics associated with a given document. To enable this feature, you need to add the `onPageNav` site configuration [option](api-site-config.md#optional-fields) to your `siteConfig.js`.
```js
{
onPageNav: 'separate',
...
}
```
Currently, `'separate'` is the only option available for this field. This provides a separate navigation on the right side of the page.