Skip to content

Commit 2446208

Browse files
author
cvluca
committed
enable optional sidebar and anchor
1 parent e7fff31 commit 2446208

File tree

16 files changed

+191
-76
lines changed

16 files changed

+191
-76
lines changed

contents/blog/first-blog.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ title: First Blog
44
rootPage: /blog
55
sidebar: Blog
66
showTitle: true
7+
hideAnchor: true
78
---
89
[Next Blog](/blog/second-blog)

contents/blog/second-blog.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ title: Second Blog
44
rootPage: /blog
55
sidebar: Blog
66
showTitle: true
7+
hideAnchor: true
78
---
89
[Previous Blog](/blog/first-blog)

contents/docs/guide/anchor.md

+4
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ The anchor will be generated with different layers based on the size of the head
2222
Check the anchor on the right.
2323

2424
#### The smaller heading
25+
26+
## Hide Anchor
27+
28+
The anchor can be hide by setting `hideAnchor` on the top of the markdown file (see [contents](/docs/guide/contents#information-of-the-page)).

contents/docs/guide/contents.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: Contents
33
sidebar: Docs
44
showTitle: true
5+
hideAnchor: false
56
---
67
## Source of contents
78

@@ -23,11 +24,12 @@ The information of the page is stored on the top of the markdown files used to g
2324

2425
* `title`: the title of the page
2526
* `showTitle`: show the title on the center at the beginning
26-
* `date`: the date created
2727
* `sidebar`: entry of the sidebar (see [sidebar](/docs/guide/sidebar)).
28+
* `hideAnchor`: hide anchor (false by default)
2829

29-
You can add any additional information and querying with GraphQL. For blog in the example:
30+
If you use the default setting, you should have at least one file contains each setting. You can add any additional information and querying with GraphQL. For blog in the example:
3031

32+
* `date`: the date created
3133
* `rootPage`: is used to filter the posts by the root page (i.e. [/blog](/blog))
3234

3335
### Example

contents/docs/guide/menu-items.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ See the current file. `Docs` is linked directly to the markdown page, and `Blog`
1616
```sh
1717
# /src/menuItems/menuItems.json
1818
[
19-
{
19+
{
2020
"name": "Docs",
2121
"link": "/docs/get-started/introduction"
2222
},

contents/docs/guide/sidebar.md

+6
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,9 @@ The current page contains a multiple level of sidebar, and it's defined with thr
8585
If the root entry is `Docs`, the `child_entries` will be added as the SubMenus (i.e. `Get Started` and `Guide`).
8686

8787
It is allowed to contains both `child_entries` and `items` in single entry object, and the posts (i.e. `items`) will be rendered before the SubMenus (i.e. `child_entries`) on the sidebar.
88+
89+
The order of items in the sidebar is based on the order you defined in `child_entries` and `items` in this file.
90+
91+
## Hide Sidebar
92+
93+
If you do not add `sidebar` entry in the markdown file (see [contents](/docs/guide/contents#information-of-the-page)), or set it to null, the sidebar will be hided.

package-lock.json

+76-49
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
"dependencies": {
77
"antd": "^3.23.2",
88
"eslint-plugin-flowtype": "^2.50.3",
9-
"gatsby": "^2.15.14",
9+
"gatsby": "^2.15.15",
1010
"gatsby-cli": "^2.7.47",
11-
"gatsby-image": "^2.2.18",
11+
"gatsby-image": "^2.2.19",
1212
"gatsby-plugin-manifest": "^2.2.16",
1313
"gatsby-plugin-offline": "^2.2.10",
1414
"gatsby-plugin-react-helmet": "^3.1.7",
15-
"gatsby-plugin-sharp": "^2.2.21",
15+
"gatsby-plugin-sharp": "^2.2.22",
1616
"gatsby-remark-autolink-headers": "^2.1.10",
17-
"gatsby-remark-images": "^3.1.21",
17+
"gatsby-remark-images": "^3.1.22",
1818
"gatsby-remark-katex": "^3.1.8",
1919
"gatsby-source-filesystem": "^2.1.22",
2020
"gatsby-transformer-json": "^2.2.8",
@@ -43,8 +43,8 @@
4343
"devDependencies": {
4444
"gatsby-plugin-remove-trailing-slashes": "^2.1.6",
4545
"gh-pages": "^2.1.1",
46-
"prettier": "^1.18.2",
47-
"mem": ">=4.0.0"
46+
"mem": "^5.1.1",
47+
"prettier": "^1.18.2"
4848
},
4949
"repository": {
5050
"type": "git",

src/actions/actionTypes.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// sidebar
22
export const SET_SIDEBAR_OPEN = "SET_SIDEBAR_OPEN";
33
export const SET_SIDEBAR_DOCKED = "SET_SIDEBAR_DOCKED";
4+
export const SET_SIDEBAR_HIDE = "SET_SIDEBAR_HIDE";
45

56
// sidebar content
67
export const SET_SIDEBAR_CONTENT_ENTRY = "SET_SIDEBAR_CONTENT_ENTRY";
@@ -10,6 +11,7 @@ export const ON_SIDEBAR_CONTENT_SELECTED = "ON_SIDEBAR_CONTENT_SELECTED";
1011

1112
// anchor
1213
export const SET_ANCHOR_OPEN = "SET_ANCHOR_OPEN";
14+
export const SET_ANCHOR_HIDE = "SET_ANCHOR_HIDE";
1315

1416
// menu
1517
export const ON_CHANGE_MENU_STATE = "ON_CHANGE_MENU_STATE";

0 commit comments

Comments
 (0)