diff --git a/CHANGELOG.md b/CHANGELOG.md index b4c191345b1a..bc3b3b384a19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,9 +6,20 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ## [Unreleased] +## [1.13.0] - 2019-09-15 + +**Fixed** + +- fix: content aligning breaks at IE11 ([#1684](https://github.com/facebook/docusaurus/pull/#1684)) +- fix: footer links margin ([#1781](https://github.com/facebook/docusaurus/pull/#1781)) +- feat: strip html from TOC ([#1762](https://github.com/facebook/docusaurus/pull/#1762)) + **Docs** -- docs: document what should be in .gitignore ([https://github.com/facebook/docusaurus/pull/1709](https://github.com/facebook/docusaurus/pull/1709)) +- docs: document what should be in .gitignore ([#1709](https://github.com/facebook/docusaurus/pull/1709)) +- docs: change separateCSS to separateCss ([#1735](https://github.com/facebook/docusaurus/pull/#1735)) +- docs: fix documented type for the `cleanUrl` option ([#1775](https://github.com/facebook/docusaurus/pull/#1775)) +- docs: improve tutorial ## [1.12.0] - 2019-07-20 @@ -1157,7 +1168,8 @@ N/A - Blog - Documentation -[unreleased]: https://github.com/facebook/Docusaurus/compare/v1.12.0...HEAD +[unreleased]: https://github.com/facebook/Docusaurus/compare/v1.13.0...HEAD +[1.13.0]: https://github.com/facebook/Docusaurus/compare/v1.12.0...v1.13.0 [1.12.0]: https://github.com/facebook/Docusaurus/compare/v1.11.1...v1.12.0 [1.11.1]: https://github.com/facebook/Docusaurus/compare/v1.11.0...v1.11.1 [1.11.0]: https://github.com/facebook/Docusaurus/compare/v1.10.0...v1.11.0 diff --git a/admin/publish.md b/admin/publish.md index a35247ba1e09..b0b7b5df77a3 100644 --- a/admin/publish.md +++ b/admin/publish.md @@ -14,9 +14,9 @@ If you are not currently logged into npm locally: 1. Bump version number in [`package.json`](https://github.com/facebook/Docusaurus/blob/master/package.json). 1. Update the [changelog](https://github.com/facebook/Docusaurus/blob/master/CHANGELOG.md), including at the reference links at the bottom. 1. Do this always, but particularly important if there were any `package.json` changes in this release: - 1. If there is no `node_modules` directory in you local Docusaurus version, run `yarn install` and `npm install`. - 1. Run `yarn upgrade` to update `yarn.lock` and `npm update` to update `package-lock.json`. -1. From the `website` directory, run `npm run version x.x.x`, where x.x.x is the same version number you updated to in `package.json`. + 1. If there is no `node_modules` directory in you local Docusaurus version, run `yarn install` and `npm install`. + 1. Run `yarn upgrade` to update `yarn.lock` and `npm update` to update `package-lock.json`. +1. From the `website-1.x` directory, run `npm run docusaurus-version x.x.x`, where x.x.x is the same version number you updated to in `package.json`. 1. Test your PR locally on a project that was created via [these instructions](https://github.com/facebook/Docusaurus/blob/master/admin/local-third-party-project-testing.md). 1. Submit your PR 1. When your PR is merged, rebase to get the PR commit locally. diff --git a/packages/docusaurus-1.x/package.json b/packages/docusaurus-1.x/package.json index 553fb02ea1d4..8329d1c1684a 100644 --- a/packages/docusaurus-1.x/package.json +++ b/packages/docusaurus-1.x/package.json @@ -1,7 +1,7 @@ { "name": "docusaurus", "description": "Easy to Maintain Open Source Documentation Websites", - "version": "2.0.0-alpha.24", + "version": "1.13.0", "license": "MIT", "keywords": [ "documentation", diff --git a/packages/docusaurus-init-1.x/package.json b/packages/docusaurus-init-1.x/package.json index 7260ac13971f..65c1ad1c7fe9 100644 --- a/packages/docusaurus-init-1.x/package.json +++ b/packages/docusaurus-init-1.x/package.json @@ -1,7 +1,7 @@ { "name": "docusaurus-init", "description": "Initialization script for Docusaurus", - "version": "2.0.0-alpha.24", + "version": "1.13.0", "license": "MIT", "preferGlobal": true, "keywords": [ diff --git a/website-1.x/package.json b/website-1.x/package.json index e9e96d385bbb..f30bf446dbf6 100644 --- a/website-1.x/package.json +++ b/website-1.x/package.json @@ -15,6 +15,6 @@ }, "dependencies": { "async": "^2.5.0", - "docusaurus": "^2.0.0-alpha.24" + "docusaurus": "1.13.0" } } diff --git a/website-1.x/versioned_docs/version-1.13.0/api-site-config.md b/website-1.x/versioned_docs/version-1.13.0/api-site-config.md new file mode 100644 index 000000000000..ed8a0dffc98c --- /dev/null +++ b/website-1.x/versioned_docs/version-1.13.0/api-site-config.md @@ -0,0 +1,435 @@ +--- +id: version-1.13.0-site-config +title: siteConfig.js +original_id: site-config +--- + +A large part of the 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 the footer of the site and within the feed + +#### `favicon` [string] + +URL for site favicon. + +#### `headerIcon` [string] + +URL for icon used in the 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 } +], +``` + +#### `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] + +The 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 an 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` [boolean] + +If `true`, allow URLs with no `HTML` extension. For example, a request to URL https://docusaurus.io/docs/installation will return 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. + +#### `docsUrl` [string] + +The base URL for all docs file. Set this field to `''` to remove the `docs` prefix of the documentation URL. +If unset, it is defaulted to `docs`. + +#### `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`. + +#### `docsSideNavCollapsible` [boolean] + +Set this to `true` if you want to be able to expand/collapse the links and subcategories in the sidebar. + +#### `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 `. + +#### `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 `. + +#### `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] + +The 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 `` tag to `` with `rel` as `"manifest"` and `href` as the provided path. + +#### `markdownOptions` [object] + +Override default [Remarkable options](https://github.com/jonschlinkert/remarkable#options) that will be used to render markdown. + +> To manage [syntax extensions](https://github.com/jonschlinkert/remarkable#syntax-extensions), use the `markdownPlugins` field. + +#### `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. + +For example, if you want to [enable superscript and subscript](https://github.com/jonschlinkert/remarkable#syntax-extensions) in your markdown that is rendered by Remarkable to HTML, you would do the following: + +``` + markdownPlugins: [ + function foo(md) { + md.inline.ruler.enable(['sub', 'sup']); + }, + ], +``` + +#### `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. + +#### `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] + +An 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` [array] + +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] + +An 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] + +An 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 '
bar
'; + }; + }, + ], + 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; +``` diff --git a/website-1.x/versioned_docs/version-1.13.0/tutorial-create-new-site.md b/website-1.x/versioned_docs/version-1.13.0/tutorial-create-new-site.md new file mode 100644 index 000000000000..6cc2e8cbdb5d --- /dev/null +++ b/website-1.x/versioned_docs/version-1.13.0/tutorial-create-new-site.md @@ -0,0 +1,74 @@ +--- +id: version-1.13.0-tutorial-create-new-site +title: Create a New Site +original_id: tutorial-create-new-site +--- + +In this section, we'll get our Docusaurus site up and running for local development. The process only takes a few minutes. + +Docusaurus browser + +## Scaffold the Site + +1. `cd` to the directory of your local repository. + +```sh +cd docusaurus-tutorial +``` + +2. Execute the `docusaurus-init` command in your terminal. + +```sh +docusaurus-init +``` + +> The `Linking dependencies...` step might take a while, but it will finish eventually. + +The following contents will be created in your current directory. Some example documentation pages (under `docs`) and blog posts (under `website/blog`) are included. + +```sh +├── Dockerfile +├── docker-compose.yml +├── docs +│ ├── doc1.md +│ ├── doc2.md +│ ├── doc3.md +│ ├── exampledoc4.md +│ └── exampledoc5.md +└── website + ├── README.md + ├── blog + │ ├── 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 + │ └── en + │ ├── help.js + │ ├── index.js + │ └── users.js + ├── sidebars.json + ├── siteConfig.js + ├── static + │ ├── css + │ │ └── custom.css + │ └── img + │ ├── docusaurus.svg + │ ├── favicon + │ │ └── favicon.ico + │ ├── favicon.png + │ └── oss_logo.png + └── yarn.lock +``` + + +3. Run `cd website` to go into the `website` directory. +4. Run `npm start` or `yarn start`. + +A browser window will open up at http://localhost:3000. + +Congratulations, you have just made your first Docusaurus site! Click around the pages to get a feel for it. diff --git a/website-1.x/versioned_docs/version-1.13.0/tutorial-create-pages.md b/website-1.x/versioned_docs/version-1.13.0/tutorial-create-pages.md new file mode 100644 index 000000000000..f18895ddb3df --- /dev/null +++ b/website-1.x/versioned_docs/version-1.13.0/tutorial-create-pages.md @@ -0,0 +1,99 @@ +--- +id: version-1.13.0-tutorial-create-pages +title: Create Pages +original_id: tutorial-create-pages +--- + +In this section, we will learn about creating two types of pages in Docusaurus: a regular page and a documentation page. + +Docusaurus MacBook + +## Create a Regular Page + +1. In the `website/pages/en` directory of your repository, save a text file called `hello-world.js` with the following contents: + +``` +const React = require('react'); + +const CompLibrary = require('../../core/CompLibrary.js'); + +const Container = CompLibrary.Container; +const GridBlock = CompLibrary.GridBlock; + +function HelloWorld(props) { + return ( +
+ +

