@writedocs/generator 0.14.0 → 0.15.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/astro.config.mjs +31 -69
- package/package.json +4 -2
- package/packages/components/package.json +53 -0
- package/{src → packages/components/src}/components/Accordion.astro +2 -2
- package/{src → packages/components/src}/components/AppIcon.astro +3 -3
- package/{src → packages/components/src}/components/Callout.astro +3 -3
- package/{src → packages/components/src}/components/CodeBlock.astro +8 -27
- package/{src → packages/components/src}/components/CodeGroup.astro +3 -3
- package/{src → packages/components/src}/components/Image.astro +7 -9
- package/{src → packages/components/src}/components/compound.ts +1 -1
- package/packages/components/src/host.js +24 -0
- package/packages/components/src/index.ts +59 -0
- package/packages/components/src/integration.js +151 -0
- package/packages/components/src/lib/base-path.js +39 -0
- package/{src → packages/components/src}/lib/code-line-numbers.js +1 -1
- package/packages/components/src/lib/code-transformers.js +45 -0
- package/{src → packages/components/src}/lib/icons.js +13 -7
- package/{src → packages/components/src}/lib/shiki-code-block.js +9 -9
- package/{src → packages/components/src}/lib/site-base.ts +9 -6
- package/packages/components/src/scripts/code-block.ts +62 -0
- package/packages/components/src/styles/components.css +373 -0
- package/packages/components/src/styles/theme.css +63 -0
- package/src/cli/run-astro.js +1 -1
- package/src/components/ApiPlayground.astro +2 -2
- package/src/components/ApiSchemaField.astro +1 -1
- package/src/components/CopyPageMenu.astro +2 -2
- package/src/icons/README.md +1 -1
- package/src/layout/BaseLayout.astro +7 -2
- package/src/layout/components/AnalyticsScripts.astro +2 -2
- package/src/layout/components/Breadcrumbs.astro +1 -1
- package/src/layout/components/ConsentBanner.astro +1 -1
- package/src/layout/components/MobileMenu.astro +2 -2
- package/src/layout/components/NavTree.astro +2 -2
- package/src/layout/components/Sidebar.astro +2 -2
- package/src/layout/components/SiteFooter.astro +2 -2
- package/src/layout/components/TopBar.astro +2 -2
- package/src/layout/styles/base.css +4 -37
- package/src/lib/a11y-check.js +1 -1
- package/src/lib/base-path.js +4 -25
- package/src/lib/color.js +1 -1
- package/src/lib/components-host.ts +21 -0
- package/src/lib/config-file.js +1 -1
- package/src/lib/config.ts +4 -3
- package/src/lib/content-check.js +2 -2
- package/src/lib/link-check.js +2 -2
- package/src/lib/mdx-inject-builtins.js +2 -2
- package/src/lib/mdx-inline-react.js +1 -1
- package/src/lib/mdx-title-anchor-ids.js +2 -2
- package/src/lib/mdx-unknown-components.js +1 -1
- package/src/lib/mintlify-convert.js +2 -2
- package/src/lib/openapi-reload-integration.js +1 -1
- package/src/lib/pages.js +1 -1
- package/src/lib/project-files-integration.js +1 -1
- package/src/lib/rehype-base-path.js +1 -1
- package/src/lib/writedocs-legacy-convert.js +1 -1
- package/src/pages/404.astro +1 -1
- package/src/pages/[...slug].astro +53 -416
- package/src/components/index.ts +0 -62
- /package/{src → packages/components/src}/components/AccordionGroup.astro +0 -0
- /package/{src → packages/components/src}/components/Badge.astro +0 -0
- /package/{src → packages/components/src}/components/Card.astro +0 -0
- /package/{src → packages/components/src}/components/CardGroup.astro +0 -0
- /package/{src → packages/components/src}/components/Check.astro +0 -0
- /package/{src → packages/components/src}/components/Color.astro +0 -0
- /package/{src → packages/components/src}/components/ColorItem.astro +0 -0
- /package/{src → packages/components/src}/components/ColorRow.astro +0 -0
- /package/{src → packages/components/src}/components/Column.astro +0 -0
- /package/{src → packages/components/src}/components/Columns.astro +0 -0
- /package/{src → packages/components/src}/components/Danger.astro +0 -0
- /package/{src → packages/components/src}/components/Expandable.astro +0 -0
- /package/{src → packages/components/src}/components/Frame.astro +0 -0
- /package/{src → packages/components/src}/components/GitHubRepo.astro +0 -0
- /package/{src → packages/components/src}/components/Hint.astro +0 -0
- /package/{src → packages/components/src}/components/Icon.astro +0 -0
- /package/{src → packages/components/src}/components/Info.astro +0 -0
- /package/{src → packages/components/src}/components/Note.astro +0 -0
- /package/{src → packages/components/src}/components/Panel.astro +0 -0
- /package/{src → packages/components/src}/components/ParamField.astro +0 -0
- /package/{src → packages/components/src}/components/Parameter.astro +0 -0
- /package/{src → packages/components/src}/components/Prompt.astro +0 -0
- /package/{src → packages/components/src}/components/RequestExample.astro +0 -0
- /package/{src → packages/components/src}/components/ResponseExample.astro +0 -0
- /package/{src → packages/components/src}/components/ResponseField.astro +0 -0
- /package/{src → packages/components/src}/components/Searchbar.astro +0 -0
- /package/{src → packages/components/src}/components/Step.astro +0 -0
- /package/{src → packages/components/src}/components/Steps.astro +0 -0
- /package/{src → packages/components/src}/components/Tab.astro +0 -0
- /package/{src → packages/components/src}/components/Tabs.astro +0 -0
- /package/{src → packages/components/src}/components/Tile.astro +0 -0
- /package/{src → packages/components/src}/components/Tip.astro +0 -0
- /package/{src → packages/components/src}/components/Tooltip.astro +0 -0
- /package/{src → packages/components/src}/components/Tree.astro +0 -0
- /package/{src → packages/components/src}/components/TreeFile.astro +0 -0
- /package/{src → packages/components/src}/components/TreeFolder.astro +0 -0
- /package/{src → packages/components/src}/components/Update.astro +0 -0
- /package/{src → packages/components/src}/components/Video.astro +0 -0
- /package/{src → packages/components/src}/components/View.astro +0 -0
- /package/{src → packages/components/src}/components/Visibility.astro +0 -0
- /package/{src → packages/components/src}/components/Warning.astro +0 -0
- /package/{src → packages/components/src}/components/class-names.ts +0 -0
- /package/{src → packages/components/src}/lib/cli-report.js +0 -0
- /package/{src → packages/components/src}/lib/inline-markdown.js +0 -0
- /package/{src → packages/components/src}/lib/plain-text.js +0 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* The theme the components read, for a project that isn't a writedocs site:
|
|
2
|
+
the --wd-* variables, light and dark, with the values a writedocs site
|
|
3
|
+
gets when its writedocs.json sets no colors (BaseLayout.astro's define:vars
|
|
4
|
+
<style> - the generator sets them itself and doesn't load this file). The
|
|
5
|
+
integration adds it to every page; to use other colors, set the variables
|
|
6
|
+
again in the project's own CSS, on :root or on any element around the
|
|
7
|
+
components. Dark mode follows data-theme="dark" on <html>, like a
|
|
8
|
+
writedocs site. */
|
|
9
|
+
:root {
|
|
10
|
+
--wd-primary: #6366f1;
|
|
11
|
+
/* The text color on a --wd-primary background - readableTextOn() in the
|
|
12
|
+
generator's src/lib/color.js picks it from the primary color. */
|
|
13
|
+
--wd-on-primary: #ffffff;
|
|
14
|
+
--wd-background: #ffffff;
|
|
15
|
+
--wd-text: #404045;
|
|
16
|
+
--wd-text-muted: #64748b;
|
|
17
|
+
--wd-heading: #18191d;
|
|
18
|
+
--wd-border: #e2e8f0;
|
|
19
|
+
--wd-surface: #f8fafc;
|
|
20
|
+
}
|
|
21
|
+
:root[data-theme="dark"] {
|
|
22
|
+
--wd-background: #0b1120;
|
|
23
|
+
--wd-text: #a0a0a5;
|
|
24
|
+
--wd-text-muted: #94a3b8;
|
|
25
|
+
--wd-heading: #e0e0e5;
|
|
26
|
+
--wd-border: #1e293b;
|
|
27
|
+
--wd-surface: #131a2b;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/* What a writedocs site's own stylesheet (the generator's
|
|
31
|
+
src/layout/styles/base.css and [...slug].astro) gives the code inside the
|
|
32
|
+
components. :where() adds no specificity, so the project's own rules for
|
|
33
|
+
these elements win. */
|
|
34
|
+
:where(code) {
|
|
35
|
+
background: var(--wd-surface);
|
|
36
|
+
border: 1px solid var(--wd-border);
|
|
37
|
+
padding: 0.15em 0.45em;
|
|
38
|
+
border-radius: 0.35em;
|
|
39
|
+
font-size: 1em;
|
|
40
|
+
font-weight: 500;
|
|
41
|
+
}
|
|
42
|
+
:where(pre code) {
|
|
43
|
+
background: none;
|
|
44
|
+
border: none;
|
|
45
|
+
padding: 0;
|
|
46
|
+
font-weight: normal;
|
|
47
|
+
}
|
|
48
|
+
:where(pre) {
|
|
49
|
+
padding: 1rem;
|
|
50
|
+
border-radius: 0.5rem;
|
|
51
|
+
overflow-x: auto;
|
|
52
|
+
}
|
|
53
|
+
/* A code block's panel. The generator scopes this rule to its article
|
|
54
|
+
(.wd-article pre.astro-code in components.css); here every code block
|
|
55
|
+
gets it. */
|
|
56
|
+
.wd-code-block pre.astro-code {
|
|
57
|
+
margin: 0;
|
|
58
|
+
padding: 0.75rem var(--wd-code-pad-x);
|
|
59
|
+
border: none;
|
|
60
|
+
border-radius: 0.875rem;
|
|
61
|
+
font-size: 0.875rem;
|
|
62
|
+
line-height: 1.5rem;
|
|
63
|
+
}
|
package/src/cli/run-astro.js
CHANGED
|
@@ -12,7 +12,7 @@ const workerPath = path.join(path.dirname(fileURLToPath(import.meta.url)), 'astr
|
|
|
12
12
|
*
|
|
13
13
|
* { type: 'astro-log', level, label, message } - an Astro/Vite log line
|
|
14
14
|
* { type: 'report', level, message, where } - writedocs' own code
|
|
15
|
-
* (lib/cli-report.js)
|
|
15
|
+
* (packages/components/src/lib/cli-report.js)
|
|
16
16
|
* { type: 'raw', stream, line } - anything printed directly
|
|
17
17
|
* { type: 'ready', urls } / { type: 'done' } / { type: 'fatal', error }
|
|
18
18
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import ApiSchemaField from './ApiSchemaField.astro';
|
|
4
|
-
import Tabs from '
|
|
5
|
-
import Tab from '
|
|
4
|
+
import Tabs from '../../packages/components/src/components/Tabs.astro';
|
|
5
|
+
import Tab from '../../packages/components/src/components/Tab.astro';
|
|
6
6
|
import {
|
|
7
7
|
schemaRows,
|
|
8
8
|
exampleFromSchema,
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
// the same way NavTree.astro's own nested sidebar groups do - same
|
|
19
19
|
// established pattern in this codebase for "a tree of unknown depth, one
|
|
20
20
|
// component handles every level."
|
|
21
|
-
import Expandable from '
|
|
21
|
+
import Expandable from '../../packages/components/src/components/Expandable.astro';
|
|
22
22
|
import type { SchemaRow } from '../lib/openapi-render';
|
|
23
23
|
import { descriptionHtml } from '../lib/openapi-markdown';
|
|
24
24
|
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
import { Icon } from 'astro-icon/components';
|
|
35
35
|
import type { ContextMenuOption } from '../lib/config';
|
|
36
36
|
import { mcpServerUrl, cursorInstallLink, vscodeInstallLink } from '../lib/mcp-links.js';
|
|
37
|
-
import { siteHref } from '
|
|
37
|
+
import { siteHref } from '../../packages/components/src/lib/site-base';
|
|
38
38
|
|
|
39
39
|
interface Props {
|
|
40
40
|
currentPath: string; // e.g. "/" or "/guides/foo/" - see hrefForSlug() in [...slug].astro
|
|
@@ -52,7 +52,7 @@ const { currentPath, siteUrl, siteName, options } = Astro.props as Props;
|
|
|
52
52
|
// slug with a literal ".md" appended instead of the trailing slash).
|
|
53
53
|
const mdPath = currentPath === '/' ? '/index.md' : `${currentPath.replace(/\/$/, '')}.md`;
|
|
54
54
|
const mdAbsoluteUrl = siteUrl ? `${siteUrl}${mdPath}` : null;
|
|
55
|
-
// The .md's address as the page links it - with the basePath (lib/site-base.ts).
|
|
55
|
+
// The .md's address as the page links it - with the basePath (the components package's lib/site-base.ts).
|
|
56
56
|
const mdHref = siteHref(mdPath);
|
|
57
57
|
const mcpUrl = siteUrl ? mcpServerUrl(siteUrl) : null;
|
|
58
58
|
|
package/src/icons/README.md
CHANGED
|
@@ -8,5 +8,5 @@ and `writedocs build`:
|
|
|
8
8
|
Failed to load icons from "src/icons": ENOENT: no such file or directory
|
|
9
9
|
|
|
10
10
|
writedocs has no local icons: every icon comes from the installed icon sets
|
|
11
|
-
(see src/lib/icons.js). Don't delete the folder; `scripts/package-files.test.js`
|
|
11
|
+
(see packages/components/src/lib/icons.js). Don't delete the folder; `scripts/package-files.test.js`
|
|
12
12
|
checks it ships in the npm package.
|
|
@@ -55,6 +55,11 @@ import "../styles/global.css";
|
|
|
55
55
|
// theme with no extra CSS needed here.
|
|
56
56
|
import "katex/dist/katex.min.css";
|
|
57
57
|
import "./styles/base.css";
|
|
58
|
+
// What the components package's components share: code blocks (every ```
|
|
59
|
+
// fence goes through the package's transformers - astro.config.mjs), Shiki's
|
|
60
|
+
// dark theme, icons given as an image. The --wd-* variables it uses are this
|
|
61
|
+
// layout's own (the define:vars <style> below).
|
|
62
|
+
import "../../packages/components/src/styles/components.css";
|
|
58
63
|
import "./styles/banner.css";
|
|
59
64
|
// Astro's client-side router - swaps <body> content between same-origin
|
|
60
65
|
// navigations via the native View Transition API instead of a hard
|
|
@@ -85,8 +90,8 @@ import { jsonLd, serializeJsonLd } from "../lib/json-ld.js";
|
|
|
85
90
|
import { consentOptions } from "../lib/consent.js";
|
|
86
91
|
import { oncePerBuild } from "../lib/build-memo.js";
|
|
87
92
|
// writedocs.json's `basePath`: every site address written below goes
|
|
88
|
-
// through siteHref() - see lib/site-base.ts.
|
|
89
|
-
import { BASE, siteHref } from "
|
|
93
|
+
// through siteHref() - see the components package's lib/site-base.ts.
|
|
94
|
+
import { BASE, siteHref } from "../../packages/components/src/lib/site-base";
|
|
90
95
|
|
|
91
96
|
interface Props {
|
|
92
97
|
config: DocsConfig;
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
// it doesn't wait for consent.
|
|
23
23
|
import type { DocsConfig } from '../../lib/config';
|
|
24
24
|
import { analyticsTags, scriptTags, consentLoaderScript } from '../../lib/consent.js';
|
|
25
|
-
import { siteHref } from '
|
|
25
|
+
import { siteHref } from '../../../packages/components/src/lib/site-base';
|
|
26
26
|
|
|
27
27
|
interface Props {
|
|
28
28
|
config: DocsConfig;
|
|
@@ -35,7 +35,7 @@ interface Props {
|
|
|
35
35
|
const { config, consent = null, gatedScripts = [] } = Astro.props as Props;
|
|
36
36
|
|
|
37
37
|
// A script's `src` can be a file in the site ("/js/stats.js"): it gets the
|
|
38
|
-
// basePath (lib/site-base.ts).
|
|
38
|
+
// basePath (the components package's lib/site-base.ts).
|
|
39
39
|
const withSrcBase = <T extends { src?: string }>(tag: T): T => (tag.src ? { ...tag, src: siteHref(tag.src) } : tag);
|
|
40
40
|
const tags = analyticsTags(config.integrations).map(withSrcBase);
|
|
41
41
|
const loader = consent ? consentLoaderScript([...tags, ...scriptTags(gatedScripts).map(withSrcBase)]) : null;
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// Iconify id for the exact same Font Awesome 6 glyph as react-icons'
|
|
21
21
|
// `FaHouse`, without pulling React into an otherwise-static nav element.
|
|
22
22
|
import { Icon } from 'astro-icon/components';
|
|
23
|
-
import { siteHref } from '
|
|
23
|
+
import { siteHref } from '../../../packages/components/src/lib/site-base';
|
|
24
24
|
|
|
25
25
|
export interface BreadcrumbItem {
|
|
26
26
|
label: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
import { siteHref } from '
|
|
2
|
+
import { siteHref } from '../../../packages/components/src/lib/site-base';
|
|
3
3
|
// writedocs.json's `integrations.consent` - the banner that asks before the
|
|
4
4
|
// analytics integrations load. It's in the page hidden; src/scripts/
|
|
5
5
|
// consent.ts shows it when the reader hasn't answered yet (window.wdConsent,
|
|
@@ -29,13 +29,13 @@
|
|
|
29
29
|
// several unrelated concerns in one file - see that component's own
|
|
30
30
|
// comment for the fuller rationale.
|
|
31
31
|
import { isExternalHref, type DocsConfig, type Selector, type GlobalDropdownView } from '../../lib/config';
|
|
32
|
-
import AppIcon from '
|
|
32
|
+
import AppIcon from '../../../packages/components/src/components/AppIcon.astro';
|
|
33
33
|
import { logoWidth } from '../../lib/image-size.js';
|
|
34
34
|
import { hasMobileMenu, currentOption } from '../../lib/selector-placement.js';
|
|
35
35
|
import '../styles/dropdown.css';
|
|
36
36
|
import '../styles/topbar.css';
|
|
37
37
|
import '../styles/mobile-menu.css';
|
|
38
|
-
import { siteHref } from '
|
|
38
|
+
import { siteHref } from '../../../packages/components/src/lib/site-base';
|
|
39
39
|
|
|
40
40
|
interface Props {
|
|
41
41
|
config: DocsConfig;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { navTreeContainsSlug, isExternalHref, type NavTreeNode } from "../../lib/config";
|
|
3
|
-
import AppIcon from "
|
|
3
|
+
import AppIcon from "../../../packages/components/src/components/AppIcon.astro";
|
|
4
4
|
import { methodClass } from "../../lib/openapi-render";
|
|
5
|
-
import { siteHref } from '
|
|
5
|
+
import { siteHref } from '../../../packages/components/src/lib/site-base';
|
|
6
6
|
|
|
7
7
|
interface Props {
|
|
8
8
|
nodes: NavTreeNode[];
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { isExternalHref, type NavTreeNode, type Selector } from "../../lib/config";
|
|
3
3
|
import NavTree from "./NavTree.astro";
|
|
4
4
|
import { currentOption } from "../../lib/selector-placement.js";
|
|
5
|
-
import AppIcon from "
|
|
5
|
+
import AppIcon from "../../../packages/components/src/components/AppIcon.astro";
|
|
6
6
|
// Two colorways of the same "Powered by writedocs" mark, not a
|
|
7
7
|
// theme-matched pair in the wd-logo-light/wd-logo-dark sense (that
|
|
8
8
|
// convention names each file by which theme it's *shown in*) - these
|
|
@@ -17,7 +17,7 @@ import AppIcon from "../../components/AppIcon.astro";
|
|
|
17
17
|
// src="/..."> here would 404 on every real site build.
|
|
18
18
|
import watermarkForLightTheme from "../../assets/wd_watermark_dark.png";
|
|
19
19
|
import watermarkForDarkTheme from "../../assets/wd_watermark.png";
|
|
20
|
-
import { siteHref } from '
|
|
20
|
+
import { siteHref } from '../../../packages/components/src/lib/site-base';
|
|
21
21
|
|
|
22
22
|
// Deploy-time-only opt-out, not a writedocs.json field: a site's own writedocs.json
|
|
23
23
|
// is part of its checked-in content (something the author controls), while
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
// several unrelated concerns in one file - see that component's own
|
|
11
11
|
// comment for the fuller rationale.
|
|
12
12
|
import { isExternalHref, type DocsConfig } from '../../lib/config';
|
|
13
|
-
import AppIcon from '
|
|
13
|
+
import AppIcon from '../../../packages/components/src/components/AppIcon.astro';
|
|
14
14
|
import { logoWidth } from '../../lib/image-size.js';
|
|
15
15
|
import '../styles/footer.css';
|
|
16
|
-
import { siteHref } from '
|
|
16
|
+
import { siteHref } from '../../../packages/components/src/lib/site-base';
|
|
17
17
|
|
|
18
18
|
interface Props {
|
|
19
19
|
config: DocsConfig;
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
// several unrelated concerns in one file - see that component's own
|
|
13
13
|
// comment for the fuller rationale.
|
|
14
14
|
import { isExternalHref, type DocsConfig, type Selector, type GlobalDropdownView } from '../../lib/config';
|
|
15
|
-
import AppIcon from '
|
|
15
|
+
import AppIcon from '../../../packages/components/src/components/AppIcon.astro';
|
|
16
16
|
import { logoWidth } from '../../lib/image-size.js';
|
|
17
17
|
import { selectorPlacements, hasMobileMenu, currentOption } from '../../lib/selector-placement.js';
|
|
18
18
|
import '../styles/dropdown.css';
|
|
19
19
|
import '../styles/topbar.css';
|
|
20
|
-
import { siteHref } from '
|
|
20
|
+
import { siteHref } from '../../../packages/components/src/lib/site-base';
|
|
21
21
|
|
|
22
22
|
interface Props {
|
|
23
23
|
config: DocsConfig;
|
|
@@ -218,38 +218,11 @@ pre {
|
|
|
218
218
|
display: block;
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
-
/*
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
stashes the dark equivalents in --shiki-dark/--shiki-dark-bg custom
|
|
226
|
-
properties. Swapping to those on [data-theme='dark'] is the officially
|
|
227
|
-
documented way to make Shiki-highlighted code follow a manual
|
|
228
|
-
(non-media-query) theme toggle - see
|
|
229
|
-
https://docs.astro.build/en/guides/syntax-highlighting/#setting-light-and-dark-mode-themes.
|
|
230
|
-
Site-wide/article-content concern, unrelated to any one layout
|
|
231
|
-
component, which is why it lives here rather than in any of the
|
|
232
|
-
feature-specific stylesheets.
|
|
233
|
-
The background goes on the <pre> only: Shiki gives the spans inside no
|
|
234
|
-
background of their own, and painting the theme's background on every
|
|
235
|
-
span (.line included) covered the highlighted, diff, error and focus
|
|
236
|
-
line colors and the highlighted words in dark mode. */
|
|
237
|
-
[data-theme="dark"] .astro-code {
|
|
238
|
-
background-color: var(--shiki-dark-bg) !important;
|
|
239
|
-
}
|
|
240
|
-
[data-theme="dark"] .astro-code,
|
|
241
|
-
[data-theme="dark"] .astro-code span {
|
|
242
|
-
color: var(--shiki-dark) !important;
|
|
243
|
-
font-style: var(--shiki-dark-font-style) !important;
|
|
244
|
-
font-weight: var(--shiki-dark-font-weight) !important;
|
|
245
|
-
text-decoration: var(--shiki-dark-text-decoration) !important;
|
|
246
|
-
}
|
|
221
|
+
/* Shiki's dark theme on code blocks, the code blocks themselves, and icons
|
|
222
|
+
given as an image are the components package's
|
|
223
|
+
(packages/components/src/styles/components.css, imported by
|
|
224
|
+
BaseLayout.astro right after this file). */
|
|
247
225
|
|
|
248
|
-
/* An icon given as an image URL or path (resolveIcon()'s 'image' kind,
|
|
249
|
-
rendered by AppIcon.astro) - 1em square inside its caller's own icon
|
|
250
|
-
span, so it sizes like a glyph icon would. Lives here rather than in
|
|
251
|
-
AppIcon.astro so it's part of the shared stylesheet, not an inline
|
|
252
|
-
<style> added to every page. */
|
|
253
226
|
/* An image the build gave its file's width and height
|
|
254
227
|
(lib/rehype-image-loading.js): those attributes reserve its place while
|
|
255
228
|
it loads, and this keeps its height following its width when it's shown
|
|
@@ -280,12 +253,6 @@ pre {
|
|
|
280
253
|
:where(img[data-wd-sized]) {
|
|
281
254
|
height: auto;
|
|
282
255
|
}
|
|
283
|
-
img.wd-icon-img {
|
|
284
|
-
display: block;
|
|
285
|
-
width: 1em;
|
|
286
|
-
height: 1em;
|
|
287
|
-
object-fit: contain;
|
|
288
|
-
}
|
|
289
256
|
|
|
290
257
|
/* Scrollbars of the columns beside the page - the sidebar, the table of
|
|
291
258
|
contents, the mobile menu and its option lists: a thin pill in the
|
package/src/lib/a11y-check.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `writedocs a11y`: accessibility problems that can be found in the source,
|
|
2
2
|
// without building - the ones an author introduces and can fix in a page or
|
|
3
3
|
// in writedocs.json. Plain JavaScript, loaded by plain Node from an
|
|
4
|
-
// installed package (see lib/icons.js's comment on why not TypeScript).
|
|
4
|
+
// installed package (see packages/components/src/lib/icons.js's comment on why not TypeScript).
|
|
5
5
|
//
|
|
6
6
|
// - contrast (WCAG 2 AA, 4.5:1 for text) of the colors writedocs.json sets:
|
|
7
7
|
// links (styles.colors.primary) on the light and dark backgrounds, body
|
package/src/lib/base-path.js
CHANGED
|
@@ -36,31 +36,10 @@ export function normalizeBasePath(value) {
|
|
|
36
36
|
return value;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/** `url` with the base in front, if it's a site address - "/a/" -> "/docs/a/",
|
|
46
|
-
* "/" -> "/docs/". Anything else, and everything when there's no base,
|
|
47
|
-
* comes back as it is. */
|
|
48
|
-
export function withBase(base, url) {
|
|
49
|
-
if (!base || !isSiteAddress(url)) return url;
|
|
50
|
-
return base + url;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/** A `srcset` with the base in front of each site address in it. */
|
|
54
|
-
export function srcsetWithBase(base, srcset) {
|
|
55
|
-
if (!base || typeof srcset !== 'string') return srcset;
|
|
56
|
-
return srcset
|
|
57
|
-
.split(',')
|
|
58
|
-
.map((candidate) => {
|
|
59
|
-
const [url, ...descriptor] = candidate.trim().split(/\s+/);
|
|
60
|
-
return [withBase(base, url), ...descriptor].join(' ');
|
|
61
|
-
})
|
|
62
|
-
.join(', ');
|
|
63
|
-
}
|
|
39
|
+
// isSiteAddress(), withBase() and srcsetWithBase() - which addresses take the
|
|
40
|
+
// base, and putting it in front of them - live in the components package,
|
|
41
|
+
// whose components write addresses too.
|
|
42
|
+
export { isSiteAddress, withBase, srcsetWithBase } from '../../packages/components/src/lib/base-path.js';
|
|
64
43
|
|
|
65
44
|
/** The address inside the site for a request path - "/docs/a/" -> "/a/",
|
|
66
45
|
* "/docs" -> "/" - or null when the path isn't under the base. With no base,
|
package/src/lib/color.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// goes on a configured color, and by `writedocs a11y` (lib/a11y-check.js),
|
|
4
4
|
// which checks that choice. One implementation, so the check always
|
|
5
5
|
// measures what the site actually renders. Plain JavaScript, loaded by
|
|
6
|
-
// plain Node from an installed package (see lib/icons.js's comment).
|
|
6
|
+
// plain Node from an installed package (see packages/components/src/lib/icons.js's comment).
|
|
7
7
|
|
|
8
8
|
/** [r, g, b] for `#rgb`/`#rrggbb` (the `#` optional), or null. */
|
|
9
9
|
export function parseHex(value) {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The generator's answers to what the components package asks of its host
|
|
2
|
+
// (packages/components/src/host.js has the default and what each function
|
|
3
|
+
// means). astro.config.mjs passes this file to the package's integration,
|
|
4
|
+
// which puts it in place of the default. Both read the site being built:
|
|
5
|
+
// its writedocs.json and its files.
|
|
6
|
+
import { loadDocsConfig, resolveCodeblockTheme } from './config';
|
|
7
|
+
import { imageFileFor, imageSize as fileImageSize } from './image-size.js';
|
|
8
|
+
|
|
9
|
+
const contentDir = process.env.WRITEDOCS_CONTENT_DIR || process.cwd();
|
|
10
|
+
|
|
11
|
+
/** writedocs.json's styles.codeblocks themes - read on every call, so an
|
|
12
|
+
* edit during `writedocs dev` reaches the next render. */
|
|
13
|
+
export function codeblockTheme(): { light: string; dark: string } {
|
|
14
|
+
return resolveCodeblockTheme(loadDocsConfig(contentDir));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** The size of the project's file at `src`, or null when it isn't one. */
|
|
18
|
+
export function imageSize(src: string): { width: number; height: number } | null {
|
|
19
|
+
const file = imageFileFor(src, contentDir);
|
|
20
|
+
return (file && fileImageSize(file, contentDir)) || null;
|
|
21
|
+
}
|
package/src/lib/config-file.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Reading writedocs.json (and the other JSON configs `writedocs convert`
|
|
2
2
|
// reads) as text. Plain JavaScript, not TypeScript, so the CLI can load it
|
|
3
|
-
// with plain Node - see lib/icons.js's comment.
|
|
3
|
+
// with plain Node - see packages/components/src/lib/icons.js's comment.
|
|
4
4
|
//
|
|
5
5
|
// Windows editors - Notepad, PowerShell 5.1's `Out-File`/`Set-Content
|
|
6
6
|
// -Encoding utf8` - save UTF-8 with a byte order mark. JSON.parse rejects
|
package/src/lib/config.ts
CHANGED
|
@@ -289,9 +289,10 @@ export type IconResolution =
|
|
|
289
289
|
| { kind: 'image'; src: string } // an image URL or site path, rendered as <img>
|
|
290
290
|
| { kind: 'text'; value: string }; // literal text/emoji, rendered as-is
|
|
291
291
|
|
|
292
|
-
// The implementation lives in lib/icons.js -
|
|
293
|
-
// `writedocs validate` loads it with plain Node
|
|
294
|
-
|
|
292
|
+
// The implementation lives in the components package's lib/icons.js -
|
|
293
|
+
// plain JavaScript, because `writedocs validate` loads it with plain Node
|
|
294
|
+
// (see that file's comment).
|
|
295
|
+
export { resolveIcon, iconExists, iconSvg } from '../../packages/components/src/lib/icons.js';
|
|
295
296
|
|
|
296
297
|
// ---------------------------------------------------------------------
|
|
297
298
|
// OpenAPI navigation expansion - turns a group's `openapi: { src, path }`
|
package/src/lib/content-check.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `writedocs validate`'s content pass: everything in a site's pages that
|
|
2
2
|
// would break the build or silently degrade it, found in one run instead of
|
|
3
3
|
// one build failure at a time. Plain JavaScript, loaded by plain Node from
|
|
4
|
-
// an installed package (see lib/icons.js's comment on why not TypeScript).
|
|
4
|
+
// an installed package (see packages/components/src/lib/icons.js's comment on why not TypeScript).
|
|
5
5
|
//
|
|
6
6
|
// Errors - the build would fail:
|
|
7
7
|
// - a page's frontmatter doesn't match the page schema (the same
|
|
@@ -31,7 +31,7 @@ import path from 'node:path';
|
|
|
31
31
|
import matter from 'gray-matter';
|
|
32
32
|
import { visit } from 'unist-util-visit';
|
|
33
33
|
import { findAllPages, fileIdForPath, titleFromPath, navPageId } from './pages.js';
|
|
34
|
-
import { iconExists } from '
|
|
34
|
+
import { iconExists } from '../../packages/components/src/lib/icons.js';
|
|
35
35
|
import { findUnknownComponents } from './mdx-unknown-components.js';
|
|
36
36
|
import { findInteractiveComponents, simplifiedBuiltinMessage } from './mdx-inline-react.js';
|
|
37
37
|
import { pageFrontmatterSchema, createJsonLocator } from './config-schema.js';
|
package/src/lib/link-check.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// `writedocs broken-links`: every internal link in the content - page
|
|
2
2
|
// bodies, the snippets they import, and writedocs.json - checked against the
|
|
3
3
|
// site the build would produce, without building it. Plain JavaScript,
|
|
4
|
-
// loaded by plain Node from an installed package (see lib/icons.js's
|
|
4
|
+
// loaded by plain Node from an installed package (see packages/components/src/lib/icons.js's
|
|
5
5
|
// comment on why not TypeScript).
|
|
6
6
|
//
|
|
7
7
|
// A link is broken when, on the built site:
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
//
|
|
31
31
|
// External links (http:, mailto:, ...) aren't checked.
|
|
32
32
|
import fs from 'node:fs';
|
|
33
|
-
import { estreeText } from '
|
|
33
|
+
import { estreeText } from '../../packages/components/src/lib/plain-text.js';
|
|
34
34
|
import path from 'node:path';
|
|
35
35
|
import { createRequire } from 'node:module';
|
|
36
36
|
import { pathToFileURL } from 'node:url';
|
|
@@ -3,7 +3,7 @@ import { parse as acornParse } from 'acorn';
|
|
|
3
3
|
|
|
4
4
|
// The exact same set [...slug].astro passes as the `components` prop to
|
|
5
5
|
// every page's own <Content components={components} /> call (see
|
|
6
|
-
//
|
|
6
|
+
// packages/components/src/index.ts, the barrel this imports from) - kept as one
|
|
7
7
|
// literal list rather than importing that map here, since this runs inside
|
|
8
8
|
// astro.config.mjs's markdown pipeline, a different module graph than
|
|
9
9
|
// [...slug].astro's own.
|
|
@@ -58,7 +58,7 @@ const PACKAGE_SPECIFIER = 'writedocs/components';
|
|
|
58
58
|
/**
|
|
59
59
|
* A remark plugin that auto-imports any of Writedocs' built-in components
|
|
60
60
|
* (`Callout`, `Card`, ...) a `.mdx` file uses but never itself imported -
|
|
61
|
-
* from `writedocs/components` (see
|
|
61
|
+
* from `writedocs/components` (see packages/components/src/index.ts) - so a snippet
|
|
62
62
|
* (see docs/dev/docs/snippets.mdx) gets the exact same zero-import
|
|
63
63
|
* experience a page under docs/ already has via [...slug].astro's own
|
|
64
64
|
* `components` prop. Runs on every `.mdx` file, pages included - harmless
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import crypto from 'node:crypto';
|
|
4
4
|
import { parse as acornParse } from 'acorn';
|
|
5
|
-
import { report } from '
|
|
5
|
+
import { report } from '../../packages/components/src/lib/cli-report.js';
|
|
6
6
|
import { writedocsTempDir } from './writedocs-temp-dir.js';
|
|
7
7
|
import { MINTLIFY_HOOKS } from './mdx-mintlify.js';
|
|
8
8
|
import { BUILTIN_COMPONENT_NAMES } from './mdx-inject-builtins.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { visit } from 'unist-util-visit';
|
|
2
|
-
import { estreeText } from '
|
|
2
|
+
import { estreeText } from '../../packages/components/src/lib/plain-text.js';
|
|
3
3
|
|
|
4
4
|
// Every JSX tag name that can carry a `title` prop and render a linkable
|
|
5
5
|
// heading of its own - the 6 Callout variants remarkInjectBuiltinComponents
|
|
@@ -20,7 +20,7 @@ const ANCHOR_ATTRIBUTE = { Update: 'label' };
|
|
|
20
20
|
// rather than a shared import, since this file runs inside
|
|
21
21
|
// astro.config.mjs's markdown pipeline, a different module graph than
|
|
22
22
|
// either component's own (same reasoning mdx-inject-builtins.js gives for
|
|
23
|
-
// not importing
|
|
23
|
+
// not importing packages/components/src/index.ts).
|
|
24
24
|
function slugify(value) {
|
|
25
25
|
return value
|
|
26
26
|
.toLowerCase()
|
|
@@ -2,7 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import { visit } from 'unist-util-visit';
|
|
3
3
|
import { parse as acornParse } from 'acorn';
|
|
4
4
|
import { BUILTIN_COMPONENT_NAMES } from './mdx-inject-builtins.js';
|
|
5
|
-
import { report } from '
|
|
5
|
+
import { report } from '../../packages/components/src/lib/cli-report.js';
|
|
6
6
|
|
|
7
7
|
// Which JSX elements in an MDX file are components writedocs can't resolve
|
|
8
8
|
// - neither a built-in nor something the file imports or defines itself.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Converts a Mintlify docs.json into a writedocs.json - `writedocs convert
|
|
2
2
|
// --mintlify` (src/cli/convert.js). Plain JavaScript so the CLI can load it
|
|
3
|
-
// from an installed package (see lib/icons.js's comment).
|
|
3
|
+
// from an installed package (see packages/components/src/lib/icons.js's comment).
|
|
4
4
|
//
|
|
5
5
|
// convertMintlifyConfig() is a pure function: Mintlify config in, writedocs
|
|
6
6
|
// config plus a list of notes out. A note is anything that couldn't be
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
// its `$ref`s first.
|
|
11
11
|
import fs from 'node:fs';
|
|
12
12
|
import path from 'node:path';
|
|
13
|
-
import { iconExists } from '
|
|
13
|
+
import { iconExists } from '../../packages/components/src/lib/icons.js';
|
|
14
14
|
import { readJsonText } from './config-file.js';
|
|
15
15
|
|
|
16
16
|
// ---------------------------------------------------------------------
|
|
@@ -32,7 +32,7 @@ import { planApiPages, writeGeneratedFiles } from '../cli/generate-api-pages.js'
|
|
|
32
32
|
import { collectOpenApiGroups } from './openapi-spec.js';
|
|
33
33
|
import { readConfigText } from './config-file.js';
|
|
34
34
|
import { writedocsTempDir } from './writedocs-temp-dir.js';
|
|
35
|
-
import { report } from '
|
|
35
|
+
import { report } from '../../packages/components/src/lib/cli-report.js';
|
|
36
36
|
import { readDevOpenApiState, writeDevOpenApiState, specProblem } from './openapi-dev-status.js';
|
|
37
37
|
import { contentStoreChanged } from './content-store-reload-integration.js';
|
|
38
38
|
|
package/src/lib/pages.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Which files in a content directory are pages. Plain JavaScript, not
|
|
2
2
|
// TypeScript, so `writedocs validate` can load it with plain Node (Node
|
|
3
|
-
// refuses to strip types under node_modules - see lib/icons.js's comment);
|
|
3
|
+
// refuses to strip types under node_modules - see packages/components/src/lib/icons.js's comment);
|
|
4
4
|
// lib/config.ts re-exports findAllPages() for everything inside Astro.
|
|
5
5
|
import fs from 'node:fs';
|
|
6
6
|
import path from 'node:path';
|
|
@@ -25,7 +25,7 @@ import { findPublishedFiles, readSpecPaths } from './project-files.js';
|
|
|
25
25
|
import { projectIgnore } from './project-ignore.js';
|
|
26
26
|
import { robotsTxt } from './robots-txt.js';
|
|
27
27
|
import { isNoindex } from './seo-tags.js';
|
|
28
|
-
import { report } from '
|
|
28
|
+
import { report } from '../../packages/components/src/lib/cli-report.js';
|
|
29
29
|
|
|
30
30
|
/** Every file under `dir`, as POSIX paths from it. */
|
|
31
31
|
function listFiles(dir, relBase = '') {
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// .md page (`raw`), and HTML tags written in MDX (`mdxJsx*` with a lowercase
|
|
10
10
|
// name) - their href, src, srcset, poster and action. Not a component's
|
|
11
11
|
// props (`<Card href="/a">`): a component writes its own addresses, with
|
|
12
|
-
// siteHref() (lib/site-base.ts), so prefixing here too would give them the
|
|
12
|
+
// siteHref() (the components package's lib/site-base.ts), so prefixing here too would give them the
|
|
13
13
|
// base twice. Not a value written as an expression (`href={link}`), which
|
|
14
14
|
// isn't known until the page runs.
|
|
15
15
|
//
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import fs from 'node:fs';
|
|
18
18
|
import path from 'node:path';
|
|
19
19
|
import matter from 'gray-matter';
|
|
20
|
-
import { iconExists } from '
|
|
20
|
+
import { iconExists } from '../../packages/components/src/lib/icons.js';
|
|
21
21
|
import { readJsonText } from './config-file.js';
|
|
22
22
|
import { fileIdForPath } from './pages.js';
|
|
23
23
|
import { Notes, LANGUAGE_NAMES } from './mintlify-convert.js';
|
package/src/pages/404.astro
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// non-dynamic page at its literal path).
|
|
10
10
|
import { loadDocsConfig } from '../lib/config';
|
|
11
11
|
import BaseLayout from '../layout/BaseLayout.astro';
|
|
12
|
-
import { siteHref } from '
|
|
12
|
+
import { siteHref } from '../../packages/components/src/lib/site-base';
|
|
13
13
|
|
|
14
14
|
const contentDir = process.env.WRITEDOCS_CONTENT_DIR || process.cwd();
|
|
15
15
|
const config = loadDocsConfig(contentDir);
|