@waveso/docs 0.5.0 → 0.7.0
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/CHANGELOG.md +252 -1
- package/README.md +188 -90
- package/dist/anchors.d.ts +44 -0
- package/dist/anchors.js +76 -0
- package/dist/errors.d.ts +2 -0
- package/dist/frontmatter.d.ts +8 -0
- package/dist/frontmatter.js +7 -1
- package/dist/link-suggestion.d.ts +31 -0
- package/dist/link-suggestion.js +94 -0
- package/dist/next.d.ts +34 -27
- package/dist/next.js +40 -13
- package/dist/plugins/rehype-fallback-heading-ids.js +1 -1
- package/dist/plugins/remark-doc-links.d.ts +33 -1
- package/dist/plugins/remark-doc-links.js +24 -8
- package/dist/react/hero.d.ts +19 -0
- package/dist/react/hero.js +44 -0
- package/dist/react/layout.d.ts +1 -3
- package/dist/react/layout.js +17 -54
- package/dist/react/link-adapter.d.ts +34 -0
- package/dist/react/link-adapter.js +30 -0
- package/dist/react/nav.d.ts +11 -11
- package/dist/react/nav.js +106 -58
- package/dist/react/next-link.d.ts +6 -28
- package/dist/react/next-link.js +45 -24
- package/dist/react/next-nav.d.ts +5 -1
- package/dist/react/next-nav.js +5 -3
- package/dist/react/next-search.js +1 -1
- package/dist/react/shell-labels.d.ts +8 -2
- package/dist/react/toc.d.ts +13 -3
- package/dist/react/toc.js +17 -10
- package/dist/render.d.ts +1 -1
- package/dist/render.js +71 -11
- package/dist/source.js +7 -3
- package/dist/styles.css +1079 -237
- package/dist/types.d.ts +102 -6
- package/package.json +10 -3
package/dist/types.d.ts
CHANGED
|
@@ -15,6 +15,21 @@ import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
|
15
15
|
* `Property 'audience' does not exist on type 'DocFrontmatter'` at every read
|
|
16
16
|
* site, because the inference then collapses to this default.
|
|
17
17
|
*/
|
|
18
|
+
/**
|
|
19
|
+
* One call to action in a page's hero.
|
|
20
|
+
*
|
|
21
|
+
* `variant` is optional because the shape every landing page has is
|
|
22
|
+
* primary-then-secondary: the first action is the primary unless it says
|
|
23
|
+
* otherwise.
|
|
24
|
+
*/
|
|
25
|
+
interface DocAction {
|
|
26
|
+
/** Visible text. */
|
|
27
|
+
label: string;
|
|
28
|
+
/** Where it goes. Internal hrefs route; external ones open in a new tab. */
|
|
29
|
+
href: string;
|
|
30
|
+
/** Overrides the position-derived default. */
|
|
31
|
+
variant?: 'primary' | 'secondary' | undefined;
|
|
32
|
+
}
|
|
18
33
|
interface DocFrontmatter {
|
|
19
34
|
/** Page title. Used for `<h1>` fallbacks, `<title>`, and search. */
|
|
20
35
|
title: string;
|
|
@@ -44,6 +59,21 @@ interface DocFrontmatter {
|
|
|
44
59
|
* Lower sorts first; pages without an order sort last, alphabetically.
|
|
45
60
|
*/
|
|
46
61
|
order?: number | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Calls to action, and the opt-in for the page's hero.
|
|
64
|
+
*
|
|
65
|
+
* Declaring them turns {@link DocFrontmatter.title} and
|
|
66
|
+
* {@link DocFrontmatter.description} into a page header with these links
|
|
67
|
+
* under it, and stops `render` prepending its own `<h1>` — the hero renders
|
|
68
|
+
* the heading, because the tagline and the actions have to sit beneath it.
|
|
69
|
+
*
|
|
70
|
+
* Leave it off and the page is exactly what it was: the description stays a
|
|
71
|
+
* `<meta>` tag and the title is the first thing in the prose. That is the
|
|
72
|
+
* whole difference between documentation that is the entire site and
|
|
73
|
+
* documentation mounted inside an application that already has a landing
|
|
74
|
+
* page — one field, in the file that wants it.
|
|
75
|
+
*/
|
|
76
|
+
actions?: DocAction[] | undefined;
|
|
47
77
|
}
|
|
48
78
|
/**
|
|
49
79
|
* A single documentation page discovered on disk.
|
|
@@ -244,11 +274,24 @@ interface DocLinkContext {
|
|
|
244
274
|
/** The source path, e.g. `'api/auth.md'`. For error messages. */
|
|
245
275
|
relativePath: string;
|
|
246
276
|
}
|
|
277
|
+
/**
|
|
278
|
+
* What a link problem should do to a build.
|
|
279
|
+
*
|
|
280
|
+
* The three Docusaurus settled on, and for the same reason: the tool cannot
|
|
281
|
+
* know how much a given site cares, and guessing produces either a build that
|
|
282
|
+
* fails on someone's legitimate URL or one that ships a dead link quietly.
|
|
283
|
+
*
|
|
284
|
+
* `'warn'` writes to `console.warn` and continues, which on a docs site is a
|
|
285
|
+
* line in a build log — useful during a migration, not a substitute for
|
|
286
|
+
* `'throw'`.
|
|
287
|
+
*/
|
|
288
|
+
type DocsLinkSeverity = 'throw' | 'warn' | 'ignore';
|
|
247
289
|
/**
|
|
248
290
|
* Resolve an internal markdown link target to a route.
|
|
249
291
|
*
|
|
250
292
|
* Called for every relative link found in the source. Returning `undefined`
|
|
251
|
-
* signals "not a documentation page", which —
|
|
293
|
+
* signals "not a documentation page", which — under the default
|
|
294
|
+
* `onBrokenLinks: 'throw'` — fails
|
|
252
295
|
* the build rather than shipping a 404 that was valid on GitHub.
|
|
253
296
|
*/
|
|
254
297
|
type LinkResolver = (
|
|
@@ -321,10 +364,61 @@ interface DocsConfig<TFrontmatter extends DocFrontmatter = DocFrontmatter> {
|
|
|
321
364
|
*/
|
|
322
365
|
includeDrafts?: boolean | undefined;
|
|
323
366
|
/**
|
|
324
|
-
*
|
|
325
|
-
*
|
|
367
|
+
* What to do about an internal link that resolves to no published page.
|
|
368
|
+
* Defaults to `'throw'`.
|
|
369
|
+
*
|
|
370
|
+
* A link that 404s was valid in the editor and on GitHub, so it is the kind
|
|
371
|
+
* of mistake nobody finds by reading. Throwing is the default for that
|
|
372
|
+
* reason, and there is rarely a good reason to lower it — `'warn'` exists
|
|
373
|
+
* for a migration where the corpus is knowingly incomplete for a while.
|
|
374
|
+
*
|
|
375
|
+
* The error names the file and the line, and offers the closest published
|
|
376
|
+
* route when the link looks like a typo of one.
|
|
377
|
+
*/
|
|
378
|
+
onBrokenLinks?: DocsLinkSeverity | undefined;
|
|
379
|
+
/**
|
|
380
|
+
* What to do about a `#fragment` that no heading on the target page owns.
|
|
381
|
+
* Defaults to `'throw'`.
|
|
382
|
+
*
|
|
383
|
+
* ⚠️ THE MORE COMMON OF THE TWO LINK FAILURES, AND IT WENT UNCHECKED. A route
|
|
384
|
+
* was verified and its fragment discarded, so `[setup](./install.md#setup)`
|
|
385
|
+
* built green with no `#setup` anywhere on the page. Headings get renamed
|
|
386
|
+
* constantly and nothing renames the links into them, which is exactly why it
|
|
387
|
+
* is worth checking and exactly why it breaks.
|
|
388
|
+
*
|
|
389
|
+
* Checked against every `id` in the rendered page rather than against the
|
|
390
|
+
* table of contents, which captures `h2`–`h3` only — so a link to an `h4` is
|
|
391
|
+
* fine, and so is one to an id a `rehypePlugins` entry put on something that
|
|
392
|
+
* is not a heading.
|
|
393
|
+
*
|
|
394
|
+
* Lower it to `'warn'` if a plugin of yours adds ids this package cannot see
|
|
395
|
+
* at render time.
|
|
396
|
+
*/
|
|
397
|
+
onBrokenAnchors?: DocsLinkSeverity | undefined;
|
|
398
|
+
/**
|
|
399
|
+
* Route prefixes that belong to your application, not to the documentation.
|
|
400
|
+
*
|
|
401
|
+
* ⚠️ ONLY MEANINGFUL AT A ROOT MOUNT, WHICH IS ALSO THE ONLY PLACE IT IS
|
|
402
|
+
* NEEDED. Under `basePath: '/docs'` an absolute link either carries the
|
|
403
|
+
* prefix — so it is documentation and is checked — or it does not, and this
|
|
404
|
+
* package leaves it alone. Under `basePath: '/'` there is no prefix to test
|
|
405
|
+
* against: `/setup` and `/login` look identical, and both are checked against
|
|
406
|
+
* the published pages.
|
|
407
|
+
*
|
|
408
|
+
* That is the right default, because a root mount is what you choose when the
|
|
409
|
+
* origin serves documentation and nothing else — `docs.example.com` — and
|
|
410
|
+
* there an unknown absolute link is always a typo. If the origin *does* serve
|
|
411
|
+
* something else, name what is yours:
|
|
412
|
+
*
|
|
413
|
+
* ```ts
|
|
414
|
+
* externalRoutes: ['/login', '/dashboard', '/api/']
|
|
415
|
+
* ```
|
|
416
|
+
*
|
|
417
|
+
* A link is skipped when it equals one of these or begins with one followed
|
|
418
|
+
* by `/`. It is a statement about your application, so nothing here can infer
|
|
419
|
+
* it and nothing tries.
|
|
326
420
|
*/
|
|
327
|
-
|
|
421
|
+
externalRoutes?: readonly string[] | undefined;
|
|
328
422
|
/**
|
|
329
423
|
* Validates every page's frontmatter. Defaults to `docFrontmatterSchema`
|
|
330
424
|
* from `@waveso/docs/frontmatter`.
|
|
@@ -375,7 +469,9 @@ interface ResolvedDocsConfig<TFrontmatter extends DocFrontmatter = DocFrontmatte
|
|
|
375
469
|
contentDir: string;
|
|
376
470
|
basePath: string;
|
|
377
471
|
includeDrafts: boolean;
|
|
378
|
-
|
|
472
|
+
onBrokenLinks: DocsLinkSeverity;
|
|
473
|
+
onBrokenAnchors: DocsLinkSeverity;
|
|
474
|
+
externalRoutes: readonly string[];
|
|
379
475
|
/**
|
|
380
476
|
* As supplied. `resolveDocsConfig` omits the key rather than setting it to
|
|
381
477
|
* `undefined` when the built-in `docFrontmatterSchema` applies, so the
|
|
@@ -384,4 +480,4 @@ interface ResolvedDocsConfig<TFrontmatter extends DocFrontmatter = DocFrontmatte
|
|
|
384
480
|
frontmatterSchema?: StandardSchemaV1<unknown, TFrontmatter> | undefined;
|
|
385
481
|
}
|
|
386
482
|
//#endregion
|
|
387
|
-
export { DocFile, DocFrontmatter, DocLinkContext, DocNavGroup, DocNavLink, DocNavNode, DocNavPage, DocNavSeparator, DocsConfig, DocsMeta, ImageResolver, LinkResolver, RenderedDoc, ResolvedDocsConfig, SearchRecord, TocEntry };
|
|
483
|
+
export { DocAction, DocFile, DocFrontmatter, DocLinkContext, DocNavGroup, DocNavLink, DocNavNode, DocNavPage, DocNavSeparator, DocsConfig, DocsLinkSeverity, DocsMeta, ImageResolver, LinkResolver, RenderedDoc, ResolvedDocsConfig, SearchRecord, TocEntry };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@waveso/docs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Zero parser bytes in the browser: markdown docs for Next.js, built to hast in Node and rendered as your components",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -68,6 +68,10 @@
|
|
|
68
68
|
"types": "./dist/react/callout.d.ts",
|
|
69
69
|
"default": "./dist/react/callout.js"
|
|
70
70
|
},
|
|
71
|
+
"./react/hero": {
|
|
72
|
+
"types": "./dist/react/hero.d.ts",
|
|
73
|
+
"default": "./dist/react/hero.js"
|
|
74
|
+
},
|
|
71
75
|
"./react/doc-content": {
|
|
72
76
|
"types": "./dist/react/doc-content.d.ts",
|
|
73
77
|
"default": "./dist/react/doc-content.js"
|
|
@@ -76,6 +80,10 @@
|
|
|
76
80
|
"types": "./dist/react/markdown-components.d.ts",
|
|
77
81
|
"default": "./dist/react/markdown-components.js"
|
|
78
82
|
},
|
|
83
|
+
"./react/next-link": {
|
|
84
|
+
"types": "./dist/react/next-link.d.ts",
|
|
85
|
+
"default": "./dist/react/next-link.js"
|
|
86
|
+
},
|
|
79
87
|
"./react/next-search": {
|
|
80
88
|
"types": "./dist/react/next-search.d.ts",
|
|
81
89
|
"default": "./dist/react/next-search.js"
|
|
@@ -196,7 +204,6 @@
|
|
|
196
204
|
"test:smoke": "node smoke/check.ts",
|
|
197
205
|
"size": "node scripts/size.ts",
|
|
198
206
|
"build:site": "next build site",
|
|
199
|
-
"dev:site": "next dev site"
|
|
200
|
-
"shoot": "node scripts/shoot.ts"
|
|
207
|
+
"dev:site": "next dev site"
|
|
201
208
|
}
|
|
202
209
|
}
|