Hello World!

+

This is my first page!

+
+
+ ); +} + +module.exports = HelloWorld; +``` + +> Use any text editor to make the file, such as [Microsoft Visual Studio Code](https://code.visualstudio.com/download) or [Komodo Edit](https://www.activestate.com/komodo-edit). + +2. Go to http://localhost:3000/hello-world and you should be able to see the new page. +1. Change the text within the `

...

` to "I can write JSX here!" and save the file again. The browser should refresh automatically to reflect the change. + +```diff +-

This is my first page!

++

I can write JSX here!

+``` + +React is being used as a templating engine for rendering static markup. You can leverage on the expressibility of React to build rich web content. Learn more about creating pages [here](custom-pages). + +Docusaurus React + +## Create a Documentation Page + +1. Create a new file in the `docs` folder called `doc9.md`. The `docs` folder is in the root of your Docusaurus project, one level above `website`. +1. Paste the following contents: + +``` +--- +id: doc9 +title: This is Doc 9 +--- + +I can write content using [GitHub-flavored Markdown syntax](https://github.github.com/gfm/). + +## Markdown Syntax + +**Bold** _italic_ `code` [Links](#url) + +> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse +> id sem consectetuer libero luctus adipiscing. + +* Hey +* Ho +* Let's Go +``` + +3. The `sidebars.json` is where you specify the order of your documentation pages, so open `website/sidebars.json` and add `"doc9"` after `"doc1"`. This ID should be the same one as in the metadata for the Markdown file above, so if you gave a different ID in Step 2, just make sure to use the same ID in the sidebar file. + +```diff +{ + "docs": { + "Docusaurus": [ + "doc1", ++ "doc9" + ], + "First Category": ["doc2"], + "Second Category": ["doc3"] + }, + "docs-other": { + "First Category": ["doc4", "doc5"] + } +} +``` + +4. A server restart is needed to pick up sidebar changes, so go to your terminal, kill your dev server (Cmd + C or Ctrl + C), and run `npm start` or `yarn start`. +1. Navigate to http://localhost:3000/docs/doc9 to see the new documentation page. + +You've created your first documentation page on Docusaurus! + +Learn more about creating docs pages [here](navigation). diff --git a/website-1.x/versioned_docs/version-1.13.0/tutorial-publish-site.md b/website-1.x/versioned_docs/version-1.13.0/tutorial-publish-site.md new file mode 100644 index 000000000000..ac85e42d5abd --- /dev/null +++ b/website-1.x/versioned_docs/version-1.13.0/tutorial-publish-site.md @@ -0,0 +1,40 @@ +--- +id: version-1.13.0-tutorial-publish-site +title: Publish the Site +original_id: tutorial-publish-site +--- + +Docusaurus Facebook + +Next, we'll learn how to publish the site to the WWW for everyone to browse! For the purpose of the tutorial, we'll use GitHub Pages to host our website. But you can use any static file hosting service that you want, like Netlify, Amazon S3, etc. + +## Put the Site Online + +1. Edit the file `docusaurus-tutorial/website/siteConfig.js` and fill in the following values: + +``` +const siteConfig = { + ... + url: 'https://USERNAME.github.io', // Replace USERNAME with your GitHub username. + baseUrl: '/docusaurus-tutorial/', // The name of your GitHub project. + projectName: 'docusaurus-tutorial', // The name of your GitHub project. Same as above. + organizationName: 'USERNAME' // Your GitHub username. + ... +} +``` + +2. In Terminal or Git Bash, kill the web server by pressing **Cmd+C** or **Ctrl+C**. +3. In the `website` directory, run `npm run build` or `yarn build`. The command generates a `build` directory inside the `website` directory, containing HTML files (and other file types) for all of your docs and other pages. Make sure the `docusaurus-tutorial/website/build` directory is successfully created before running the next step. +4. Replace `USERNAME` with your GitHub username and run the following command. + +```sh +GIT_USER=USERNAME CURRENT_BRANCH=master USE_SSH=true npm run publish-gh-pages # SSH +# or +GIT_USER=USERNAME CURRENT_BRANCH=master npm run publish-gh-pages # HTTPS +``` + +The HTML files (and other file types) are pushed to the `gh-pages` branch of your repository: https://github.com/USERNAME/docusaurus-tutorial. + +5. Go to https://USERNAME.github.io/docusaurus-tutorial/ and view your site in action! + +> Note that when you run `npm run start` again, the `baseUrl` will now be part of the path. diff --git a/website-1.x/versioned_docs/version-1.13.0/tutorial-setup.md b/website-1.x/versioned_docs/version-1.13.0/tutorial-setup.md new file mode 100644 index 000000000000..eef8958478cf --- /dev/null +++ b/website-1.x/versioned_docs/version-1.13.0/tutorial-setup.md @@ -0,0 +1,90 @@ +--- +id: version-1.13.0-tutorial-setup +title: Setting Up +original_id: tutorial-setup +--- + +This tutorial is geared at first-time users who want detailed instructions on how to go from zero to a Docusaurus website that has versions. Let's start! + +Docusaurus campfire + +## Install Git + +Git is a version control system for tracking changes in source code during software development and it can help you synchronize and version files between your local system and your online repository. Git for Windows includes Git Bash, a terminal application. If not already installed, see [Installing Git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git). + +## Install Node.js + +Node.js is an environment that can run JavaScript code outside of a web browser and is used to write and run server-side JavaScript apps. Node.js installation includes `npm`, the package manager that allows you to install NPM modules from your terminal. + +1. Open Terminal on a Mac, Linux, or Unix system. Open Git Bash on a Windows system. +1. If you have `brew` on your OS, run the following command to install Node. + +```sh +brew install node +``` + +Alternatively, you can download an installer from the [Node.js homepage](https://nodejs.org/en/). + +## Check your Node.js installation + +Check that you have the minimum required version installed by running the following command: + +```sh +node -v +``` + +You should see a version larger than Node 8. + +```sh +node -v +v8.15.1 +``` + +> Docusaurus' minimum supported Node.js version is Node 8, but more recent versions will work as well. + +## Install Yarn (Optional) + +We highly recommend that you install Yarn, an alternative package manager that has superb performance for managing your NPM dependencies. Check it out [here](https://yarnpkg.com/en/docs/install). + +> You can still proceed with the tutorial without Yarn. + +## Create a GitHub repository and local clone + +1. Go to https://github.com/ and sign up for an account if you don't already have one. +1. Click on the green **New** button or go to https://github.com/new. +1. Type a repository name without spaces. For example, `docusaurus-tutorial`. +1. Click **Create repository** (without `.gitignore` and without a license). + +GitHub create repo + +5. In Terminal or Git Bash, `cd` to a directory where the local clone will be a subdirectory. + +```sh +cd /Users/NAME/doc_projects # macOS example +# or +cd /c/NAME/doc_projects # Windows example +``` + +6. Clone your repository to your local machine: + +```sh +git clone git@github.com:USERNAME/docusaurus-tutorial.git # SSH +# or +git clone https://github.com/USERNAME/docusaurus-tutorial.git # HTTPS +``` + +## Install the Docusaurus init command + +Docusaurus comes with a command line tool to help you scaffold a Docusaurus site with some example templates. Let's install the installer! + +Run the following command: + +```sh +npm install --global docusaurus-init +``` + +or if you have Yarn: + +```sh +yarn global add docusaurus-init +``` diff --git a/website-1.x/versioned_docs/version-1.13.0/tutorial-version.md b/website-1.x/versioned_docs/version-1.13.0/tutorial-version.md new file mode 100644 index 000000000000..7f0d8a2bfef2 --- /dev/null +++ b/website-1.x/versioned_docs/version-1.13.0/tutorial-version.md @@ -0,0 +1,74 @@ +--- +id: version-1.13.0-tutorial-version +title: Add Versions +original_id: tutorial-version +--- + +With an example site deployed, we can now try out one of the killer features of Docusaurus — versioned documentation. Versioned documentation helps to show relevant documentation for the current version of a tool and also hide unreleased documentation from users, reducing confusion. Documentation for older versions is also preserved and accessible to users of older versions of a tool even as the latest documentation changes. + +Docusaurus process + +## Releasing a Version + +Assume you are happy with the current state of the documentation and want to freeze it as the v1.0.0 docs. First you `cd` to the `website` directory and run the following command. + +```sh +npm run examples versions +``` + +That command generates a `versions.js` file, which will be used to list down all the versions of docs in the project. + +Next, you run a command with the version you want to create, like `1.0.0`. + +```sh +npm run version 1.0.0 +``` + +That command preserves a copy of all documents currently in the `docs` directory and makes them available as documentation for version 1.0.0. The `docs` directory is copied to the `website/versioned_docs/version-1.0.0` directory. + +### Current Version + +Type `npm start` and you will see the version beside the title. Version 1.0.0, the number of your current version, shows at the URL http://localhost:3000/docusaurus-tutorial/docs/doc1. + +Let's test out how versioning actually works. Open `docs/doc1.md` and change the first line of the body: + +```diff +--- +id: doc1 +title: Latin-ish +sidebar_label: Example Page +--- + +- Check the [documentation](https://docusaurus.io) for how to use Docusaurus. ++ This is the latest version of the docs. + +## Lorem + +Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. +``` + +If you go to http://localhost:3000/docusaurus-tutorial/docs/doc1 in your browser, realize that it's still showing the line before the change. That's because the version you're looking at is the 1.0.0 version, which has already been frozen in time. The document you changed is part of the next version. + +### Next Version + +The latest version of the documents is viewed by adding `next` to the URL: http://localhost:3000/docusaurus-tutorial/docs/next/doc1. Now you can see the line change to "This is the latest version of the docs." Note that the version beside the title changes to "next" when you open that URL. + +Click the version to open the versions page, which was created at http://localhost:3000/docusaurus-tutorial/versions with a list of the documentation versions. See that both `1.0.0` and `master` are listed there and they link to the respective versions of the documentation. + +The master documents in the `docs` directory became version next when the `website/versioned_docs/version-1.0.0` directory was made for version 1.0.0. + +### Past Versions + +Assume the documentation changed and needs an update. You can release another version, like `1.0.1`. + +```sh +npm run version 1.0.1 +``` + +Version 1.0.0 remains available as a past version. You can view it by adding `1.0.0` to the URL, http://localhost:3000/docusaurus-tutorial/docs/1.0.0/doc1. Also, a link to version 1.0.0 appears on the versions page. + +Go ahead and [publish](https://docusaurus.io/docs/en/next/tutorial-publish-site) your versioned site with the `publish-gh-pages` script! + +## Wrap Up + +That's all folks! In this short tutorial, you have experienced how easy it is to create a documentation website from scratch and make versions for them. There are many more things you can do with Docusaurus, such as adding a blog, search and translations. Check out the [Guides](https://docusaurus.io/docs/en/next/versioning) section for more. diff --git a/website-1.x/versions.json b/website-1.x/versions.json index c112a0481c4f..f0ee498aca5b 100644 --- a/website-1.x/versions.json +++ b/website-1.x/versions.json @@ -1,4 +1,5 @@ [ + "1.13.0", "1.12.0", "1.11.x", "1.10.x",