docpensieve 0.1.5 → 0.2.0-beta.1

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docpensieve",
3
- "version": "0.1.5",
3
+ "version": "0.2.0-beta.1",
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.1.5",
28
- "@docpensieve/core": "0.1.5",
29
- "@docpensieve/shared": "0.1.5",
30
- "@docpensieve/theme": "0.1.5",
27
+ "@docpensieve/components": "0.2.0-beta.1",
28
+ "@docpensieve/core": "0.2.0-beta.1",
29
+ "@docpensieve/shared": "0.2.0-beta.1",
30
+ "@docpensieve/theme": "0.2.0-beta.1",
31
31
  "chalk": "^6.0.0",
32
32
  "chokidar": "^5.0.0",
33
33
  "commander": "^15.0.0"
@@ -45,7 +45,7 @@
45
45
  "url": "git+https://github.com/Juniors017/docpensieve.git",
46
46
  "directory": "packages/cli"
47
47
  },
48
- "homepage": "https://github.com/Juniors017/docpensieve#readme",
48
+ "homepage": "https://docpensieve.com",
49
49
  "bugs": {
50
50
  "url": "https://github.com/Juniors017/docpensieve/issues"
51
51
  },
@@ -56,7 +56,7 @@ const NOT_INSTALLED = new Set(['index.md', 'index.mdx', 'icons', EXAMPLES_CSS]);
56
56
  const CUSTOM_CSS = fileURLToPath(new URL('../templates/custom.css', import.meta.url));
57
57
 
58
58
  /** Where the generated configuration sends readers for every field. */
59
- const DOCUMENTATION_URL = 'https://juniors017.github.io/docpensieve/';
59
+ const DOCUMENTATION_URL = 'https://docpensieve.com/';
60
60
 
