Skip to content

Commit 9cbdc69

Browse files
sveinpgmarkerikson
authored andcommitted
#1031 Set up basic docusaurus structure (#1032)
* #1031 Set up basic docusaurus structure * Removed docker related files * Added metadata to the doc files * Code review: Moved docusaurus website to the top level of the repo and updated values in siteConfig.js according to comments by @markerikson
1 parent cf91991 commit 9cbdc69

File tree

13 files changed

+548
-4
lines changed

13 files changed

+548
-4
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,12 @@ test/**/lcov-report
1111
test/react/*/test/**/*.spec.js
1212
test/react/**/src
1313
lcov.info
14+
15+
lib/core/metadata.js
16+
lib/core/MetadataBlog.js
17+
18+
website/translated_docs
19+
website/build/
20+
website/yarn.lock
21+
website/node_modules
22+
website/i18n/*

docs/GettingStarted.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
id: getting-started
3+
title: Getting started
4+
sidebar_label: Getting started
5+
---
6+
17
# Getting Started
28

39
[React-Redux](https://github.com/reduxjs/react-redux) is the official [React](https://reactjs.org/) binding for [Redux](https://redux.js.org/). It lets your React components read data from a Redux store, and dispatch actions to the store to update data.

docs/api.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
## API
1+
---
2+
id: api
3+
title: Api
4+
sidebar_label: Api
5+
---
6+
7+
# API
28

39
<a id="provider"></a>
410
### `<Provider store>`
@@ -52,7 +58,7 @@ It does not modify the component class passed to it; instead, it *returns* a new
5258
<a id="connect-arguments"></a>
5359
#### Arguments
5460

55-
* [`mapStateToProps(state, [ownProps]): stateProps`] \(*Function*): If this argument is specified, the new component will subscribe to Redux store updates. This means that any time the store is updated, `mapStateToProps` will be called. The results of `mapStateToProps` must be a plain object, which will be merged into the component’s props. If you don't want to subscribe to store updates, pass `null` or `undefined` in place of `mapStateToProps`.
61+
* [`mapStateToProps(state, [ownProps]): stateProps`] \(*Function*): If this argument is specified, the new component will subscribe to Redux store updates. This means that any time the store is updated, `mapStateToProps` will be called. The results of `mapStateToProps` must be a plain object, which will be merged into the component’s props. If you don't want to subscribe to store updates, pass `null` or `undefined` in place of `mapStateToProps`.
5662

5763
If your `mapStateToProps` function is declared as taking two parameters, it will be called with the store state as the first parameter and the props passed to the connected component as the second parameter, and will also be re-invoked whenever the connected component receives new props as determined by shallow equality comparisons. (The second parameter is normally referred to as `ownProps` by convention.)
5864

@@ -63,7 +69,7 @@ It does not modify the component class passed to it; instead, it *returns* a new
6369
* [`mapDispatchToProps(dispatch, [ownProps]): dispatchProps`] \(*Object* or *Function*): If an object is passed, each function inside it is assumed to be a Redux action creator. An object with the same function names, but with every action creator wrapped into a `dispatch` call so they may be invoked directly, will be merged into the component’s props.
6470

6571
If a function is passed, it will be given `dispatch` as the first parameter. It’s up to you to return an object that somehow uses `dispatch` to bind action creators in your own way. (Tip: you may use the [`bindActionCreators()`](https://redux.js.org/api-reference/bindactioncreators) helper from Redux.)
66-
72+
6773
If your `mapDispatchToProps` function is declared as taking two parameters, it will be called with `dispatch` as the first parameter and the props passed to the connected component as the second parameter, and will be re-invoked whenever the connected component receives new props. (The second parameter is normally referred to as `ownProps` by convention.)
6874

6975
If you do not supply your own `mapDispatchToProps` function or object full of action creators, the default `mapDispatchToProps` implementation just injects `dispatch` into your component’s props.
@@ -382,7 +388,7 @@ It does not modify the component class passed to it; instead, it *returns* a new
382388
* [`storeKey`] *(String)*: the key of props/context to get the store. You probably only need this if you are in the inadvisable position of having multiple stores. Default value: `'store'`
383389

384390
* [`withRef`] *(Boolean)*: If true, stores a ref to the wrapped component instance and makes it available via `getWrappedInstance()` method. Default value: `false`
385-
391+
386392
* Additionally, any extra options passed via `connectOptions` will be passed through to your `selectorFactory` in the `factoryOptions` argument.
387393

388394
<a id="connectAdvanced-returns"></a>

docs/troubleshooting.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
---
2+
id: troubleshooting
3+
title: Troubleshooting
4+
sidebar_label: Troubleshooting
5+
---
6+
17
## Troubleshooting
28

39
Make sure to check out [Troubleshooting Redux](http://redux.js.org/docs/Troubleshooting.html) first.

website/README.md

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

website/core/Footer.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* Copyright (c) 2017-present, Facebook, Inc.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*/
7+
8+
const React = require("react");
9+
10+
class Footer extends React.Component {
11+
docUrl(doc, language) {
12+
const baseUrl = this.props.config.baseUrl;
13+
return `${baseUrl}docs/${language ? `${language}/` : ""}${doc}`;
14+
}
15+
16+
pageUrl(doc, language) {
17+
const baseUrl = this.props.config.baseUrl;
18+
return baseUrl + (language ? `${language}/` : "") + doc;
19+
}
20+
21+
render() {
22+
return (
23+
<footer className="nav-footer" id="footer">
24+
<section className="sitemap">
25+
<a href={this.props.config.baseUrl} className="nav-home">
26+
{this.props.config.footerIcon && (
27+
<img
28+
src={this.props.config.baseUrl + this.props.config.footerIcon}
29+
alt={this.props.config.title}
30+
width="66"
31+
height="58"
32+
/>
33+
)}
34+
</a>
35+
<div>
36+
<h5>Docs</h5>
37+
<a href={this.docUrl("getting-started", this.props.language)}>
38+
Getting Started
39+
</a>
40+
<a href={this.docUrl("api", this.props.language)}>
41+
Api
42+
</a>
43+
<a href={this.docUrl("troubleshooting", this.props.language)}>
44+
Troubleshooting
45+
</a>
46+
</div>
47+
<div>
48+
<h5>Community</h5>
49+
<a
50+
href="http://stackoverflow.com/questions/tagged/react-redux"
51+
target="_blank"
52+
rel="noreferrer noopener"
53+
>
54+
Stack Overflow
55+
</a>
56+
</div>
57+
<div>
58+
<h5>More</h5>
59+
<a href={`${this.props.config.baseUrl}blog`}>Blog</a>
60+
<a href="https://github.com/reduxjs/react-redux/">GitHub</a>
61+
<a
62+
className="github-button"
63+
href={this.props.config.repoUrl}
64+
data-icon="octicon-star"
65+
data-count-href="/reduxjs/react-redux/stargazers"
66+
data-show-count="true"
67+
data-count-aria-label="# stargazers on GitHub"
68+
aria-label="Star this project on GitHub"
69+
>
70+
Star
71+
</a>
72+
</div>
73+
</section>
74+
</footer>
75+
);
76+
}
77+
}
78+
79+
module.exports = Footer;

website/package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"scripts": {
3+
"start": "docusaurus-start",
4+
"build": "docusaurus-build",
5+
"publish-gh-pages": "docusaurus-publish",
6+
"write-translations": "docusaurus-write-translations",
7+
"version": "docusaurus-version",
8+
"rename-version": "docusaurus-rename-version"
9+
},
10+
"devDependencies": {
11+
"docusaurus": "^1.4.0"
12+
}
13+
}

0 commit comments

Comments
 (0)