From 6041f9ece79c43383f8b110932446e256ca967b5 Mon Sep 17 00:00:00 2001 From: Joel Marcey Date: Mon, 23 Apr 2018 16:40:13 -0700 Subject: [PATCH] Publish v1.0.14 (#597) --- CHANGELOG.md | 30 ++- package-lock.json | 2 +- package.json | 2 +- .../getting-started-installation.md | 53 ++++++ .../getting-started-publishing.md | 179 ++++++++++++++++++ .../getting-started-site-creation.md | 96 ++++++++++ .../version-1.0.14/guides-blog.md | 128 +++++++++++++ website/versions.json | 1 + 8 files changed, 488 insertions(+), 3 deletions(-) create mode 100644 website/versioned_docs/version-1.0.14/getting-started-installation.md create mode 100644 website/versioned_docs/version-1.0.14/getting-started-publishing.md create mode 100644 website/versioned_docs/version-1.0.14/getting-started-site-creation.md create mode 100644 website/versioned_docs/version-1.0.14/guides-blog.md diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b194cab5538..41653607d875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,33 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [1.0.14] - 2018-04-23 + +Small release mostly for documentation. + +Thank you to the following contributors who have helped with this releae: + +- @yangshun +- @ericnakagawa +- @shikaan +- @longility + +### Breaking changes + +N/A + +### Added + +N/A + +### Fixed/Changed + +- Blog metadata now [refreshed](https://github.com/facebook/Docusaurus/commit/d3fd347d21d3480e656cf4590917633f91254c5f) on changes to blog posts. + +### Removed + +N/A + ## [1.0.13] - 2018-04-20 This is primarily a bug fix release. @@ -295,7 +322,8 @@ N/A - Blog - Documentation -[Unreleased]: https://github.com/facebook/Docusaurus/compare/v1.0.13...HEAD +[Unreleased]: https://github.com/facebook/Docusaurus/compare/v1.0.14...HEAD +[1.0.14]: https://github.com/facebook/Docusaurus/compare/v1.0.13...v1.0.14 [1.0.13]: https://github.com/facebook/Docusaurus/compare/v1.0.12...v1.0.13 [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 diff --git a/package-lock.json b/package-lock.json index 8afe72387951..8cc0a3ba4f8d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "docusaurus", - "version": "1.0.13", + "version": "1.0.14", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 30fe80b17bc5..e227fac03cc7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "docusaurus", "description": "Easy to Maintain Open Source Documentation Websites", - "version": "1.0.13", + "version": "1.0.14", "license": "MIT", "keywords": [ "documentation", diff --git a/website/versioned_docs/version-1.0.14/getting-started-installation.md b/website/versioned_docs/version-1.0.14/getting-started-installation.md new file mode 100644 index 000000000000..93aaa7ee3324 --- /dev/null +++ b/website/versioned_docs/version-1.0.14/getting-started-installation.md @@ -0,0 +1,53 @@ +--- +id: version-1.0.14-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. To install Docusaurus, we have created an easy script that will get all of the infrastructure setup 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. + + > While we recommend Node 8.x or greater, your Node version must at least 6.x. + +1. Go into the root of your GitHub repo directory where you will be creating the docs. +1. `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`. + +> After Docusaurus is installed, moving forward, you can check your current version of Docusaurus by going into the `website` directory and typing `yarn outdated docusaurus` or `npm outdated docusaurus`. You can update to the [latest version](https://www.npmjs.com/package/docusaurus) of Docusaurus by typing `yarn upgrade docusaurus --latest` or `npm update docusaurus`. + +## Verifying Installation + +Along with previously existing files and directories, your root directory will now contain a structure similar to: + +```bash +root-of-repo +├── 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 +│ └── core +│ └── Footer.js +│ └── node_modules +│ └── package.json +│ └── pages +│ └── sidebars.json +│ └── siteConfig.js +│ └── static +``` + +Running the Docusaurus initialization script, `docusaurus-init`, produces a runnable, example website to base your site upon. + +1. In your root, rename `docs-examples-from-docusaurus` to `docs`. +1. `cd website` +1. Rename `blog-examples-from-docusaurus` to `blog`. +1. Run the local webserver via `yarn start` or `npm start`. +1. Load the example site at http://localhost:3000. You should see the example site loaded in your web browser. + +![](/img/getting-started-preparation-verify.png) diff --git a/website/versioned_docs/version-1.0.14/getting-started-publishing.md b/website/versioned_docs/version-1.0.14/getting-started-publishing.md new file mode 100644 index 000000000000..57642ebab1ab --- /dev/null +++ b/website/versioned_docs/version-1.0.14/getting-started-publishing.md @@ -0,0 +1,179 @@ +--- +id: version-1.0.14-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. + +### Hosting on a Service: + +* [Github Pages](#using-github-pages) +* [Netlify](#hosting-on-netlify) + +### 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. + +### Hosting on Netlify + +Steps to configure your Docusaurus-powered site on Netlify. + +1. Select **New site from Git** +2. Connect to your preferred Git provider. +3. Select the branch to deploy. Default is `master` +4. Configure your build steps: + +* For your build command enter: `cd website; npm install; npm run build;` +* For publish directory: `build/` (use the projectName from your siteConfig) + +5. Click **Deploy site** + +You can also configure Netlify to rebuild on every commit to your repo, or only `master` branch commits. diff --git a/website/versioned_docs/version-1.0.14/getting-started-site-creation.md b/website/versioned_docs/version-1.0.14/getting-started-site-creation.md new file mode 100644 index 000000000000..ba3aa9de19cb --- /dev/null +++ b/website/versioned_docs/version-1.0.14/getting-started-site-creation.md @@ -0,0 +1,96 @@ +--- +id: version-1.0.14-site-creation +title: Creating your site +original_id: site-creation +--- + +Docusaurus was created to hopefully make it super simple for you to create a site and documentation for your open source project. + +After [installation](getting-started-installation.md) and [preparation](getting-started-preparation.md), much of the work to create a basic site for your docs is already complete. + +## Site Structure + +Your site structure looks like the following: + +```bash +root-of-repo +├── docs +└── website +│ └── blog +│ └── core +│ └── Footer.js +│ └── node_modules +│ └── package.json +│ └── pages +│ └── sidebars.json +│ └── siteConfig.js +│ └── static +``` + +> This assumes that you removed the example `.md` files that were installed with the [initialization](getting-started-installation.md) script. + +All of your documentation files should be placed inside the `docs` folder as markdown `.md` files. Any blog posts should be inside the `blog` folder. + +> The blog posts must be formatted as `YYYY-MM-DD-your-file-name.md` + +## Create Your Basic Site + +To create a fully functional site, you only need to do a few steps: + +1. Add your documentation to the `/docs` folder as `.md` files, ensuring you have the proper [header](api-doc-markdown.md#documents) in each file. The simplest header would be the following, where `id` is the link name (e.g., `docs/intro.html`) and the `title`, is, of course, the title of the browser page. + + ``` + --- + id: intro + title: Getting Started + --- + + My *new content* here.. + ``` + +1. Add zero or more docs to the [`sidebars.json`](guides-navigation.md#adding-docs-to-a-sidebar) file so that your documentation is rendered in a sidebar, if you choose them to be. + + > If you do not add your documentation to the `sidebars.json` file, the docs will be rendered, but they can only be linked to from other documentation and visited with the known URL. + +3. Modify the `website/siteConfig.js` file to [configure your site](api-site-config.md), following the comments included in the [docs](api-site-config.md) and the `website/siteConfig.js` to guide you. +1. Create any [custom pages](guides-custom-pages.md#customizing-your-site-footer) and/or [customize](guides-custom-pages.md#customizing-your-site-footer) the `website/core/Footer.js` file that provides the footer for your site. +1. Place assets, such as images, in the `website/static/` folder. +1. Run the site to see the results of your changes. + + ``` + cd website + yarn run start # or `npm run start` + # navigate to http://localhost:3000 + ``` + +## Special Customization + +### Docs Landing Page + +If you prefer to have your landing page be straight to your documentation, you can do this through a redirect. + +1. Remove the `index.js` file from the `website/pages` directory, if it exists. +1. Add a [custom static `index.html` page](guides-custom-pages.md#adding-static-pages) in the `website/static` folder with the following contents: + +```html + + + + + + + Your Site Title Here + + + If you are not redirected automatically, follow this link. + + +``` + +> You will get the `id` of the document to land on the `.md` metadata of that doc page. + +### Blog Only + +You can also use Docusaurus to host your [blog only](guides-blog.md#i-want-to-run-in-blog-only-mode). diff --git a/website/versioned_docs/version-1.0.14/guides-blog.md b/website/versioned_docs/version-1.0.14/guides-blog.md new file mode 100644 index 000000000000..1214fe8ac18f --- /dev/null +++ b/website/versioned_docs/version-1.0.14/guides-blog.md @@ -0,0 +1,128 @@ +--- +id: version-1.0.14-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`. + +## Advanced Topics + +### I want to run in "Blog Only" mode. + +You can run your Docusaurus site without a landing page and instead have your blog load first. + +To do this: + +1. Create a file `index.html` in `website/static/`. + +1. Place the contents of the template below into `website/static/index.html` + +1. Customize the `` of `website/static/index.html` + +1. Delete the dynamic landing page `website/pages/en/index.js` + +> Now, when Docusaurus generates or builds your site, it will copy the file from `static/index.html` and place it in the site's main folder. The static file is served when a visitor arrives on your page. When the page loads it will redirect the visitor to `/blog`. + +You can use this template: + +```<!DOCTYPE HTML> +<html lang="en-US"> + <head> + <meta charset="UTF-8"> + <meta http-equiv="refresh" content="0; url=blog/"> + <script type="text/javascript"> + window.location.href = "blog/" + </script> + <title>Title of Your Blog + + + If you are not redirected automatically, follow this link. + + +``` diff --git a/website/versions.json b/website/versions.json index 7101dbd079d2..31c0812aa2f0 100644 --- a/website/versions.json +++ b/website/versions.json @@ -1,4 +1,5 @@ [ + "1.0.14", "1.0.13", "1.0.12", "1.0.11"