Skip to content

Commit c646304

Browse files
wgao19markerikson
authored andcommitted
WiP: Integrate docusaurus 2 (#247)
* Migrate Docs to Docusaurus 2 Alpha (#226) * Migrate to docusaurus 2 * Change docs to MDX format * Make custom 404 compatible with Docusaurus v2 * Removes unwated stuffs as suggested by @endiliey * update doc site .gitignore for Docusaurus 2 * update dependencies for Docusaurus 2 * remove lightBackground class that breaks dark mode * inline svgs to pick up colors by dark theme * make font size align with current RSK site * use monokai css for code block * remove unused files * add netlify.toml * remove unused 404 file * move monokai into custom.css * Update docusaurus, rm -rf useless file & use correct monokai prism theme instead of css" Co-authored-by: Endi <endiliey@gmail.com> * tweak css * tweak codeblock, use line highlighting * line highlight docs * readme * tweaks * tweak monokai * larger code font * workaround for highlighting toc * bold right toc * align inline code snippet style with current rsk site - border radius should be 3px - bg color should be rgba(27, 31, 35, 0.05) * align anchor color with current rsk site - anchor color should be blue - visited color should be redux purple * align pagination pill styles with current rsk site - outline and link colors should be redux purple - hover effect flips color and bg * disable dark mode
1 parent f565b5b commit c646304

31 files changed

+9898
-10493
lines changed

docs/tutorials/advanced-tutorial.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ The starting commit for this application is a plain React implementation that us
3434
Let's start by viewing the original plain React app in action:
3535

3636
<iframe src="https://codesandbox.io/embed/rsk-github-issues-example-8jf6d?fontsize=14&hidenavigation=1&theme=dark&view=preview"
37-
style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
37+
style={{ width: '100%', height: '500px', border: 0, borderRadius: '4px', overflow: 'hidden' }}
3838
title="rtk-github-issues-example-01-plain-react"
3939
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
4040
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
@@ -381,7 +381,7 @@ Unlike typical `connect` + `mapDispatch` usage, here we call `dispatch()` direct
381381
Let's see if this works!
382382

383383
<iframe src="https://codesandbox.io/embed/rtk-github-issues-example-02-issues-display-tdx2w?fontsize=14&hidenavigation=1&module=%2Fsrc%2Fapp%2FApp.tsx&theme=dark&view=preview"
384-
style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
384+
style={{ width: '100%', height: '500px', border: 0, borderRadius: '4px', overflow: 'hidden' }}
385385
title="rtk-github-issues-example-02-issues-display"
386386
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
387387
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
@@ -1219,7 +1219,7 @@ Hopefully you now have a solid understand of how Redux Toolkit looks in a real w
12191219
Let's wrap this up with one more look at the complete source code and the running app:
12201220

12211221
<iframe src="https://codesandbox.io/embed/rtk-github-issues-example-03-final-ihttc?fontsize=14&hidenavigation=1&module=%2Fsrc%2Ffeatures%2FissueDetails%2FcommentsSlice.ts&theme=dark&view=editor"
1222-
style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
1222+
style={{ width: '100%', height: '500px', border: 0, borderRadius: '4px', overflow: 'hidden' }}
12231223
title="rtk-github-issues-example03-final"
12241224
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
12251225
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"

docs/tutorials/basic-tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ You can see that we're keeping the async handling separate from the reducer logi
275275
Here's the complete example in a sandbox:
276276

277277
<iframe src="https://codesandbox.io/embed/counter-vanilla-createslice-redux-toolkit-6gkxx?fontsize=14&hidenavigation=1&theme=dark&view=editor"
278-
style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
278+
style={{ width: '100%', height: '500px', border: 0, borderRadius: '4px', overflow: 'hidden' }}
279279
title="counter-vanilla createSlice - Redux Toolkit"
280280
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
281281
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"

docs/tutorials/intermediate-tutorial.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ The changes here are simple. We update `src/index.js` to import `configureStore`
6868

6969
> - [Convert store setup to use configureStore](https://github.com/reduxjs/rtk-convert-todos-example/commit/cdfc15edbd82beda9ef0521aa191574b6cc7695a)
7070
71-
```diff
71+
```diff {3-4,9-12}
7272
import React from "react";
7373
import { render } from "react-dom";
7474
-import { createStore } from "redux";
@@ -77,8 +77,8 @@ import { Provider } from "react-redux";
7777
import App from "./components/App";
7878
import rootReducer from "./reducers";
7979

80-
-const store = createStore(rootReducer);
81-
+const store = configureStore({
80+
- const store = createStore(rootReducer);
81+
+ const store = configureStore({
8282
+ reducer: rootReducer,
8383
+});
8484
```
@@ -87,7 +87,7 @@ import rootReducer from "./reducers";
8787

8888
If you have [the Redux DevTools browser extension](https://github.com/zalmoxisus/redux-devtools-extension) installed, you should now be able to see the current state if you start the application in development mode and open the DevTools Extension. It should look like this:
8989

90-
![Redux DevTools Extension screenshot showing initial state](assets/tutorials/intermediate/int-tut-01-redux-devtools.png)
90+
![Redux DevTools Extension screenshot showing initial state](/assets/tutorials/intermediate/int-tut-01-redux-devtools.png)
9191

9292
## Creating the Todos Slice
9393

@@ -674,7 +674,7 @@ Everyone has different preferences on what makes a "maintainable" folder structu
674674
Now, let's see the final version of the code in action!
675675
676676
<iframe src="https://codesandbox.io/embed/rtk-convert-todos-example-uqqy3?fontsize=14&hidenavigation=1&module=%2Fsrc%2Ffeatures%2Ftodos%2FtodosSlice.js&theme=dark&view=editor"
677-
style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden;"
677+
style={{ width: '100%', height: '500px', border: 0, borderRadius: '4px', overflow: 'hidden' }}
678678
title="rtk-convert-todos-example"
679679
allow="geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
680680
sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"

docs/usage/usage-guide.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,6 @@ Second, **JS modules can have "circular reference" problems if two modules try t
523523

524524
This CodeSandbox example demonstrates the problem:
525525

526-
<iframe src="https://codesandbox.io/embed/rw7ppj4z0m" style="width:100%; height:500px; border:0; border-radius: 4px; overflow:hidden; margin-bottom: 20px" sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>
526+
<iframe src="https://codesandbox.io/embed/rw7ppj4z0m" style={{ width: '100%', height: '500px', border: 0, borderRadius: '4px', overflow: 'hidden' }} sandbox="allow-modals allow-forms allow-popups allow-scripts allow-same-origin"></iframe>
527527

528528
If you encounter this, you may need to restructure your code in a way that avoids the circular references.

netlify.toml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
1-
# Settings in the [build] context are global and are applied to all contexts
2-
# unless otherwise overridden by more specific contexts.
31
[build]
4-
# Directory (relative to root of your repo) that contains the deploy-ready
5-
# HTML files and assets generated by the build. If a base directory has
6-
# been specified, include it in the publish directory path.
7-
publish = "website/build/redux-toolkit/"
2+
base = "website"
3+
publish = "website/build"
4+
command = "yarn build"

website/.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# dependencies
2+
node_modules/
3+
4+
# production
5+
/build
6+
7+
# generated files
8+
.docusaurus/
9+
.cache-loader
10+
11+
# misc
12+
.DS_Store
13+
.env.local
14+
.env.development.local
15+
.env.test.local
16+
.env.production.local
17+
npm-debug.log*
18+
yarn-debug.log*
19+
yarn-error.log*
20+
*.log

website/README.md

Lines changed: 33 additions & 198 deletions
Original file line numberDiff line numberDiff line change
@@ -1,198 +1,33 @@
1-
This website was created with [Docusaurus](https://docusaurus.io/).
2-
3-
# What's In This Document
4-
5-
- [Get Started in 5 Minutes](#get-started-in-5-minutes)
6-
- [Directory Structure](#directory-structure)
7-
- [Editing Content](#editing-content)
8-
- [Adding Content](#adding-content)
9-
- [Full Documentation](#full-documentation)
10-
11-
# Get Started in 5 Minutes
12-
13-
1. Make sure all the dependencies for the website are installed:
14-
15-
```sh
16-
# Install dependencies
17-
$ yarn
18-
```
19-
20-
2. Run your dev server:
21-
22-
```sh
23-
# Start the site
24-
$ yarn start
25-
```
26-
27-
## Directory Structure
28-
29-
Your project file structure should look something like this
30-
31-
```
32-
my-docusaurus/
33-
docs/
34-
doc-1.md
35-
doc-2.md
36-
doc-3.md
37-
website/
38-
blog/
39-
2016-3-11-oldest-post.md
40-
2017-10-24-newest-post.md
41-
core/
42-
node_modules/
43-
pages/
44-
static/
45-
css/
46-
img/
47-
package.json
48-
sidebar.json
49-
siteConfig.js
50-
```
51-
52-
# Editing Content
53-
54-
## Editing an existing docs page
55-
56-
Edit docs by navigating to `docs/` and editing the corresponding document:
57-
58-
`docs/doc-to-be-edited.md`
59-
60-
```markdown
61-
---
62-
id: page-needs-edit
63-
title: This Doc Needs To Be Edited
64-
---
65-
66-
Edit me...
67-
```
68-
69-
For more information about docs, click [here](https://docusaurus.io/docs/en/navigation)
70-
71-
## Editing an existing blog post
72-
73-
Edit blog posts by navigating to `website/blog` and editing the corresponding post:
74-
75-
`website/blog/post-to-be-edited.md`
76-
77-
```markdown
78-
---
79-
id: post-needs-edit
80-
title: This Blog Post Needs To Be Edited
81-
---
82-
83-
Edit me...
84-
```
85-
86-
For more information about blog posts, click [here](https://docusaurus.io/docs/en/adding-blog)
87-
88-
# Adding Content
89-
90-
## Adding a new docs page to an existing sidebar
91-
92-
1. Create the doc as a new markdown file in `/docs`, example `docs/newly-created-doc.md`:
93-
94-
```md
95-
---
96-
id: newly-created-doc
97-
title: This Doc Needs To Be Edited
98-
---
99-
100-
My new content here..
101-
```
102-
103-
1. Refer to that doc's ID in an existing sidebar in `website/sidebar.json`:
104-
105-
```javascript
106-
// Add newly-created-doc to the Getting Started category of docs
107-
{
108-
"docs": {
109-
"Getting Started": [
110-
"quick-start",
111-
"newly-created-doc" // new doc here
112-
],
113-
...
114-
},
115-
...
116-
}
117-
```
118-
119-
For more information about adding new docs, click [here](https://docusaurus.io/docs/en/navigation)
120-
121-
## Adding a new blog post
122-
123-
1. Make sure there is a header link to your blog in `website/siteConfig.js`:
124-
125-
`website/siteConfig.js`
126-
127-
```javascript
128-
headerLinks: [
129-
...
130-
{ blog: true, label: 'Blog' },
131-
...
132-
]
133-
```
134-
135-
2. Create the blog post with the format `YYYY-MM-DD-My-Blog-Post-Title.md` in `website/blog`:
136-
137-
`website/blog/2018-05-21-New-Blog-Post.md`
138-
139-
```markdown
140-
---
141-
author: Frank Li
142-
authorURL: https://twitter.com/foobarbaz
143-
authorFBID: 503283835
144-
title: New Blog Post
145-
---
146-
147-
Lorem Ipsum...
148-
```
149-
150-
For more information about blog posts, click [here](https://docusaurus.io/docs/en/adding-blog)
151-
152-
## Adding items to your site's top navigation bar
153-
154-
1. Add links to docs, custom pages or external links by editing the headerLinks field of `website/siteConfig.js`:
155-
156-
`website/siteConfig.js`
157-
158-
```javascript
159-
{
160-
headerLinks: [
161-
...
162-
/* you can add docs */
163-
{ doc: 'my-examples', label: 'Examples' },
164-
/* you can add custom pages */
165-
{ page: 'help', label: 'Help' },
166-
/* you can add external links */
167-
{ href: 'https://github.com/facebook/Docusaurus', label: 'GitHub' },
168-
...
169-
],
170-
...
171-
}
172-
```
173-
174-
For more information about the navigation bar, click [here](https://docusaurus.io/docs/en/navigation)
175-
176-
## Adding custom pages
177-
178-
1. Docusaurus uses React components to build pages. The components are saved as .js files in `website/pages/en`:
179-
1. If you want your page to show up in your navigation header, you will need to update `website/siteConfig.js` to add to the `headerLinks` element:
180-
181-
`website/siteConfig.js`
182-
183-
```javascript
184-
{
185-
headerLinks: [
186-
...
187-
{ page: 'my-new-custom-page', label: 'My New Custom Page' },
188-
...
189-
],
190-
...
191-
}
192-
```
193-
194-
For more information about custom pages, click [here](https://docusaurus.io/docs/en/custom-pages).
195-
196-
# Full Documentation
197-
198-
Full documentation can be found on the [website](https://docusaurus.io/).
1+
# Website
2+
3+
This website is built using Docusaurus 2, a modern static website generator.
4+
5+
### Installation
6+
7+
```
8+
$ yarn
9+
```
10+
11+
### Local Development
12+
13+
```
14+
$ yarn start
15+
```
16+
17+
This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.
18+
19+
### Build
20+
21+
```
22+
$ yarn build
23+
```
24+
25+
This command generates static content into the `build` directory and can be served using any static contents hosting service.
26+
27+
### Deployment
28+
29+
```
30+
$ GIT_USER=<Your GitHub username> USE_SSH=1 yarn deploy
31+
```
32+
33+
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

0 commit comments

Comments
 (0)