61
61
  /**
62
62
  * Asks a question, with a default value shown between brackets.
@@ -235,6 +235,7 @@ function renderConfig({ name, theme, siteUrl, version }) {
235
235
  " // 'tailwind' compiles the utilities your pages use; 'custom' is a plain",
236
236
  ' // stylesheet with no dependency.',
237
237
  ` framework: ${quote(theme)},`,
238
+ " // 'class' follows the reader's system; 'dark' or 'light' keeps one scheme.",
238
239
  " darkMode: 'class',",
239
240
  '',
240
241
  ' // Design tokens to override, for instance the accent colour:',
@@ -256,7 +257,9 @@ function renderConfig({ name, theme, siteUrl, version }) {
256
257
  : []),
257
258
  ' },',
258
259
  '',
259
- " // 'auto': the menu follows the folders and the 01-, 02- prefixes.",
260
+ " // 'auto': the menu follows the folders and the 01-, 02- prefixes. To write",
261
+ " // it by hand, name a JSON file instead — 'sidebar.json' — read from each",
262
+ ' // version folder.',
260
263
  " sidebar: 'auto',",
261
264
  '',
262
265
  ' // The shipped components — Card, Columns, Tooltip… — usable in any .mdx',
@@ -268,6 +271,21 @@ function renderConfig({ name, theme, siteUrl, version }) {
268
271
  '',
269
272
  ' // Structured data (JSON-LD) generated from the frontmatter of each page.',
270
273
  ' jsonld: { enabled: true },',
274
+ '',
275
+ ' // sitemap.xml of the published versions, for search engines — written',
276
+ ' // once siteUrl is set. robots.txt joins it when the site is served at',
277
+ ' // the root of its domain.',
278
+ // Commented out until siteUrl is known: written explicitly, it asks for a
279
+ // sitemap that cannot be built yet, and the configuration refuses it.
280
+ siteUrl ? ' sitemap: true,' : ' // sitemap: true,',
281
+ '',
282
+ ' // RSS feed of the pages that carry a date, at the root of the site. It',
283
+ ' // needs siteUrl.',
284
+ ' feed: false,',
285
+ '',
286
+ ' // A search field in the header, and a search page built with the site.',
287
+ ' // Content pages load no script: the search page alone does.',
288
+ ' search: true,',
271
289
  '};',
272
290
  '',
273
291
  '// Every field is described in the reference of the DocPensieve documentation:',
@@ -65,6 +65,30 @@ docs/v1.0/
65
65
  └── 01-card.mdx
66
66
  ```
67
67
 
68
+ ## Writing the menu by hand
69
+
70
+ When the file tree does not give the menu you want, describe it in a JSON file
71
+ of the version's folder, and name it in the configuration:
72
+
73
+ ```js
74
+ // docpensieve.config.mjs
75
+ sidebar: 'sidebar.json',
76
+ ```
77
+
78
+ ```json
79
+ [
80
+ "/",
81
+ { "label": "Start here", "items": ["guide/installation", "guide/first-site"] },
82
+ { "auto": "components" },
83
+ { "label": "Repository", "href": "https://github.com/me/my-project" }
84
+ ]
85
+ ```
86
+
87
+ A page is named by its path, as in its URL. `{ "auto": "components" }` keeps
88
+ the automatic menu of a folder — the DocPensieve section stays whole that way.
89
+ A page the file leaves out is still published, only off the menu. Every kind
90
+ of entry is in the [`sidebar` reference](../reference/configuration/).
91
+
68
92
  ## Internal links
69
93
 
70
94
  Two spellings, two meanings:
@@ -92,6 +116,12 @@ An image sits next to the page and is written relatively:
92
116
  Files that are not pages are copied as is into the output, at the same
93
117
  relative place. The path is rewritten like a link.
94
118
 
119
+ The build reads the width and height of each image from its file — PNG, JPEG,
120
+ GIF, WebP or SVG — and writes them on the page: the browser keeps the room
121
+ before the image arrives, instead of shifting the text when it does. Every
122
+ image but the first loads lazily, when the reader nears it; the first, often in
123
+ view, keeps its normal loading.
124
+
95
125
  ## Components
96
126
 
97
127
  In an `.mdx` page, the shipped components are used **without an import**:
@@ -122,3 +122,14 @@ result years later.
122
122
 
123
123
  The branch model answers this — each compiled version on its own orphan branch,
124
124
  with its history. See [Versions](./versions/).
125
+
126
+ ## Search engines and feed readers
127
+
128
+ With `siteUrl` set, the build writes `sitemap.xml` at the root of the site —
129
+ every published version, a version in preparation excepted. Give its address
130
+ to the search engines you care about; `robots.txt` names it for them when the
131
+ site sits at the root of its domain.
132
+
133
+ For pages that are news rather than reference — release notes, a changelog —
134
+ give them a `date` and set `feed: true`: `feed.xml` then lists them, newest
135
+ first. The fields are in the [configuration reference](../reference/configuration/).
@@ -190,7 +190,7 @@ carrying the caption.
190
190
  <div className="text-4xl font-semibold text-indigo-600">0</div>
191
191
  <div className="text-sm">bytes of JavaScript</div>
192
192
  </CardBody>
193
- <CardFooter>on every delivered page</CardFooter>
193
+ <CardFooter>on every content page</CardFooter>
194
194
  </Card>
195
195
  </Column>
196
196
  <Column span={4}>
@@ -223,7 +223,7 @@ carrying the caption.
223
223
  <div className="figure">0</div>
224
224
  <div className="small">bytes of JavaScript</div>
225
225
  </CardBody>
226
- <CardFooter>on every delivered page</CardFooter>
226
+ <CardFooter>on every content page</CardFooter>
227
227
  </Card>
228
228
  </Column>
229
229
  <Column span={4}>
@@ -93,7 +93,7 @@ The shipped components avoid that clipping wherever they can — a `Card` rounds
93
93
  the corners of its image one by one rather than clipping its content.
94
94
 
95
95
  The bubble does not close with the Escape key: listening for it would take a
96
- script, and the site loads none. It disappears when the pointer or the focus
96
+ script, and content pages load none. It disappears when the pointer or the focus
97
97
  leaves the term.
98
98
 
99
99
  A `Tooltip` without text stops the build: a hover with no effect goes
@@ -146,5 +146,5 @@ folder: each one stops the build, naming the expected path. A missing icon
146
146
  would otherwise leave an empty box that nobody notices.
147
147
 
148
148
  The scripts and event handlers present in a file are removed before inlining.
149
- The produced site loads no JavaScript, and a component is not going to
150
- introduce any.
149
+ Content pages load no JavaScript, and a component is not going to introduce
150
+ any.
@@ -75,7 +75,8 @@ changes the examples too.
75
75
 
76
76
  ## Without JavaScript
77
77
 
78
- The produced site loads no script. Whatever needs interaction therefore goes
78
+ Content pages load no script — the search page alone does. Whatever needs
79
+ interaction therefore goes
79
80
  through native elements or through CSS: `details` for expanding, a link for
80
81
  moving, `animation-timeline` for appearing on scroll.
81
82
 
@@ -49,22 +49,25 @@ can change.
49
49
 
50
50
  ## The fields
51
51
 
52
- | Field | Default | Effect |
53
- | ------------------ | ------------------- | --------------------------------------------------------------------------- |
54
- | `projectName` | `'Documentation'` | Name shown in the header and in the JSON-LD |
55
- | `siteUrl` | `''` | Public URL. Used for the `canonical` and the JSON-LD |
56
- | `baseUrl` | `'/'` | Deployment prefix. Derived from `siteUrl` when omitted |
57
- | `outDir` | `'dist'` | Output folder, relative to the root |
58
- | `versions` | `[]` | At least one entry |
59
- | `theme` | see below | Styling |
60
- | `sidebar` | `'auto'` | `'auto'`: the sidebar follows the file tree. The only value written so far |
61
- | `globalComponents` | `true` | Shipped components available without an import |
62
- | `scrollToTop` | `true` | Back-to-top button on every page |
63
- | `jsonld` | `{ enabled: true }` | Structured data |
64
- | `lang` | `'en'` | Language of the document, in `<html lang>`. The shell's labels stay English |
65
- | `logo` | `''` | Image beside the project name, in the header |
66
- | `favicon` | `''` | Icon of the browser tab: `.ico`, `.png` or `.svg` |
67
- | `socialImage` | `''` | Preview of a shared page. Needs `siteUrl` |
52
+ | Field | Default | Effect |
53
+ | ------------------ | ------------------- | ---------------------------------------------------------------------------------- |
54
+ | `projectName` | `'Documentation'` | Name shown in the header and in the JSON-LD |
55
+ | `siteUrl` | `''` | Public URL. Used for the `canonical` and the JSON-LD |
56
+ | `baseUrl` | `'/'` | Deployment prefix. Derived from `siteUrl` when omitted |
57
+ | `outDir` | `'dist'` | Output folder, relative to the root |
58
+ | `versions` | `[]` | At least one entry |
59
+ | `theme` | see below | Styling |
60
+ | `sidebar` | `'auto'` | `'auto'`: the menu follows the file tree. Or a `.json` file of each version folder |
61
+ | `globalComponents` | `true` | Shipped components available without an import |
62
+ | `scrollToTop` | `true` | Back-to-top button on every page |
63
+ | `jsonld` | `{ enabled: true }` | Structured data |
64
+ | `lang` | `'en'` | Language of the document, in `<html lang>`. The shell's labels stay English |
65
+ | `logo` | `''` | Image beside the project name, in the header |
66
+ | `favicon` | `''` | Icon of the browser tab: `.ico`, `.png` or `.svg` |
67
+ | `socialImage` | `''` | Preview of a shared page. Needs `siteUrl` |
68
+ | `sitemap` | `true` | `sitemap.xml` of the published versions, once `siteUrl` is set |
69
+ | `feed` | `false` | RSS feed of the dated pages. Needs `siteUrl` |
70
+ | `search` | `true` | Search field in the header, and a search page built with the site |
68
71
 
69
72
  ## Images
70
73
 
@@ -87,6 +90,45 @@ version, under `assets/`, so that a version stays whole on its own branch.
87
90
 
88
91
  A declared image that does not exist stops the build, naming the field.
89
92
 
93
+ ## Sitemap and feed
94
+
95
+ ```js
96
+ siteUrl: 'https://example.com',
97
+ sitemap: true, // the default
98
+ feed: true,
99
+ ```
100
+
101
+ Once `siteUrl` is set, the build writes `sitemap.xml` at the root of the site:
102
+ every page of every version, except a version in preparation, whose pages
103
+ carry `noindex`. Each page is dated by its `modified` frontmatter, or failing
104
+ that its `date`. `sitemap: false` turns it off.
105
+
106
+ `robots.txt` joins it when the site is served at the root of its domain.
107
+ Search engines only read that file there: under a sub-path, it would be
108
+ written for nobody — declare the sitemap to them directly.
109
+
110
+ `feed: true` writes `feed.xml`, an RSS feed of the pages of the current version
111
+ that carry a `date`, newest first, and every page announces it in its head.
112
+ It is off by default: most documentation pages carry no date.
113
+
114
+ Both list absolute addresses: asked for without `siteUrl`, they stop the build.
115
+
116
+ ## Search
117
+
118
+ `search: true`, the default, puts a search field in the header and builds a
119
+ search page in each version, at `/search/`. The build writes the index of the
120
+ version — the plain text of every page — and the search page already lists
121
+ every page with its description.
122
+
123
+ The field is a plain form that leads to that page: **content pages load no
124
+ script**. The search page alone loads one, of a few kilobytes, which filters
125
+ the list as you type, best matches first, with an excerpt of each. Without
126
+ JavaScript, the page stays the full list of pages.
127
+
128
+ The search page is kept out of search engines (`noindex`) and out of the
129
+ sitemap. A page of your own at `/search/` would take its place: the build
130
+ refuses it, and `search: false` frees the address.
131
+
90
132
  ## `versions`
91
133
 
92
134
  ```js
@@ -96,14 +138,16 @@ versions: [
96
138
  ],
97
139
  ```
98
140
 
99
- | Field | Role |
100
- | ------------ | ---------------------------------------------------------------- |
101
- | `slug` | URL and branch identifier |
102
- | `name` | Label shown in the switcher |
103
- | `folder` | Source folder, relative to the root |
104
- | `current` | Version served by default. At most one |
105
- | `archived` | Version kept but no longer maintained. Banner, but stays indexed |
106
- | `prerelease` | Version in preparation. Banner **and** `noindex` |
141
+ | Field | Role |
142
+ | ------------ | ----------------------------------------------------------------------------- |
143
+ | `slug` | URL and branch identifier |
144
+ | `name` | Label shown in the switcher |
145
+ | `folder` | Source folder, relative to the root |
146
+ | `current` | Version served by default. At most one |
147
+ | `archived` | Version kept but no longer maintained. Banner, but stays indexed |
148
+ | `prerelease` | Version in preparation. Banner **and** `noindex` |
149
+ | `logo` | This version's logo, instead of the project's — a beta told apart at a glance |
150
+ | `favicon` | This version's favicon, instead of the project's |
107
151
 
108
152
  ## `theme`
109
153
 
@@ -117,13 +161,13 @@ theme: {
117
161
  },
118
162
  ```
119
163
 
120
- | Field | Effect |
121
- | ----------- | ----------------------------------------- |
122
- | `framework` | `'tailwind'` or `'custom'` |
123
- | `darkMode` | Dark theme strategy |
124
- | `tokens` | Redefined `--dp-*` tokens |
125
- | `css` | CSS appended to the produced stylesheet |
126
- | `source` | Stylesheet handed to the utility compiler |
164
+ | Field | Effect |
165
+ | ----------- | ----------------------------------------------------------------------------- |
166
+ | `framework` | `'tailwind'` or `'custom'` |
167
+ | `darkMode` | `'class'` follows the reader's system; `'dark'` or `'light'` keeps one scheme |
168
+ | `tokens` | Redefined `--dp-*` tokens |
169
+ | `css` | CSS appended to the produced stylesheet |
170
+ | `source` | Stylesheet handed to the utility compiler |
127
171
 
128
172
  The available tokens are listed in [Themes](../guide/themes/).
129
173
 
@@ -132,6 +176,42 @@ Longer rules go in the `theme/` folder, at the root of the project: every
132
176
  `docpensieve dev` picks up every change. Under the `custom` theme, `init`
133
177
  starts it with `theme/custom.css`.
134
178
 
179
+ ## `sidebar`
180
+
181
+ `'auto'` builds the menu from the file tree: folders become categories, and the
182
+ `01-`, `02-` prefixes set the order. To write it by hand, name a JSON file:
183
+
184
+ ```js
185
+ sidebar: 'sidebar.json',
186
+ ```
187
+
188
+ It is read from **each version's folder** — `docs/v1.0/sidebar.json` — since
189
+ each version has its own pages. It holds an array of entries, kept in the order
190
+ written:
191
+
192
+ ```json
193
+ [
194
+ "/",
195
+ { "label": "Guide", "page": "guide", "items": ["guide/installation", "guide/first-site"] },
196
+ { "page": "reference/cli", "label": "Commands" },
197
+ { "auto": "docpensieve" },
198
+ { "label": "Repository", "href": "https://github.com/me/my-project" }
199
+ ]
200
+ ```
201
+
202
+ | Entry | What it gives |
203
+ | ------------------------------- | ------------------------------------------------------------------------------- |
204
+ | `"guide/installation"` | A page, by its path within the version, as in its URL — `"/"` for the home page |
205
+ | `{ "page", "label" }` | The same page, with a label of its own |
206
+ | `{ "label", "items", "page"? }` | A category, clickable when it names a page |
207
+ | `{ "label", "href" }` | A link outside the site |
208
+ | `{ "auto": "folder" }` | The automatic menu of a folder: the DocPensieve section keeps its own this way |
209
+
210
+ A page left out stays published: it is only absent from the menu. A path that
211
+ names no page, a page listed twice, or an entry of no known kind stops the
212
+ build, naming the file and the paths close to the one written. The file itself
213
+ is not published.
214
+
135
215
  ## `baseUrl`, and why you rarely write it
136
216
 
137
217
  A `siteUrl` with a sub-path already gives it: `https://example.com/my-project`
@@ -25,13 +25,13 @@ theme: {
25
25
  },
26
26
  ```
27
27
 
28
- | Field | Default | Effect |
29
- | ----------- | ------------------------ | ----------------------------------------------------- |
30
- | `framework` | `'tailwind'` | `'tailwind'` or `'custom'` |
31
- | `darkMode` | `'class'` | Dark theme strategy |
32
- | `tokens` | — | Redefined `--dp-*` tokens, merged with the provider's |
33
- | `css` | `''` | CSS appended to the produced stylesheet |
34
- | `source` | `@import "tailwindcss";` | Stylesheet handed to the utility compiler |
28
+ | Field | Default | Effect |
29
+ | ----------- | ------------------------ | --------------------------------------------------------------------------------------------------------- |
30
+ | `framework` | `'tailwind'` | `'tailwind'` or `'custom'` |
31
+ | `darkMode` | `'class'` | `'class'`: the reader's system, unless a class on `<html>` decides. `'dark'` or `'light'` sets that class |
32
+ | `tokens` | — | Redefined `--dp-*` tokens, merged with the provider's |
33
+ | `css` | `''` | CSS appended to the produced stylesheet |
34
+ | `source` | `@import "tailwindcss";` | Stylesheet handed to the utility compiler |
35
35
 
36
36
  `source` only concerns the `tailwind` provider: it is the entry stylesheet it
37
37
  compiles. Replacing it lets you add directives — a `@theme` block, for
@@ -98,6 +98,7 @@ the `dp-*` class below.
98
98
  | `footer` | `dp-footer` | Page footer |
99
99
  | `scrollTop` | `dp-scroll-top` | Back-to-top button |
100
100
  | `scrollTopIcon` | `dp-scroll-top-icon` | Arrow of that button |
101
+ | `search` | `dp-search` | Search field of the header |
101
102
 
102
103
  A slot can carry **variants**, suffixed `--variant`: `column` gives
103
104
  `dp-column--span-8`, `skill` gives `dp-skill--circle`.