-
Notifications
You must be signed in to change notification settings - Fork 701
Add react-static content for deploying docs #786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a211eec
Add react-static content for deploying docs
kale-stew 299d29e
Remove double quote docs rule
kale-stew 075d3f1
Add dates, clean up docs changelog
kale-stew cd185f6
Add headers to doc content pages
kale-stew 7678b46
Consolidate eslint rules
kale-stew 33a32a8
PR feedback
kale-stew 2bd3a52
Fix docs for CI
kale-stew 2b86d8e
Make lint happy
kale-stew 373f93a
PR feedback
kale-stew 3fd0e85
Get rid of second CHANGELOG
kale-stew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,36 @@ | ||
| node_modules | ||
| # dependencies | ||
| /node_modules | ||
| /*/node_modules | ||
| package-lock.json | ||
| yarn.lock | ||
|
|
||
| # testing | ||
| /coverage | ||
| test/screenshots | ||
|
|
||
| # production | ||
| /dist | ||
| /tmp | ||
|
|
||
| # misc | ||
| .DS_Store | ||
| .env.local | ||
| .env.development.local | ||
| .env.test.local | ||
| .env.production.local | ||
| \.hg | ||
| .idea | ||
| .vscode | ||
|
|
||
| npm-debug.log* | ||
| yarn-debug.log* | ||
| yarn-error.log* | ||
| *.log | ||
|
|
||
| # build | ||
| coverage | ||
| Procfile | ||
| build | ||
| dist | ||
| lib | ||
| es | ||
| *.log | ||
| .DS_Store | ||
| .vscode |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| { | ||
| "extends": "react-static/.babelrc", | ||
| "plugins": ["babel-plugin-styled-components"] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| # Spectacle Documentation Site | ||
|
|
||
| Now built with react-static! | ||
|
|
||
| ## Getting Started | ||
|
|
||
| To install and run the docs site locally: | ||
|
|
||
| ```sh | ||
| $ cd docs | ||
| $ yarn install | ||
| $ yarn start | ||
| ``` | ||
|
|
||
| Note that paths in local development are based on a root of "/" but be careful when defining relative and absolute paths | ||
| inline or doing url parsing, as the production output root will be "open-source/spectacle." | ||
|
|
||
| ## Building the site for deployment | ||
|
|
||
| ### Build and check the staging site | ||
|
|
||
| The staging build is served from a root path, e.g. `http://example/com`. This is typically used for CI / per-PR previews. | ||
|
|
||
| ```sh | ||
| $ cd docs | ||
| $ yarn stage:build | ||
| $ yarn stage:serve | ||
| ``` | ||
|
|
||
| This build creates `dist/open-source/spectacle` simulating the directory style output. | ||
|
|
||
| Then visit: http://localhost:3000/open-source/spectacle/ | ||
|
|
||
| ### Build and check the production site | ||
|
|
||
| The production site is served from a nested path, e.g. `https://formidable.com/open-source/spectacle`. | ||
|
|
||
| ```sh | ||
| $ cd docs | ||
| $ yarn prod:build | ||
| $ yarn prod:serve | ||
| ``` | ||
|
|
||
| This build creates `dist` but the `serve` dev server remaps paths to make it appear at `open-source/spectacle`. This build **is** the appropriate, full production build. | ||
|
|
||
| Then visit: http://localhost:3000/open-source/spectacle/ | ||
|
|
||
| Both of these steps are important for validating that both the `basePath` used by the static HTML output and the `basename` used | ||
| by the client-side router are working as expected. This is also where you'll want to validate that there are no hardcoded, inlined, or malformed asset paths that worked locally but will not resolve correctly in production! | ||
|
|
||
| ## Tips for developing | ||
|
|
||
| - Almost all of your code will be executed in two contexts: first in node for server-side rendering and static html generation, then client-side as a PWA. In addition to writing [node-safe code](https://github.com/nozzle/react-static/blob/master/docs/concepts.md#writing-universal-node-safe-code), this also means that it's necessary to validate that both contexts are working as expected. | ||
|
|
||
| - In addition to two execution contexts, there are three stages: development, staging, and production. `yarn start` uses a local dev server with live reload that takes about one second to rebuild. This is a good choice for most local development, but it's important to keep in mind that **the development server does not build the static html.** For that, you will want to use `yarn stage && yarn serve`. The `yarn build` command is used by formidable.com within its build script that moves the output of this lander into the correct location within the overall site output. | ||
|
|
||
| - When debugging an issue with the static html output, don't be shy about cracking open the `dist` folder and looking at the output! | ||
|
|
||
| - When debugging an issue with the PWA or SSR-PWA coordination, consider using `yarn stage-debug` -- this builds the staging output without minification/uglification and propagates warnings/errors. | ||
|
|
||
| - We have seen errors related to minification, uglification, and codesplitting before, please do not treat the debug build or the local dev server as 1:1 with production output! | ||
|
|
||
| ## Tips for getting the most out of react-static + webpack tooling | ||
|
|
||
| We are on react-static v5 due to blocking stability issues with v6, which means... | ||
|
|
||
| - You'll want to make sure that when you refer to the docs you're in the v5 branch. | ||
|
|
||
| - When you install the react-static CLI tool globally, you'll want to use the v5 version (`npm install -g react-static@^5.9.12`) which currently has a wider selection of working templates that can be very useful as executable canonical references. | ||
|
|
||
| - If you're looking for the client-side router documentation for react-static to see how to implement a certain behavior, the best place to start is in the [react-router docs](https://reacttraining.com/react-router/web/api/), which react-static v5 uses under the hood. There are a few additional react-static specific properties for [Router](https://github.com/nozzle/react-static/blob/v5/docs/components.md#router), [Routes](https://github.com/nozzle/react-static/blob/v5/docs/components.md#routes), and [Link](https://github.com/nozzle/react-static/blob/v5/docs/components.md#link), but if you need something from the routing that doesn't seem to covered in the react-static api, the react-router docs are pretty likely to have you covered. | ||
|
|
||
| - You'll ~~want~~ need to use Webpack 3 plugins. Webpack has an [interesting approach](https://github.com/webpack/webpack.js.org/issues/1854) to documenting old versions. The existing documentation is broadly usable but you may want to familiarize yourself with this [introductory v3 to v4 migration guide](https://webpack.js.org/migrate/4/) and the relevant [react-static docs](https://github.com/nozzle/react-static/blob/v5/docs/config.md#webpack). | ||
|
|
||
| - Interestingly, some webpack v4 loaders still work with v3, while some webpack v3 loaders _don't_ work with webpack v3. Version-twiddling or using a different loader for reasons that are unclear may be required. When tweaking webpack, it's extra-important to validate both PWA and static html output and clear out cached files. | ||
|
|
||
| ## Using this project as a template: | ||
|
|
||
| This lander is designed to be easily re-used as a template for other projects. | ||
|
|
||
| What to change: | ||
|
|
||
| - Docs Content | ||
| - markdown content lives in `/docs/content` | ||
| - _Note:_ Any markdown files placed here will be rendered as separate pages, and header tags will be rendered into a hierarchical sidebar. Please make sure header tags do not include any special symbols as they will be used to create anchor tags and hashes. | ||
| - Main Page Content | ||
| - `src/screens/home/_content.js` includes section titles, descriptions, and assets urls | ||
| - `src/screens/home/hero.js` | ||
| - Constants | ||
| - client constants live in `src/constants.js` | ||
| - static constants live in `static-config-parts/constants.js` | ||
| - Assets | ||
| - Logos, sidebar svgs and favicons (TODO: These are all very similar svgs, and could some day live in a separate repo, and take props like color, name etc) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| --- | ||
| title: Basic Concepts | ||
| order: 1 | ||
| --- | ||
|
|
||
| <a name="basic-concepts"></a> | ||
|
|
||
| # Basic Concepts | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| --- | ||
| title: Extensions | ||
| order: 4 | ||
| --- | ||
|
|
||
| <a name="third-party"></a> | ||
|
|
||
| # Third Party Extensions | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| --- | ||
| title: Getting Started | ||
| order: 0 | ||
| --- | ||
|
|
||
| <a name="getting-started"></a> | ||
|
|
||
| # Getting Started | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| --- | ||
| title: Base Props | ||
| order: 3 | ||
| --- | ||
|
|
||
| <a name="base-props"></a> | ||
|
|
||
| # Base Props | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,8 @@ | ||
| --- | ||
| title: Tag API | ||
| order: 2 | ||
| --- | ||
|
|
||
| <a name="tag-api"></a> | ||
|
|
||
| # Tag API | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| { | ||
| "name": "formidable-spectacle-docs", | ||
| "version": "5.1.0", | ||
| "description": "Documentation site for Spectacle", | ||
| "main": "static.config.js", | ||
| "license": "MIT", | ||
| "bugs": { | ||
| "url": "https://github.com/FormidableLabs/spectacle-docs/issues" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/FormidableLabs/spectacle-docs.git" | ||
| }, | ||
| "homepage": "https://github.com/FormidableLabs/spectacle-docs#readme", | ||
| "scripts": { | ||
| "start": "react-static start", | ||
| "clean": "rimraf dist", | ||
| "stage:build": "react-static build --staging", | ||
| "stage:serve": "serve -l 3000 -c serve-staging.json", | ||
| "prod:build": "react-static build", | ||
| "prod:serve": "serve -l 3000", | ||
| "stage-debug": "react-static build --staging --debug", | ||
| "prettier-all": "npx prettier --write '{src,static-config-helpers,static-config-parts,static.config,scripts,lib}/**/*.{js,jsx}'", | ||
| "preversion": "yarn run lint && yarn run build", | ||
| "format": "yarn run lint --fix", | ||
| "lint": "eslint 'src/**/*.js' 'static-config-*/*.js' 'src/**/*.js' 'static.config.js'", | ||
| "test-local": "node test/spectacle-integration.js" | ||
| }, | ||
| "dependencies": { | ||
| "@babel/node": "^7.2.0", | ||
| "array-shuffle": "^1.0.1", | ||
| "axios": "^0.16.2", | ||
| "chokidar": "2.0.3", | ||
| "classnames": "^2.2.6", | ||
| "exenv": "^1.2.2", | ||
| "formidable-oss-badges": "0.1.1", | ||
| "gray-matter": "^3.1.1", | ||
| "history": "^4.7.2", | ||
| "htmr": "0.6.3", | ||
| "jdown": "^0.3.0", | ||
| "klaw": "^2.1.1", | ||
| "mdast": "^3.0.0", | ||
| "prismjs": "^1.15.0", | ||
| "prop-types": "^15.6.2", | ||
| "raw-loader": "^1.0.0", | ||
| "react": "^16.7.0", | ||
| "react-copy-to-clipboard": "^5.0.1", | ||
| "react-dom": "^16.0.0", | ||
| "react-ga": "^2.4.1", | ||
| "react-hot-loader": "^4.0.0-beta.21", | ||
| "react-router": "^4.2.0", | ||
| "react-router-ga": "^1.0.0", | ||
| "react-side-effect": "^1.1.5", | ||
| "react-static": "^5.9.12", | ||
| "styled-components": "^4.1.1" | ||
| }, | ||
| "devDependencies": { | ||
| "@babel/cli": "^7.2.0", | ||
| "@babel/core": "^7.2.0", | ||
| "anchorate": "^1.1.0", | ||
| "babel-preset-stage-1": "^6.24.1", | ||
| "chalk": "^2.4.1", | ||
| "change-case": "^3.0.2", | ||
| "config": "^3.0.0", | ||
| "eslint-config-formidable": "^4.0.0", | ||
| "eslint-config-prettier": "^4.1.0", | ||
| "eslint-config-react-tools": "1.x.x", | ||
| "eslint-plugin-filenames": "^1.3.2", | ||
| "eslint-plugin-prettier": "^3.0.0", | ||
| "eslint-plugin-promise": "^4.0.1", | ||
| "folder-reader": "^2.0.0", | ||
| "gatsby-remark-prismjs": "^3.2.2", | ||
| "github-slugger": "^1.2.1", | ||
| "js-yaml": "^3.12.0", | ||
| "json-to-frontmatter-markdown": "^1.0.0", | ||
| "lodash": "^4.17.11", | ||
| "node-dir": "^0.1.17", | ||
| "prettier": "^1.15.1", | ||
| "puppeteer": "^1.13.0", | ||
| "react-document-meta": "^2.0.3", | ||
| "react-router-scroll": "^0.2.0", | ||
| "react-static-plugin-styled-components": "^6.0.0-beta.28", | ||
| "remark": "^10.0.1", | ||
| "remark-frontmatter": "^1.3.0", | ||
| "remark-html": "^8.0.0", | ||
| "remark-kbd": "^1.0.16", | ||
| "remark-slug": "^5.1.1", | ||
| "remark-toc": "^5.1.0", | ||
| "rimraf": "^3.0.0", | ||
| "serve": "^11.3.0", | ||
| "spectacle": "^5.0.0", | ||
| "style-loader": "^0.23.1", | ||
| "surge": "^0.20.1", | ||
| "to-vfile": "^5.0.2", | ||
| "toml-js": "0.0.8", | ||
| "unist-util-select": "^1.5.0", | ||
| "unist-util-visit": "^1.4.0", | ||
| "url-loader": "^1.1.2" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| User-agent: * |
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <browserconfig> | ||
| <msapplication> | ||
| <tile> | ||
| <square70x70logo src="./static/favicon/favicon-32.png"/> | ||
| <TileColor>#ff4081</TileColor> | ||
| </tile> | ||
| </msapplication> | ||
| </browserconfig> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.