diff --git a/CHANGELOG.md b/CHANGELOG.md index a167d780f525..6d155aef8558 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,43 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [1.0.12] - 2018-04-18 + +This is a general release with additions and documentation updates. We would also like to welcome [React Native Elements](https://react-native-training.github.io/react-native-elements/) as a user of Docusaurus. + +https://docusaurus.io has turned on versioning. There are other documentation updates as well. + +> We turned on translations, but found a bug. So we turned it off until we fix it. + +Thank you to the following contributors who helped with this release: + +- @yangshun +- @amyrlam +- @SleepWalker +- @InternetExplorer7 +- @zkochan +- @iRoachie +- @limonte + +### Breaking changes + +- While not officially breaking, `authorImage` will be [deprecated](https://github.com/facebook/Docusaurus/pull/577) for [`authorImageURL`](https://github.com/facebook/Docusaurus/commit/57cddb4d0897e7d9a62305c6b2b8a04e824e0941) in blog posts. + +### Added + +- [`twitterImage`](https://github.com/facebook/Docusaurus/commit/e738bbd99e80596f7280c2a131600600c083fc68) has been added to site configuration options for use in Twitter cards. +- Support for [non-latin characters](https://github.com/facebook/Docusaurus/commit/1642c078a723487d922b80f6d112c989b98e8bd3) have been added in heading anchors. +- [``](https://github.com/facebook/Docusaurus/commit/946e2cef907a37290bfdf831dedc072de596f927) has been added to all HTML pages. +- `cssnano` is used to [minify](https://github.com/facebook/Docusaurus/commit/159b80df942ba4d7c422ecb6d4b57aa34fd7b5e3) the main CSS file. + +### Fixed/Changed + +- [Search bar width in mobile navigation](https://github.com/facebook/Docusaurus/commit/ba024a25c7cf37cdaecafb8d805a49505f461785). + +### Removed + +N/A + ## [1.0.11] - 2018-04-12 This is a general release with additions and documentation updates (which are already live on docusaurus.io). We would also like to welcome [BlueWhale](https://facebookresearch.github.io/BlueWhale) as a new user of Docusaurus. @@ -232,7 +269,8 @@ N/A - Blog - Documentation -[Unreleased]: https://github.com/facebook/Docusaurus/compare/v1.0.11...HEAD +[Unreleased]: https://github.com/facebook/Docusaurus/compare/v1.0.12...HEAD +[1.0.12]: https://github.com/facebook/Docusaurus/compare/v1.0.11...v1.0.12 [1.0.11]: https://github.com/facebook/Docusaurus/compare/v1.0.10...v1.0.11 [1.0.10]: https://github.com/facebook/Docusaurus/compare/v1.0.9...v1.0.10 [1.0.9]: https://github.com/facebook/Docusaurus/compare/v1.0.8...v1.0.9 diff --git a/package-lock.json b/package-lock.json index 118e6bd77bd4..233d4f7dfdb9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "docusaurus", - "version": "1.0.11", + "version": "1.0.12", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 8cc4ebe948cc..57dc92077189 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "docusaurus", "description": "Easy to Maintain Open Source Documentation Websites", - "version": "1.0.11", + "version": "1.0.12", "license": "MIT", "keywords": [ "documentation", diff --git a/website/versioned_docs/version-1.0.12/api-pages.md b/website/versioned_docs/version-1.0.12/api-pages.md new file mode 100644 index 000000000000..c381e49eeb39 --- /dev/null +++ b/website/versioned_docs/version-1.0.12/api-pages.md @@ -0,0 +1,157 @@ +--- +id: version-1.0.12-api-pages +title: Pages and Styles +original_id: api-pages +--- + +Docusaurus provides support for writing pages as React components inside the `website/pages` folder which will share the same header, footer, and styles as the rest of the site. + +## Urls for Pages + +Any `.js` files in `website/pages` will be rendered to static html using the path of the file after "pages". Files in `website/pages/en` will also get copied out into `pages` and will OVERRIDE any files of the same name in `pages`. For example, the page for the `website/pages/en/help.js` file will be found at the url `${baseUrl}en/help.js` as well as the url `${baseUrl}help.js`, where `${baseUrl}` is the `baseUrl` field set in your [siteConfig.js file](api-site-config.md). + +## Page Require Paths + +Docusaurus provides a few useful React components for users to write their own pages, found in the `CompLibrary` module. This module is provided as part of Docusaurus in `node_modules/docusaurus`, so to access it, pages in the `pages` folder are temporarily copied into `node_modules/docusaurus` when rendering to static html. As seen in the example files, this means that a user page at `pages/en/index.js` uses a require path to `"../../core/CompLibrary.js"` to import the provided components. + +What this means to the user is that if you wish to use the `CompLibrary` module, make sure the require path is set correctly. For example, a page at `page/mypage.js` would use a path `"../core/CompLibrary.js"`. + +If you wish to use your own components inside the website folder, use `process.cwd()` which will refer to the `website` folder to construct require paths. For example, if you add a component to `website/core/mycomponent.js`, you can use the require path, `"process.cwd() + /core/mycomponent.js"`. + +## Provided Components + +Docusaurus provides the following components in `CompLibrary`: + +### `CompLibrary.MarkdownBlock` + +A React component that parses markdown and renders to HTML. + +Example: + +```jsx +const MarkdownBlock = CompLibrary.MarkdownBlock; + + + [Markdown syntax for a link](http://www.example.com) +; +``` + +### `CompLibrary.Container` + +A React container component using Docusaurus styles. Has optional padding and background color props that you can configure. + +**Props** + +| Prop | Type | Default | Description | +| --- | --- | --- | --- | +| `padding` | Array of `'all'`, `'bottom'`, `'left'`, `'right'`, `'top'` | `[]` | Positions of the padding. | +| `background` | One of `'dark'`, `'highlight'`, `'light'` | `null` | Background styling of the element. | +| `className` | String | - | Custom class to add to the element. | + +**Example** + +```jsx + + ... + +``` + +### `CompLibrary.GridBlock` + +A React component to organize text and images. + +**Props** + +| Prop | Type | Default | Description | +| --- | --- | --- | --- | +| `align` | One of `'left'`, `'center'`, `'right'` | `'left'` | Text alignment of content. | +| `layout` | One of `'twoColumn'`, `'threeColumn'`, `'fourColumn'` | `'twoColumn'` | Number of column sections in the `GridBlock`. | +| `className` | String | - | Custom class to add to the element. | +| `contents` | Array of content objects | `[]` | Contents of each section of the GridBlock. Refer to the next table for the fields available on a content object. | + +**Content Object** + +| Key | Type | Default | Description | +| --- | --- | --- | --- | +| `title` | String | - | The display title of this section, which is parsed using Markdown | +| `content` | String | - | The text of this section, which is parsed using Markdown | +| `image` | String | - | The path of the display image | +| `imageAlt` | String | - | The text that will be shown in case the image is not available | +| `imageAlign` | One of `'top'`, `'left'`, `'bottom'`, `'right'` | `'left'` | Image alignment relative to the text | +| `imageLink` | String | - | Link destination from clicking the image | + +**Example** + +``` + +``` + +More examples of how these components are used can be found in the [generated example files](getting-started-preparation.md) as well as in Docusaurus' own repo for its website set-up. + +## Translating Strings + +When translations are enabled, any pages inside `website/pages/en` will be translated for all enabled languages. Urls for non-English pages will use their language tags as specified in the `languages.js` file. E.g. The url for a French page of `website/pages/en/help.js` would be found at `${baseUrl}fr/help.html`. + +When writing pages that you wish to translate, wrap any strings to be translated inside a `` tag. e.g., + +```jsx +

+ I like translations +

+``` + +You can also provide an optional description attribute to provide context for translators. e.g, + +```jsx + + + Community + + +``` + +Add the following require statement as well: + +```js +const translate = require('../../server/translate.js').translate; +``` + +Note that this path is valid for files inside `pages/en` and should be adjusted accordingly if files are in different locations, as discussed [above](#page-require-paths). + +## Using Static Assets + +Static assets should be placed into the `website/static` folder. They can be accessed by their paths, excluding "static". For example, if the site's `baseUrl` is "/docusaurus/", an image in `website/static/img/logo.png` is available at `/docusaurus/img/logo.png`. + +## Styles + +You should configure your site's primary, secondary, and code block colors using the `colors` field in `siteConfig` as specified [here](api-site-config.md). You can also configure other colors in the same way as described in the `siteConfig` doc. + +You can provide your own custom styles by adding them anywhere in the `website/static` folder. Any `.css` files you provide in the `static` folder will get concatenated to the end of Docusaurus' provided styles, allowing you to add to or override Docusaurus default styles as you wish. + +An easy way to figure out what classes you wish to override or add to is to [start your server locally](api-commands.md) and use your browser's inspect element tool. diff --git a/website/versioned_docs/version-1.0.12/api-site-config.md b/website/versioned_docs/version-1.0.12/api-site-config.md new file mode 100644 index 000000000000..9fad8f6c44e3 --- /dev/null +++ b/website/versioned_docs/version-1.0.12/api-site-config.md @@ -0,0 +1,233 @@ +--- +id: version-1.0.12-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. + +`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 repo project name (case sensitive). + +`tagline` - Tagline for your website. + +`title` - Title for your website. + +`url` - url for your site. + +### 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. + +`cname` - The CNAME for your website. It will go into a `CNAME` file when your site it 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. **Note that all of your documentation `*.md` files must still reside in a flat hierarchy. You cannot have your documents in nested directories**. + +```js +customDocsPath: "docs/site" +``` + +```js +customDocsPath: "website-docs" +``` +`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 at the bottom of your blog posts, provide a [Facebook application id](https://www.facebook.com/help/audiencenetwork/804209223039296), and the buttons will show up on all blog posts. + +`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`. + +``` +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`. + +``` +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. + +`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). + +`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` - Folders 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. + +`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. + +`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. + +`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 + +``` +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/", + 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: "U-A2352", + highlight: { + theme: 'default' + }, + markdownPlugins: [ + function foo(md) { + md.renderer.rules.fence_custom.foo = function(tokens, idx, options, env, instance) { + return '
bar
'; + } + } + ], + scripts: [ "https://docusaurus.io/slash.js" ], + stylesheets: [ "https://docusaurus.io/style.css" ], + facebookAppId: "1615782811974223", + facebookPixelId: "352490515235776", + twitter: "true", + twitterImage: "img/docusaurus.png", + ogImage: "img/docusaurus.png", +}; + +module.exports = siteConfig; +``` diff --git a/website/versioned_docs/version-1.0.12/getting-started-publishing.md b/website/versioned_docs/version-1.0.12/getting-started-publishing.md new file mode 100644 index 000000000000..1c5e6f38179e --- /dev/null +++ b/website/versioned_docs/version-1.0.12/getting-started-publishing.md @@ -0,0 +1,158 @@ +--- +id: version-1.0.12-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: + +``` +yarn run build # or `npm run build` +``` + +This will generate a `build` folder 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` folder 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. + +### Using GitHub Pages + +While choosing a web server or host is outside Docusaurus' scope, 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 your Docusaurus site to GitHub Pages is straightforward if you are already using GitHub to host your project. Your code repository does not even need to be public. + +> Even if your repo is private, anything published to a `gh-pages` branch will be [public](https://help.github.com/articles/user-organization-and-project-pages/). + +Most of the work to publish to GitHub pages is done for you automatically through the [`publish-gh-pages`](./api-commands.md#docusaurus-publish) script. You just need to determine the values for a few parameters required by the script. + +Two of the required parameters are set in the [`siteConfig.js`](api-site-config.md): + +| Name | Description | +| ------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `organizationName` | The GitHub user or organization that owns the repository. In the case of Docusaurus, that would be the "facebook" GitHub organization. | +| `projectName` | The name of the GitHub repository for your project. For example, Docusaurus is hosted at https://github.com/facebook/docusaurus, so our project name in this case would be "docusaurus". | + +> Docusaurus also supports deploying [user or organization sites](https://help.github.com/articles/user-organization-and-project-pages/#user--organization-pages). These sites will be served from the `master` branch of the repo. So, you will want to have the Docusaurus infra, your docs, etc. in another branch (e.g., maybe call it `source`). To do this, just set `projectName` to "_username_.github.io" (where _username_ is your username or organization name on GitHub) and `organizationName` to "_username_". The publish script will automatically deploy your site to the root of the `master` branch to be served. + +> While we recommend setting the `projectName` and `organizationName` in `siteConfig.js`, you can also use environment variables `ORGANIZATION_NAME` and `PROJECT_NAME`. + +One of the required parameters is set as a environment variable: + +| 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. | + +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. | + +Once you have the parameter value information, you can go ahead and run the publish script, ensuring you have inserted your own values inside the various parameter placeholders: + +To run the script directly from the command-line, you can use the following, filling in the parameter values as appropriate. + +```bash +GIT_USER= \ + CURRENT_BRANCH=master \ + USE_SSH=true \ + yarn run publish-gh-pages # or `npm run publish-gh-pages` +``` + +> The specified `GIT_USER` must have push access to the repository specified in the combination of `organizationName` and `projectName`. + +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://docusaurus.io (it can also be accessed via https://docusaurus.io/), because it is served from the `gh-pages` branch of the https://github.com/facebook/docusaurus GitHub repo. 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 repo that contains the documentation, by checking `Settings | Collaborators & teams` in the repo. +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 `repo` 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 org/repo. +1. Create a new environment variable named `GITHUB_TOKEN`, using your newly generated access token as the value. +1. Create a `.circleci` folder and create a `config.yml` under that folder. +1. Copy the text below into `.circleci/config.yml`. + +```yml +# If you only one 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:7.10 + + steps: + - checkout + - run: + name: Deploying to GitHub Pages + command: | + git config --global user.email "@users.noreply.github.com" + git config --global user.name "" + echo "machine github.com login password $GITHUB_TOKEN" > ~/.netrc + cd website && yarn install && 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 ``, it should be a GitHub account that has access to push documentation to your GitHub repo. Many times `` and `` 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 repo connection, you can set `USE_SSH=true`. So the above command would look something like: `cd website && npm install && 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: + +```yml +# 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` folder inside your `website/assets` folder. diff --git a/website/versioned_docs/version-1.0.12/guides-blog.md b/website/versioned_docs/version-1.0.12/guides-blog.md new file mode 100644 index 000000000000..3225380bac9c --- /dev/null +++ b/website/versioned_docs/version-1.0.12/guides-blog.md @@ -0,0 +1,94 @@ +--- +id: version-1.0.12-blog +title: Adding a Blog +original_id: blog +--- + +## Initial Setup + +To setup your site's blog, start by creating a `blog` folder within your repo's `website` directory. + +Then, add a header link to your blog within `siteConfig.js`: + +``` +headerLinks: [ + ... + {blog: true, label: 'Blog'}, + ... +] +``` + + +## Adding Posts + +To publish in the blog, create a file within the blog folder with a formatted name of `YYYY-MM-DD-My-Blog-Post-Title.md`. The post date is extracted from the file name. + +For example, at `website/blog/2017-08-18-Introducing-Docusaurus.md`: + +``` +--- +author: Frank Li +authorURL: https://twitter.com/foobarbaz +authorFBID: 503283835 +title: Introducing Docusaurus +--- + +Lorem Ipsum... +``` + + +## Header Options + +The only required field is `title`; however, we provide options to add author information to your blog post as well. + +- `author` - The text label of the author byline. +- `authorURL` - The URL associated with the author. This could be a Twitter, GitHub, Facebook account, etc. +- `authorFBID` - The Facebook profile ID that is used to fetch the profile picture. +- `authorImageURL` - The URL to the author's image. (Note: If you use both `authorFBID` and `authorImageURL`, `authorFBID` will take precedence. Don't include `authorFBID` if you want `authorImageURL` to appear.) +- `title` - The blog post title. + + +## Summary Truncation + +Use the `` marker in your blog post to represent what will be shown as the summary when viewing all blog published blog posts. Anything above `` will be part of the summary. For example: + +``` +--- +title: Truncation Example +--- + +All this will be part of the blog post summary. + +Even this. + + + +But anything from here on down will not be. + +Not this. + +Or this. +``` + +## Changing How Many Blog Posts Show on Sidebar + +By default, 5 recent blog posts are shown on the sidebar. + +You can configure a specific amount of blog posts to show by adding a `blogSidebarCount` setting to your `siteConfig.js`. + +The available options are an integer representing the number of posts you wish to show or a string with the value 'ALL'. + +Example: +``` +blogSidebarCount: 'ALL' +``` + +## RSS Feed + +Docusaurus provides a simple RSS feed for your blog posts. Both RSS and Atom feed formats are supported. This data is automatically to your website page's HTML tag. + +A summary of the post's text is provided in the RSS feed up to the ``. If no `` tag is found, then all text up 250 characters are used. + +## Social Buttons + +If you want Facebook and/or Twitter social buttons at the bottom of your blog posts, set the `facebookAppId` and/or `twitter` [site configuration](api-site-config.md) options in `siteConfig.js`. diff --git a/website/versioned_docs/version-1.0.12/guides-versioning.md b/website/versioned_docs/version-1.0.12/guides-versioning.md new file mode 100644 index 000000000000..2bf549d0deba --- /dev/null +++ b/website/versioned_docs/version-1.0.12/guides-versioning.md @@ -0,0 +1,96 @@ +--- +id: version-1.0.12-versioning +title: Versioning +original_id: versioning +--- + +You can use the `version` script to cut a new documentation version based on the latest content in the `docs` folder. That specific set of documentation will then be preserved and accessible even as the documentation in the `docs` folder changes moving forward. + +## How to Create New Versions + +Run the following script to generate a starter versions page listing all the site versions: + +```bash +yarn examples versions +``` + +This creates the `pages/en/versions.js` file. + +You can edit this file later on to customize how you display the versions. + +Add the following script to your `package.json` file if it doesn't already exist: + +```json +... +"scripts": { + "version": "docusaurus-version" +}, +... +``` + +Run the script with a command line argument of the version you wish to create. e.g., + +```bash +yarn run version 1.0.0 +``` + +This will preserve all documents currently in the `docs` folder and make them available as documentation for version `1.0.0`. + +If, for example, you ran the version script with `1.0.0` as the version number, version `1.0.0` is considered the latest release version for your project. The site will display the version number next to the title in the header. This version number links to a versions page that you created earlier. + +Documents in the `docs` folder will be considered part of version `next` and they are available, for example, at the url `docs/next/doc1.html`. Documents from the latest version use the url `docs/doc1.html`. + +Running the script again with `yarn run version 2.0.0` will create a version `2.0.0`, making version `2.0.0` the most recent set of documentation. Documents from version `1.0.0` will use the url `docs/1.0.0/doc1.html` while `2.0.0` will use `docs/doc1.html`. + +This table below summarizes Docusaurus versioning at a glance: + +| Version | Tag | URL +| --- | --- | -- | +| 1.0.0 | 1.0.0 | docs/1.0.0/doc1.html | +| 1.0.1 | 1.0.1 | docs/1.0.1/doc1.html | +| 2.0.0 | current | docs/doc1.html | +| master branch | next | docs/next/doc1.html | + +## Versioning Patterns + +You can create version numbers in whatever format you wish, and a new version can be created with any version number as long as it does not match an existing version. Version ordering is determined by the order in which versions are created, independently of how they are numbered. + +## Storing Files for Each Version + +Versioned documents are placed into `website/versioned_docs/version-${version}`, where `${version}` is the version number you supplied the `version` script. + +The markdown header for each versioned doc is altered by renaming the id front matter field to `original_id`, then using `"version-${version}-${original_id}"` as the value for the actual `id` field. + +Versioned sidebars are copied into `website/versioned_sidebars` and are named as `version-${version}-sidebars.json`. + +A `website/versions.json` file is created the first time you cut a version and is used by Docusaurus to detect what versions exist. Each time a new version is added, it gets added to the `versions.json` file. + +If you wish to change the documentation for a past version, you can access the files for that respective version. + +## Fallback Functionality + +Only files in the `docs` folder and sidebar files that differ from those of the latest version will get copied each time a new version is specified. If there is no change across versions, Docusaurus will use the file from the latest version with that file. + +For example, a document with the original id `doc1` exists for the latest version, `1.0.0`, and has the same content as the document with the id `doc1` in the `docs` folder. When a new version `2.0.0` is created, the file for `doc1` will not be copied into `versioned_docs/version-2.0.0/`. There will still be a page for `docs/2.0.0/doc1.html`, but it will use the file from version `1.0.0`. + +## Renaming Existing Versions + +To rename an existing version number to something else, first make sure the following script is in your `package.json` file: + +```json +... +"scripts": { + "rename-version": "docusaurus-rename-version" +}, +... +``` + +Run the script with command line arguments of first, the current version name, then second, the new version name. e.g., + +```bash +yarn run rename-version 1.0.0 1.0.1 +``` + +## Versioning and Translations + +If you wish to use versioning and translations features, the `crowdin.yaml` file should be set up to upload and download versioned documents to and from Crowdin for translation. Translated, versioned files will go into the folder `translated_docs/${language}/version-${version}/`. For more information, check out the [translations guide](guides-translation.md). diff --git a/website/versions.json b/website/versions.json index 38546bd469cb..94310c4290b3 100644 --- a/website/versions.json +++ b/website/versions.json @@ -1,3 +1,4 @@ [ + "1.0.12", "1.0.11" ]