Skip to content

Commit 52589e8

Browse files
Filmbostock
andauthored
document pages (#1109)
* document pages closes #1107 * Update docs/config.md Co-authored-by: Mike Bostock <[email protected]> * finish sentence * doc edits * doc edits --------- Co-authored-by: Mike Bostock <[email protected]>
1 parent 2a886d5 commit 52589e8

File tree

1 file changed

+25
-18
lines changed

1 file changed

+25
-18
lines changed

docs/config.md

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,34 +112,41 @@ Whether to show the sidebar. Defaults to true if **pages** is not empty.
112112

113113
## pages
114114

115-
An array containing pages and/or sections. If not specified, it defaults to all Markdown files found in the source root in directory listing order.
115+
An array containing pages and sections. If not specified, it defaults to all Markdown files found in the source root in directory listing order.
116116

117-
The following TypeScript interfaces describe pages and sections:
117+
Both pages and sections have a **name**, which typically corresponds to the page’s title. The name gets displayed in the sidebar. Clicking on a page navigates to the corresponding **path**, which should start with a leading slash and be relative to the root; the path can also be specified as a full URL to navigate to an external site. Clicking on a section header opens or closes that section. Each section must specify an array of **pages**, and optionally whether the section is **open** by default. If **open** is not set, it defaults to true. If **open** is false, the section is closed unless the current page belongs to that section.
118118

119-
```ts run=false
120-
export interface Page {
121-
name: string;
122-
path: string;
123-
}
124-
```
119+
For example, here **pages** specifies two sections and a total of four pages:
125120

126-
```ts run=false
127-
export interface Section {
128-
name: string;
129-
pages: Page[];
130-
open?: boolean;
121+
```js run=false
122+
export default {
123+
pages: [
124+
{
125+
name: "Section 1",
126+
pages: [
127+
{name: "Page 1", path: "/s01/page1"},
128+
{name: "Page 2", path: "/s01/page2"}
129+
]
130+
},
131+
{
132+
name: "Section 2",
133+
open: false,
134+
pages: [
135+
{name: "Page 3", path: "/s02/page3"},
136+
{name: "Page 4", path: "/s02/page4"}
137+
]
138+
}
139+
]
131140
}
132141
```
133142

134-
If a section’s **open** option is not set, it defaults to true.
135-
136-
Projects can have “unlisted” pages that are not included in the pages list. These pages will still be accessible if linked from other pages or visited directly, but they won’t be listed in the sidebar or linked to via the previous & next footer.
143+
Projects can have “unlisted” pages that are not referenced in **pages**. These pages can still be linked from other pages or visited directly, but they won’t be listed in the sidebar or linked to via the previous & next pager links.
137144

138-
The pages list should _not_ include the root page, `index.md`. Also, we don’t recommend using query strings or anchor fragments, as these will prevent the previous & next footer links from navigating.
145+
The pages list should _not_ include the home page (`/`) as this is automatically linked at the top of the sidebar. We also do not recommend listing the same page multiple times (say with different query parameters or anchor fragments), as this causes the previous & next pager links to cycle.
139146

140147
## pager
141148

142-
Whether to show the previous & next footer links; defaults to true.
149+
Whether to show the previous & next links in the footer; defaults to true. The pages are linked in the same order as they appear in the sidebar.
143150

144151
## head
145152

0 commit comments

Comments
 (0)