docpensieve 0.4.0-beta.1 → 0.4.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -5
- package/src/commands/init.js +4 -0
- package/starter/01-guide/07-migrate-to-beta.md +3 -0
- package/starter/01-guide/08-navigation.mdx +126 -0
- package/starter/03-reference/02-configuration.md +47 -0
- package/starter/03-reference/04-theme.md +7 -0
- package/starter/03-reference/05-api.md +11 -0
- package/starter/05-whats-new.md +14 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docpensieve",
|
|
3
|
-
"version": "0.4.0-beta.
|
|
3
|
+
"version": "0.4.0-beta.2",
|
|
4
4
|
"description": "DocPensieve command-line interface (init, build, check, dev, serve)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"types"
|
|
25
25
|
],
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@docpensieve/components": "0.4.0-beta.
|
|
28
|
-
"@docpensieve/core": "0.4.0-beta.
|
|
29
|
-
"@docpensieve/shared": "0.4.0-beta.
|
|
30
|
-
"@docpensieve/theme": "0.4.0-beta.
|
|
27
|
+
"@docpensieve/components": "0.4.0-beta.2",
|
|
28
|
+
"@docpensieve/core": "0.4.0-beta.2",
|
|
29
|
+
"@docpensieve/shared": "0.4.0-beta.2",
|
|
30
|
+
"@docpensieve/theme": "0.4.0-beta.2",
|
|
31
31
|
"chalk": "^6.0.0",
|
|
32
32
|
"chokidar": "^5.0.0",
|
|
33
33
|
"commander": "^15.0.0"
|
package/src/commands/init.js
CHANGED
|
@@ -284,6 +284,10 @@ function renderConfig({ name, theme, siteUrl, version }) {
|
|
|
284
284
|
" // on a narrow screen. For instance [{ label: 'Blog', href: '/blog/' }].",
|
|
285
285
|
' headerLinks: [],',
|
|
286
286
|
'',
|
|
287
|
+
' // Categories of the menu fold, opened on the branch of the page being',
|
|
288
|
+
' // read. Useful once the documentation is long.',
|
|
289
|
+
' foldedSidebar: false,',
|
|
290
|
+
'',
|
|
287
291
|
' // The shipped components — Card, Columns, Tooltip… — usable in any .mdx',
|
|
288
292
|
' // page without an import. false removes them, to use your own names.',
|
|
289
293
|
' globalComponents: true,',
|
|
@@ -22,3 +22,6 @@ Through `npx` alone, `npx docpensieve@beta` runs the beta. Going back is
|
|
|
22
22
|
|
|
23
23
|
Nothing yet: the 0.4 has just opened. Each change is listed here as it lands,
|
|
24
24
|
beside what it asks of a project already built on the 0.3.
|
|
25
|
+
|
|
26
|
+
One thing changes on its own: on a narrow screen, the menu of the documentation
|
|
27
|
+
now folds above the content instead of standing open. Nothing to configure.
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Navigation
|
|
3
|
+
description: The menu of the documentation, the links of the header, and what becomes of both on a phone.
|
|
4
|
+
tags: [guide, navigation]
|
|
5
|
+
|
|
6
|
+
jsonld:
|
|
7
|
+
type: TechArticle
|
|
8
|
+
breadcrumbs: true
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
# Navigation
|
|
12
|
+
|
|
13
|
+
A reader finds a page in one of two ways: the menu of the documentation, on the
|
|
14
|
+
left, or the header, at the top. They answer different questions — _where am I
|
|
15
|
+
in this documentation_ and _where else can I go_ — and a site may use one, the
|
|
16
|
+
other, or both.
|
|
17
|
+
|
|
18
|
+
Neither loads a script. Everything here folds and unfolds with native elements.
|
|
19
|
+
|
|
20
|
+
## The menu of the documentation
|
|
21
|
+
|
|
22
|
+
It follows the file tree, or the file you describe — that is
|
|
23
|
+
[Writing the menu by hand](./writing-pages/). What changes here is how much of
|
|
24
|
+
it shows at once.
|
|
25
|
+
|
|
26
|
+
### Folding the categories
|
|
27
|
+
|
|
28
|
+
```js
|
|
29
|
+
// docpensieve.config.mjs
|
|
30
|
+
foldedSidebar: true,
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Every category becomes a fold. **The branch holding the page being read is
|
|
34
|
+
open, the others closed**, so a menu of a hundred entries stops asking the
|
|
35
|
+
reader to scroll past what does not concern them.
|
|
36
|
+
|
|
37
|
+
<Columns>
|
|
38
|
+
<Column span={6}>
|
|
39
|
+
<Card style={{ height: '100%' }}>
|
|
40
|
+
<CardHeader>Unfolded — the default</CardHeader>
|
|
41
|
+
<CardBody>
|
|
42
|
+
Everything is visible at once. Right for a documentation of a few dozen pages, where
|
|
43
|
+
scrolling the menu costs nothing.
|
|
44
|
+
</CardBody>
|
|
45
|
+
</Card>
|
|
46
|
+
</Column>
|
|
47
|
+
<Column span={6}>
|
|
48
|
+
<Card style={{ height: '100%', borderColor: 'var(--dp-accent)' }}>
|
|
49
|
+
<CardHeader>Folded</CardHeader>
|
|
50
|
+
<CardBody>
|
|
51
|
+
Only the branch being read is open. Right once the menu is long enough that its end is out
|
|
52
|
+
of sight.
|
|
53
|
+
</CardBody>
|
|
54
|
+
</Card>
|
|
55
|
+
</Column>
|
|
56
|
+
</Columns>
|
|
57
|
+
|
|
58
|
+
A category that is also a page gains that page as its first entry. The handle
|
|
59
|
+
of a fold cannot be a link as well — a click would mean two things, and the
|
|
60
|
+
page would become unreachable.
|
|
61
|
+
|
|
62
|
+
## The header
|
|
63
|
+
|
|
64
|
+
`headerLinks` puts links beside the version switcher.
|
|
65
|
+
|
|
66
|
+
```js
|
|
67
|
+
headerLinks: [{ label: 'Blog', href: '/blog/' }],
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
A target starts from the root of a version — `/blog/` — or is a full address. A
|
|
71
|
+
relative target is refused: the header is on every page, and `blog/` would mean
|
|
72
|
+
something else on each.
|
|
73
|
+
|
|
74
|
+
### A section that lives in one version
|
|
75
|
+
|
|
76
|
+
A link may name the version it leads to:
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
{ label: 'Examples', href: '/examples/', version: 'latest' },
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Every version then leads there, which is what keeps a section written in one
|
|
83
|
+
version reachable from all of them. This site does exactly that for its
|
|
84
|
+
examples.
|
|
85
|
+
|
|
86
|
+
### A panel of links
|
|
87
|
+
|
|
88
|
+
An entry carrying `columns` opens a panel instead of leading anywhere:
|
|
89
|
+
|
|
90
|
+
```js
|
|
91
|
+
{
|
|
92
|
+
label: 'Product',
|
|
93
|
+
columns: [
|
|
94
|
+
{
|
|
95
|
+
title: 'Guide',
|
|
96
|
+
items: [
|
|
97
|
+
{ label: 'Installation', href: '/guide/installation/' },
|
|
98
|
+
{ label: 'First site', href: '/guide/first-site/' },
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
{ items: [{ label: 'Repository', href: 'https://github.com/me/my-project' }] },
|
|
102
|
+
],
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
A column may go without a title. An entry cannot carry both `href` and
|
|
107
|
+
`columns`: it either leads somewhere or opens a panel.
|
|
108
|
+
|
|
109
|
+
The panel is declared here, **not derived from the menu of the documentation**.
|
|
110
|
+
The two are therefore free to show different things — or a site without a
|
|
111
|
+
sidebar can navigate from the header alone.
|
|
112
|
+
|
|
113
|
+
## On a phone
|
|
114
|
+
|
|
115
|
+
Nothing is left to overflow off the screen.
|
|
116
|
+
|
|
117
|
+
| What | Below 48rem | Below 56rem |
|
|
118
|
+
| -------------------------------------- | ------------------------------------ | ----------------------------------------------- |
|
|
119
|
+
| Version switcher, links, panel, search | Behind the menu button of the header | — |
|
|
120
|
+
| Menu of the documentation | — | Folded above the content, behind its own button |
|
|
121
|
+
|
|
122
|
+
The panel of links unfolds inside the header menu rather than over it, and the
|
|
123
|
+
documentation menu starts closed: open, it would fill the first screen before a
|
|
124
|
+
word is read.
|
|
125
|
+
|
|
126
|
+
Both buttons are native elements. With JavaScript turned off, they still open.
|
|
@@ -60,6 +60,7 @@ can change.
|
|
|
60
60
|
| `sidebar` | `'auto'` | `'auto'`: the menu follows the file tree. Or a `.json` file of each version folder |
|
|
61
61
|
| `authors` | `''` | A `.json` file describing the authors, in each version folder that has one |
|
|
62
62
|
| `headerLinks` | `[]` | Links of the header, beside the version switcher |
|
|
63
|
+
| `foldedSidebar` | `false` | Categories of the menu fold, opened where the reader stands |
|
|
63
64
|
| `globalComponents` | `true` | Shipped components available without an import |
|
|
64
65
|
| `scrollToTop` | `true` | Back-to-top button on every page |
|
|
65
66
|
| `jsonld` | `{ enabled: true }` | Structured data |
|
|
@@ -220,6 +221,52 @@ On a narrow screen, the version switcher, the links and the search field move
|
|
|
220
221
|
behind a menu button. It is a native element that opens without a script, like
|
|
221
222
|
the version switcher itself.
|
|
222
223
|
|
|
224
|
+
### A panel of links
|
|
225
|
+
|
|
226
|
+
An entry carrying `columns` opens a panel instead of leading anywhere:
|
|
227
|
+
|
|
228
|
+
```js
|
|
229
|
+
headerLinks: [
|
|
230
|
+
{
|
|
231
|
+
label: 'Product',
|
|
232
|
+
columns: [
|
|
233
|
+
{
|
|
234
|
+
title: 'Guide',
|
|
235
|
+
items: [
|
|
236
|
+
{ label: 'Install', href: '/guide/installation/' },
|
|
237
|
+
{ label: 'Deploy', href: '/guide/deployment/' },
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
{ items: [{ label: 'Repository', href: 'https://github.com/me/my-project' }] },
|
|
241
|
+
],
|
|
242
|
+
},
|
|
243
|
+
],
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
A column may go without a title. Every link follows the rules above — absolute
|
|
247
|
+
target, optional `version`. An entry cannot carry both `href` and `columns`: it
|
|
248
|
+
either leads somewhere or opens a panel, never both.
|
|
249
|
+
|
|
250
|
+
The panel is declared here, not derived from the menu of the documentation: the
|
|
251
|
+
two can stand side by side with different links, or the site can go without a
|
|
252
|
+
sidebar and navigate from the header alone.
|
|
253
|
+
|
|
254
|
+
## `foldedSidebar`
|
|
255
|
+
|
|
256
|
+
```js
|
|
257
|
+
foldedSidebar: true,
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
Every category of the menu becomes a fold. The branch holding the page being
|
|
261
|
+
read is open, the others closed: a menu of a hundred pages stops asking the
|
|
262
|
+
reader to scroll past what does not concern them. It folds without a script.
|
|
263
|
+
|
|
264
|
+
A category that is also a page gains that page as its first entry: the handle
|
|
265
|
+
of a fold cannot be a link as well without a click meaning two things.
|
|
266
|
+
|
|
267
|
+
Left to `false`, the menu shows whole, as before. On a narrow screen the whole
|
|
268
|
+
menu folds above the content either way, since the column has nowhere to stand.
|
|
269
|
+
|
|
223
270
|
## `sidebar`
|
|
224
271
|
|
|
225
272
|
`'auto'` builds the menu from the file tree: folders become categories, and the
|
|
@@ -105,6 +105,13 @@ the `dp-*` class below.
|
|
|
105
105
|
| `headerLinks` | `dp-header-links` | Links of the header |
|
|
106
106
|
| `menu` | `dp-menu` | Menu button, on a narrow screen |
|
|
107
107
|
| `menuPanel` | `dp-menu-panel` | What that button opens |
|
|
108
|
+
| `navGroup` | `dp-nav-group` | A folded category of the menu |
|
|
109
|
+
| `navSummary` | `dp-nav-summary` | The handle of that fold |
|
|
110
|
+
| `sidebarMenu` | `dp-sidebar-menu` | The documentation menu, on a narrow screen |
|
|
111
|
+
| `mega` | `dp-mega` | A header entry that opens a panel |
|
|
112
|
+
| `megaPanel` | `dp-mega-panel` | That panel |
|
|
113
|
+
| `megaColumn` | `dp-mega-column` | A column of the panel |
|
|
114
|
+
| `megaTitle` | `dp-mega-title` | The title of a column |
|
|
108
115
|
| `byline` | `dp-byline` | Authors and dates at the head of a page |
|
|
109
116
|
| `bylineAuthors` | `dp-byline-authors` | List of the authors |
|
|
110
117
|
| `bylineAuthor` | `dp-byline-author` | One author |
|
|
@@ -443,6 +443,17 @@ humanised from their slug by `StructuredDataBuilder`.
|
|
|
443
443
|
|
|
444
444
|
**Returns** `Record<string, string>` — Full folder slug to title.
|
|
445
445
|
|
|
446
|
+
### `foldSidebar`
|
|
447
|
+
|
|
448
|
+
`foldSidebar(nodes, [currentUrl])`
|
|
449
|
+
|
|
450
|
+
| Parameter | Type | |
|
|
451
|
+
| --- | --- | --- |
|
|
452
|
+
| `nodes` | `SidebarNode[]` | |
|
|
453
|
+
| `[currentUrl]` | `string` | URL of the page being rendered. |
|
|
454
|
+
|
|
455
|
+
**Returns** `FoldedNode[]`
|
|
456
|
+
|
|
446
457
|
### `buildFeed`
|
|
447
458
|
|
|
448
459
|
`buildFeed(pages, site)`
|
package/starter/05-whats-new.md
CHANGED
|
@@ -16,10 +16,20 @@ npx docpensieve@beta init my-site
|
|
|
16
16
|
|
|
17
17
|
## Already there
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
Each feature is announced here as it lands,
|
|
21
|
-
reference — this page announces, it is never
|
|
22
|
-
written.
|
|
19
|
+
The 0.4 has just opened. What follows is what it already brings, and the rest of
|
|
20
|
+
its pages are still those of the 0.3. Each feature is announced here as it lands,
|
|
21
|
+
with a link to the guide and to the reference — this page announces, it is never
|
|
22
|
+
the only place something is written.
|
|
23
|
+
|
|
24
|
+
### A menu that folds, and a panel of links in the header
|
|
25
|
+
|
|
26
|
+
`foldedSidebar: true` folds the categories of the menu, open on the branch the
|
|
27
|
+
reader stands in. On a narrow screen the whole menu folds above the content,
|
|
28
|
+
whatever that setting. And a `headerLinks` entry carrying `columns` opens a
|
|
29
|
+
panel of links instead of leading anywhere — declared on its own, so a site can
|
|
30
|
+
navigate from the header alone, or from both. See
|
|
31
|
+
[Navigation](./guide/navigation/) in the guide, and
|
|
32
|
+
[the configuration reference](./reference/configuration/).
|
|
23
33
|
|
|
24
34
|
## For a 0.3 project
|
|
25
35
|
|