@wrksz/docs 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +157 -2
- package/dist/agents.d.ts +30 -0
- package/dist/agents.js +70 -0
- package/dist/components/agent-logos.js +90 -0
- package/dist/components/agent-prompt.d.ts +29 -0
- package/dist/components/agent-prompt.js +100 -0
- package/dist/components/badge.d.ts +16 -0
- package/dist/components/badge.js +26 -0
- package/dist/components/brand.js +30 -0
- package/dist/components/callout.d.ts +24 -0
- package/dist/components/callout.js +58 -0
- package/dist/components/cards.d.ts +26 -0
- package/dist/components/cards.js +48 -0
- package/dist/components/code-body.js +18 -0
- package/dist/components/code-group.d.ts +20 -0
- package/dist/components/code-group.js +41 -0
- package/dist/components/code-tabs.d.ts +30 -0
- package/dist/components/code-tabs.js +49 -0
- package/dist/components/content-tabs.d.ts +14 -0
- package/dist/components/content-tabs.js +27 -0
- package/dist/components/copy-code.js +41 -0
- package/dist/components/deferred-analytics.js +5 -0
- package/dist/components/details.d.ts +20 -0
- package/dist/components/details.js +29 -0
- package/dist/components/heading-link.js +23 -0
- package/dist/components/heading.d.ts +5 -0
- package/dist/components/heading.js +22 -0
- package/dist/components/icons.js +362 -0
- package/dist/components/image.d.ts +27 -0
- package/dist/components/image.js +204 -0
- package/dist/components/inline-text.js +14 -0
- package/dist/components/install.d.ts +22 -0
- package/dist/components/install.js +62 -0
- package/dist/components/mdx-tabs.d.ts +22 -0
- package/dist/components/mdx-tabs.js +30 -0
- package/dist/components/practice.d.ts +41 -0
- package/dist/components/practice.js +99 -0
- package/dist/components/props.d.ts +37 -0
- package/dist/components/props.js +70 -0
- package/dist/components/status.js +35 -0
- package/dist/components/steps.d.ts +18 -0
- package/dist/components/steps.js +23 -0
- package/dist/components/theme-switch.js +31 -0
- package/dist/components/ui/kbd.js +410 -0
- package/dist/components/ui/scroll-area.js +169 -0
- package/dist/components/ui/table.d.ts +33 -0
- package/dist/components/ui/table.js +103 -0
- package/dist/components/ui/tabs.js +69 -0
- package/dist/components/ui/toast.js +629 -0
- package/dist/components/ui/tooltip.js +31 -0
- package/dist/components/wrksz-mark.js +12 -0
- package/dist/docs/index.d.ts +8 -0
- package/dist/docs/index.js +8 -0
- package/dist/docs/layout.d.ts +6 -0
- package/dist/docs/layout.js +10 -0
- package/dist/docs/page-actions.d.ts +36 -0
- package/dist/docs/page-actions.js +136 -0
- package/dist/docs/page-footer.d.ts +14 -0
- package/dist/docs/page-footer.js +68 -0
- package/dist/docs/page-header.d.ts +13 -0
- package/dist/docs/page-header.js +57 -0
- package/dist/docs/page.d.ts +16 -0
- package/dist/docs/page.js +38 -0
- package/dist/docs/reading.js +64 -0
- package/dist/docs/shell.js +101 -0
- package/dist/docs/sidebar.js +161 -0
- package/dist/docs/toc-bar.d.ts +12 -0
- package/dist/docs/toc-bar.js +132 -0
- package/dist/docs/toc.d.ts +11 -0
- package/dist/docs/toc.js +127 -0
- package/dist/fonts/Inter-Italic.woff2 +0 -0
- package/dist/fonts/Inter-LICENSE.txt +92 -0
- package/dist/fonts/Inter.woff2 +0 -0
- package/dist/fonts/IoskeleyMono-Bold.woff2 +0 -0
- package/dist/fonts/IoskeleyMono-Italic.woff2 +0 -0
- package/dist/fonts/IoskeleyMono-LICENSE.txt +92 -0
- package/dist/fonts/IoskeleyMono-Regular.woff2 +0 -0
- package/dist/fonts.d.ts +1 -0
- package/dist/fonts.js +38 -0
- package/dist/home/features.d.ts +39 -0
- package/dist/home/features.js +75 -0
- package/dist/home/footer.d.ts +4 -0
- package/dist/home/footer.js +79 -0
- package/dist/home/hero-content.js +102 -0
- package/dist/home/hero-install.js +128 -0
- package/dist/home/hero-stage.d.ts +4 -0
- package/dist/home/hero-stage.js +9 -0
- package/dist/home/hero.d.ts +6 -0
- package/dist/home/hero.js +16 -0
- package/dist/home/home-header.d.ts +1 -0
- package/dist/home/home-header.js +173 -0
- package/dist/home/index.d.ts +7 -0
- package/dist/home/index.js +7 -0
- package/dist/home/layout.d.ts +6 -0
- package/dist/home/layout.js +15 -0
- package/dist/home/reveal.js +31 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/lib/clipboard.js +55 -0
- package/dist/lib/cn.js +1 -0
- package/dist/lib/format.js +9 -0
- package/dist/lib/package-manager-script.js +12 -0
- package/dist/lib/package-manager.js +54 -0
- package/dist/lib/theme-config.js +10 -0
- package/dist/llms.d.ts +34 -0
- package/dist/llms.js +111 -0
- package/dist/next.d.ts +18 -0
- package/dist/next.js +45 -0
- package/dist/node_modules/.pnpm/@types_mdast@4.0.4/node_modules/@types/mdast/index.d.ts +930 -0
- package/dist/node_modules/.pnpm/@types_mdx@2.0.14/node_modules/@types/mdx/types.d.ts +81 -0
- package/dist/node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.d.ts +80 -0
- package/dist/registry.d.ts +61 -0
- package/dist/registry.js +113 -0
- package/dist/root.d.ts +9 -0
- package/dist/root.js +34 -0
- package/dist/search.d.ts +5 -0
- package/dist/search.js +43 -0
- package/dist/seo/index.d.ts +6 -0
- package/dist/seo/index.js +6 -0
- package/dist/seo/json-ld.d.ts +17 -0
- package/dist/seo/json-ld.js +88 -0
- package/dist/seo/metadata.d.ts +21 -0
- package/dist/seo/metadata.js +75 -0
- package/dist/seo/robots.d.ts +14 -0
- package/dist/seo/robots.js +18 -0
- package/dist/seo/sitemap.d.ts +16 -0
- package/dist/seo/sitemap.js +26 -0
- package/dist/seo/url.d.ts +6 -0
- package/dist/seo/url.js +11 -0
- package/dist/server.js +63 -0
- package/dist/site-context.js +17 -0
- package/dist/site.d.ts +41 -0
- package/dist/site.js +13 -0
- package/dist/source/compile.d.ts +6 -0
- package/dist/source/compile.js +32 -0
- package/dist/source/errors.d.ts +4 -0
- package/dist/source/errors.js +10 -0
- package/dist/source/frontmatter.d.ts +13 -0
- package/dist/source/frontmatter.js +102 -0
- package/dist/source/highlight.js +102 -0
- package/dist/source/index.d.ts +36 -0
- package/dist/source/index.js +102 -0
- package/dist/source/markdown.d.ts +48 -0
- package/dist/source/markdown.js +393 -0
- package/dist/source/prompt.js +33 -0
- package/dist/source/scan.d.ts +8 -0
- package/dist/source/scan.js +64 -0
- package/dist/source/toc.d.ts +5 -0
- package/dist/source/toc.js +28 -0
- package/dist/source/tree.d.ts +29 -0
- package/dist/source/tree.js +91 -0
- package/dist/styles.css +879 -0
- package/dist/typography.d.ts +101 -0
- package/dist/typography.js +232 -0
- package/package.json +84 -4
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DocsShell } from "./shell.js";
|
|
2
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
// src/docs/layout.tsx
|
|
4
|
+
function DocsLayout({ source, children }) {
|
|
5
|
+
return /* @__PURE__ */ jsx(DocsShell, {
|
|
6
|
+
tree: source.tree(),
|
|
7
|
+
children
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
export { DocsLayout };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import { Agent } from "../agents.js";
|
|
3
|
+
declare const VARIANTS: {
|
|
4
|
+
readonly raised: "control-raised";
|
|
5
|
+
readonly ghost: "text-fd-foreground/70 transition-[color,background-color,scale] duration-150 hover:bg-fd-accent hover:text-fd-foreground";
|
|
6
|
+
};
|
|
7
|
+
type ActionProps = {
|
|
8
|
+
variant?: keyof typeof VARIANTS;
|
|
9
|
+
icon?: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
export type PageActionProps = ActionProps & (({
|
|
12
|
+
href: string;
|
|
13
|
+
} & ComponentProps<"a">) | ({
|
|
14
|
+
href?: undefined;
|
|
15
|
+
} & ComponentProps<"button">));
|
|
16
|
+
export declare function PageAction({ variant, icon, className, children, ...props }: PageActionProps): import("react").JSX.Element;
|
|
17
|
+
export declare function PageActions({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
|
|
18
|
+
export declare function EditPageAction({ path, children }: {
|
|
19
|
+
path: string;
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
}): import("react").JSX.Element;
|
|
22
|
+
/** Copies the page as Markdown, fetched from its `.md` route when clicked. */
|
|
23
|
+
export declare function CopyMarkdownAction({ children }: {
|
|
24
|
+
children?: ReactNode;
|
|
25
|
+
}): import("react").JSX.Element;
|
|
26
|
+
/**
|
|
27
|
+
* "Open" with a menu: the page as Markdown, then each agent with a prompt to read it. The
|
|
28
|
+
* agents come from `agents`, else the site's `openIn`, else ChatGPT, Claude, Grok, Cursor.
|
|
29
|
+
*/
|
|
30
|
+
export declare function OpenPageMenu({ agents, prompt, children }: {
|
|
31
|
+
agents?: (string | Agent)[];
|
|
32
|
+
/** The text each agent gets, from the page's Markdown URL. */
|
|
33
|
+
prompt?: (url: string) => string;
|
|
34
|
+
children?: ReactNode;
|
|
35
|
+
}): import("react").JSX.Element;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { Menu } from "@base-ui/react/menu";
|
|
3
|
+
import { usePathname } from "next/navigation";
|
|
4
|
+
import { agentUrl, resolveAgents } from "../agents.js";
|
|
5
|
+
import { AgentLogo, MarkdownLogo } from "../components/agent-logos.js";
|
|
6
|
+
import { ArrowUpRightIcon, CheckIcon, ChevronDownIcon, CopyIcon, GitHubIcon } from "../components/icons.js";
|
|
7
|
+
import { useCopy } from "../lib/clipboard.js";
|
|
8
|
+
import { cn } from "../lib/cn.js";
|
|
9
|
+
import { editUrl } from "../site.js";
|
|
10
|
+
import { useSite } from "../site-context.js";
|
|
11
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
+
// src/docs/page-actions.tsx
|
|
13
|
+
/** Agents the Open menu offers when the site names none. */
|
|
14
|
+
const OPEN_IN = [
|
|
15
|
+
"chatgpt",
|
|
16
|
+
"claude",
|
|
17
|
+
"grok",
|
|
18
|
+
"cursor"
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Actions sit `gap-2` apart; each reaches 4px past its edges (`after:`), so the hit areas
|
|
22
|
+
* meet in the middle of the gap and the pointer never lands between two of them.
|
|
23
|
+
*/
|
|
24
|
+
const ACTION = "relative flex h-8 shrink-0 after:absolute after:-inset-1 after:content-[''] items-center gap-2 rounded-lg px-2.5 text-sm text-fd-foreground outline-none select-none focus-visible:ring-2 focus-visible:ring-fd-ring active:scale-[0.97] [&_svg]:size-3.5 [&_svg]:shrink-0";
|
|
25
|
+
const VARIANTS = {
|
|
26
|
+
raised: "control-raised",
|
|
27
|
+
ghost: "text-fd-foreground/70 transition-[color,background-color,scale] duration-150 hover:bg-fd-accent hover:text-fd-foreground"
|
|
28
|
+
};
|
|
29
|
+
function PageAction({ variant = "ghost", icon, className, children, ...props }) {
|
|
30
|
+
const classes = cn(ACTION, VARIANTS[variant], className);
|
|
31
|
+
if (props.href !== void 0) {
|
|
32
|
+
const external = /^https?:\/\//.test(props.href);
|
|
33
|
+
return /* @__PURE__ */ jsxs("a", {
|
|
34
|
+
...external ? {
|
|
35
|
+
target: "_blank",
|
|
36
|
+
rel: "noreferrer noopener"
|
|
37
|
+
} : {},
|
|
38
|
+
...props,
|
|
39
|
+
className: classes,
|
|
40
|
+
children: [icon, children]
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return /* @__PURE__ */ jsxs("button", {
|
|
44
|
+
type: "button",
|
|
45
|
+
...props,
|
|
46
|
+
className: classes,
|
|
47
|
+
children: [icon, children]
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
function PageActions({ className, ...props }) {
|
|
51
|
+
return /* @__PURE__ */ jsx("div", {
|
|
52
|
+
className: cn("flex flex-wrap items-center gap-2", className),
|
|
53
|
+
...props
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function EditPageAction({ path, children = "Edit on GitHub" }) {
|
|
57
|
+
const site = useSite();
|
|
58
|
+
return /* @__PURE__ */ jsx(PageAction, {
|
|
59
|
+
href: editUrl(site, path),
|
|
60
|
+
icon: /* @__PURE__ */ jsx(GitHubIcon, {}),
|
|
61
|
+
children
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
/** This page as Markdown: its path plus `.md`, served by the `withDocs` rewrites. */
|
|
65
|
+
function useMarkdownPath() {
|
|
66
|
+
return `${usePathname().replace(/\/$/, "")}.md`;
|
|
67
|
+
}
|
|
68
|
+
/** Copies the page as Markdown, fetched from its `.md` route when clicked. */
|
|
69
|
+
function CopyMarkdownAction({ children = "Copy Markdown" }) {
|
|
70
|
+
const path = useMarkdownPath();
|
|
71
|
+
const { copied, copy } = useCopy();
|
|
72
|
+
function onClick() {
|
|
73
|
+
copy(fetch(path).then((response) => {
|
|
74
|
+
if (!response.ok) throw new Error(`${path} answered ${response.status}`);
|
|
75
|
+
return response.text();
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
78
|
+
return /* @__PURE__ */ jsx(PageAction, {
|
|
79
|
+
onClick,
|
|
80
|
+
icon: /* @__PURE__ */ jsxs("span", {
|
|
81
|
+
className: "swap",
|
|
82
|
+
children: [/* @__PURE__ */ jsx(CopyIcon, { "data-active": copied ? void 0 : "" }), /* @__PURE__ */ jsx(CheckIcon, { "data-active": copied ? "" : void 0 })]
|
|
83
|
+
}),
|
|
84
|
+
children
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
const ITEM = "flex h-9 items-center gap-2.5 rounded-lg ps-2.5 pe-2 text-sm text-fd-foreground outline-none select-none data-highlighted:bg-fd-accent [&>svg:first-child]:size-4 [&>svg:first-child]:shrink-0";
|
|
88
|
+
function MenuLink({ href, icon, children }) {
|
|
89
|
+
return /* @__PURE__ */ jsxs(Menu.LinkItem, {
|
|
90
|
+
href,
|
|
91
|
+
target: "_blank",
|
|
92
|
+
rel: "noreferrer noopener",
|
|
93
|
+
closeOnClick: true,
|
|
94
|
+
className: ITEM,
|
|
95
|
+
children: [
|
|
96
|
+
icon,
|
|
97
|
+
/* @__PURE__ */ jsx("span", {
|
|
98
|
+
className: "flex-1",
|
|
99
|
+
children
|
|
100
|
+
}),
|
|
101
|
+
/* @__PURE__ */ jsx(ArrowUpRightIcon, { className: "size-3.5 text-fd-muted-foreground" })
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* "Open" with a menu: the page as Markdown, then each agent with a prompt to read it. The
|
|
107
|
+
* agents come from `agents`, else the site's `openIn`, else ChatGPT, Claude, Grok, Cursor.
|
|
108
|
+
*/
|
|
109
|
+
function OpenPageMenu({ agents, prompt = (url) => `Read ${url} so I can ask questions about it.`, children = "Open" }) {
|
|
110
|
+
const site = useSite();
|
|
111
|
+
const path = useMarkdownPath();
|
|
112
|
+
const url = `${site.url.replace(/\/$/, "")}${path}`;
|
|
113
|
+
const offered = resolveAgents(agents ?? site.openIn ?? OPEN_IN);
|
|
114
|
+
return /* @__PURE__ */ jsxs(Menu.Root, { children: [/* @__PURE__ */ jsxs(Menu.Trigger, {
|
|
115
|
+
className: cn(ACTION, VARIANTS.ghost, "group data-popup-open:bg-fd-accent data-popup-open:text-fd-foreground"),
|
|
116
|
+
children: [children, /* @__PURE__ */ jsx(ChevronDownIcon, { className: "transition-[rotate] duration-150 ease-out group-data-popup-open:rotate-180" })]
|
|
117
|
+
}), /* @__PURE__ */ jsx(Menu.Portal, { children: /* @__PURE__ */ jsx(Menu.Positioner, {
|
|
118
|
+
side: "bottom",
|
|
119
|
+
align: "start",
|
|
120
|
+
sideOffset: 6,
|
|
121
|
+
className: "z-50",
|
|
122
|
+
children: /* @__PURE__ */ jsxs(Menu.Popup, {
|
|
123
|
+
className: "install-menu flex min-w-56 flex-col rounded-[14px] p-1.5 outline-none",
|
|
124
|
+
children: [/* @__PURE__ */ jsx(MenuLink, {
|
|
125
|
+
href: path,
|
|
126
|
+
icon: /* @__PURE__ */ jsx(MarkdownLogo, {}),
|
|
127
|
+
children: "View as Markdown"
|
|
128
|
+
}), offered.map((agent) => /* @__PURE__ */ jsxs(MenuLink, {
|
|
129
|
+
href: agentUrl(agent, prompt(url)),
|
|
130
|
+
icon: agent.logo ? /* @__PURE__ */ jsx(AgentLogo, { logo: agent.logo }) : /* @__PURE__ */ jsx("span", { className: "size-4" }),
|
|
131
|
+
children: ["Open in ", agent.label]
|
|
132
|
+
}, agent.id))]
|
|
133
|
+
})
|
|
134
|
+
}) })] });
|
|
135
|
+
}
|
|
136
|
+
export { CopyMarkdownAction, EditPageAction, OpenPageMenu, PageAction, PageActions };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ContentPage } from "../source/scan.js";
|
|
2
|
+
import { Source } from "../source/index.js";
|
|
3
|
+
export type PageFooterProps = {
|
|
4
|
+
source: Source;
|
|
5
|
+
page: ContentPage;
|
|
6
|
+
/** Hide "Edit on GitHub", e.g. for generated pages. */
|
|
7
|
+
edit?: boolean;
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The end of a page: "Edit on GitHub" and when the file last changed, then links to the
|
|
12
|
+
* previous and next pages in the sidebar's order.
|
|
13
|
+
*/
|
|
14
|
+
export declare function PageFooter({ source, page, edit, className }: PageFooterProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
import { ArrowRightIcon } from "../components/icons.js";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { EditPageAction } from "./page-actions.js";
|
|
5
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/docs/page-footer.tsx
|
|
7
|
+
const DATE = new Intl.DateTimeFormat("en-US", {
|
|
8
|
+
month: "short",
|
|
9
|
+
day: "numeric",
|
|
10
|
+
year: "numeric"
|
|
11
|
+
});
|
|
12
|
+
function Neighbour({ page, direction }) {
|
|
13
|
+
const next = direction === "next";
|
|
14
|
+
return /* @__PURE__ */ jsxs(Link, {
|
|
15
|
+
href: page.url,
|
|
16
|
+
className: cn("flex flex-col gap-1 rounded-xl px-4 py-3.5 shadow-[0_0_0_1px_var(--control-ring)] outline-none transition-colors duration-150 hover:bg-fd-card focus-visible:ring-2 focus-visible:ring-fd-ring", next && "col-start-2 items-end text-end"),
|
|
17
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
18
|
+
className: "flex items-center gap-1.5 text-[0.8125rem] text-fd-muted-foreground",
|
|
19
|
+
children: [
|
|
20
|
+
next ? null : /* @__PURE__ */ jsx(ArrowRightIcon, { className: "size-3.5 -scale-x-100" }),
|
|
21
|
+
next ? "Next" : "Previous",
|
|
22
|
+
next ? /* @__PURE__ */ jsx(ArrowRightIcon, { className: "size-3.5" }) : null
|
|
23
|
+
]
|
|
24
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
25
|
+
className: "text-[0.9375rem] font-medium text-pretty text-fd-foreground",
|
|
26
|
+
children: page.title
|
|
27
|
+
})]
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* The end of a page: "Edit on GitHub" and when the file last changed, then links to the
|
|
32
|
+
* previous and next pages in the sidebar's order.
|
|
33
|
+
*/
|
|
34
|
+
function PageFooter({ source, page, edit = true, className }) {
|
|
35
|
+
const { previous, next } = source.neighbours(page);
|
|
36
|
+
const updated = source.updated(page);
|
|
37
|
+
return /* @__PURE__ */ jsxs("footer", {
|
|
38
|
+
className: cn("mt-16 flex flex-col gap-6", className),
|
|
39
|
+
children: [edit || updated ? /* @__PURE__ */ jsxs("div", {
|
|
40
|
+
className: "flex flex-wrap items-center justify-between gap-x-4 gap-y-2",
|
|
41
|
+
children: [edit ? /* @__PURE__ */ jsx("div", {
|
|
42
|
+
className: "-ms-2.5",
|
|
43
|
+
children: /* @__PURE__ */ jsx(EditPageAction, { path: page.path })
|
|
44
|
+
}) : null, updated ? /* @__PURE__ */ jsxs("p", {
|
|
45
|
+
className: "text-[0.8125rem] text-fd-muted-foreground",
|
|
46
|
+
children: [
|
|
47
|
+
"Updated",
|
|
48
|
+
" ",
|
|
49
|
+
/* @__PURE__ */ jsx("time", {
|
|
50
|
+
dateTime: updated.toISOString(),
|
|
51
|
+
children: DATE.format(updated)
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
}) : null]
|
|
55
|
+
}) : null, previous || next ? /* @__PURE__ */ jsxs("nav", {
|
|
56
|
+
"aria-label": "More pages",
|
|
57
|
+
className: "grid gap-3 sm:grid-cols-2",
|
|
58
|
+
children: [previous ? /* @__PURE__ */ jsx(Neighbour, {
|
|
59
|
+
page: previous,
|
|
60
|
+
direction: "previous"
|
|
61
|
+
}) : null, next ? /* @__PURE__ */ jsx(Neighbour, {
|
|
62
|
+
page: next,
|
|
63
|
+
direction: "next"
|
|
64
|
+
}) : null]
|
|
65
|
+
}) : null]
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
export { PageFooter };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ContentPage } from "../source/scan.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import { Source } from "../source/index.js";
|
|
4
|
+
export type PageHeaderContext = {
|
|
5
|
+
page: ContentPage;
|
|
6
|
+
defaults: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
export type PageHeaderProps = {
|
|
9
|
+
source: Source;
|
|
10
|
+
page: ContentPage;
|
|
11
|
+
actions?: ReactNode | ((context: PageHeaderContext) => ReactNode);
|
|
12
|
+
};
|
|
13
|
+
export declare function PageHeader({ source, page, actions }: PageHeaderProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import Link from "next/link";
|
|
2
|
+
import { Status } from "../components/status.js";
|
|
3
|
+
import { Lead, Title } from "../typography.js";
|
|
4
|
+
import { CopyMarkdownAction, OpenPageMenu, PageActions } from "./page-actions.js";
|
|
5
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
6
|
+
// src/docs/page-header.tsx
|
|
7
|
+
function Trail({ crumbs }) {
|
|
8
|
+
return /* @__PURE__ */ jsx("nav", {
|
|
9
|
+
"aria-label": "Breadcrumb",
|
|
10
|
+
children: /* @__PURE__ */ jsx("ol", {
|
|
11
|
+
className: "flex flex-wrap items-center gap-x-1.5 text-sm text-fd-muted-foreground",
|
|
12
|
+
children: crumbs.map((crumb, index) => /* @__PURE__ */ jsxs("li", {
|
|
13
|
+
className: "flex items-center gap-x-1.5",
|
|
14
|
+
children: [index > 0 ? /* @__PURE__ */ jsx("span", {
|
|
15
|
+
"aria-hidden": true,
|
|
16
|
+
className: "text-fd-muted-foreground/50",
|
|
17
|
+
children: "/"
|
|
18
|
+
}) : null, crumb.url ? /* @__PURE__ */ jsx(Link, {
|
|
19
|
+
href: crumb.url,
|
|
20
|
+
className: "rounded-sm outline-none transition-colors duration-150 hover:text-fd-foreground focus-visible:ring-2 focus-visible:ring-fd-ring",
|
|
21
|
+
children: crumb.title
|
|
22
|
+
}) : crumb.title]
|
|
23
|
+
}, `${crumb.title}-${index}`))
|
|
24
|
+
})
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
function PageHeader({ source, page, actions }) {
|
|
28
|
+
const crumbs = source.breadcrumbs(page);
|
|
29
|
+
const { title, description, status } = page.data;
|
|
30
|
+
const defaults = /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(CopyMarkdownAction, {}), /* @__PURE__ */ jsx(OpenPageMenu, {})] });
|
|
31
|
+
const content = typeof actions === "function" ? actions({
|
|
32
|
+
page,
|
|
33
|
+
defaults
|
|
34
|
+
}) : actions ?? defaults;
|
|
35
|
+
return /* @__PURE__ */ jsxs("header", {
|
|
36
|
+
className: "flex flex-col",
|
|
37
|
+
children: [
|
|
38
|
+
crumbs.length ? /* @__PURE__ */ jsx(Trail, { crumbs }) : null,
|
|
39
|
+
/* @__PURE__ */ jsxs("div", {
|
|
40
|
+
className: `flex items-baseline gap-3 ${crumbs.length ? "mt-3" : ""}`,
|
|
41
|
+
children: [/* @__PURE__ */ jsx(Title, { children: title }), /* @__PURE__ */ jsx(Status, {
|
|
42
|
+
...status ? { status } : {},
|
|
43
|
+
className: "text-sm"
|
|
44
|
+
})]
|
|
45
|
+
}),
|
|
46
|
+
description ? /* @__PURE__ */ jsx(Lead, {
|
|
47
|
+
className: "mt-3 max-w-xl",
|
|
48
|
+
children: description
|
|
49
|
+
}) : null,
|
|
50
|
+
content ? /* @__PURE__ */ jsx(PageActions, {
|
|
51
|
+
className: "mt-6 -ms-2.5",
|
|
52
|
+
children: content
|
|
53
|
+
}) : null
|
|
54
|
+
]
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
export { PageHeader };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TocEntry } from "../source/toc.js";
|
|
2
|
+
import { ReactNode } from "react";
|
|
3
|
+
import "../source/index.js";
|
|
4
|
+
export type DocsPageProps = {
|
|
5
|
+
/** Headings from `source.render(page)`. An empty list keeps the column, so pages line up. */
|
|
6
|
+
toc?: TocEntry[];
|
|
7
|
+
tocLabel?: string;
|
|
8
|
+
className?: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The article and its table of contents. The pair is centred in the panel; the article
|
|
13
|
+
* keeps a reading width and the contents column sticks to the top while the page scrolls.
|
|
14
|
+
* Below `xl` the column gives way to a card stuck to the top of the page.
|
|
15
|
+
*/
|
|
16
|
+
export declare function DocsPage({ toc, tocLabel, className, children }: DocsPageProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { cn } from "../lib/cn.js";
|
|
2
|
+
import { TableOfContents } from "./toc.js";
|
|
3
|
+
import { TocBar } from "./toc-bar.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
// src/docs/page.tsx
|
|
6
|
+
/**
|
|
7
|
+
* The article and its table of contents. The pair is centred in the panel; the article
|
|
8
|
+
* keeps a reading width and the contents column sticks to the top while the page scrolls.
|
|
9
|
+
* Below `xl` the column gives way to a card stuck to the top of the page.
|
|
10
|
+
*/
|
|
11
|
+
function DocsPage({ toc = [], tocLabel, className, children }) {
|
|
12
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
13
|
+
"data-docs-page": true,
|
|
14
|
+
className: cn("mx-auto w-full max-w-176 xl:max-w-264", className),
|
|
15
|
+
children: [toc.length ? /* @__PURE__ */ jsx(TocBar, {
|
|
16
|
+
toc,
|
|
17
|
+
...tocLabel ? { label: tocLabel } : {},
|
|
18
|
+
className: "sticky -top-7 mb-8 lg:-top-11 xl:hidden"
|
|
19
|
+
}) : null, /* @__PURE__ */ jsxs("div", {
|
|
20
|
+
className: "grid xl:grid-cols-[minmax(0,44rem)_13rem] xl:justify-between xl:gap-x-12",
|
|
21
|
+
children: [/* @__PURE__ */ jsx("article", {
|
|
22
|
+
"data-docs-content": true,
|
|
23
|
+
className: "min-w-0",
|
|
24
|
+
children
|
|
25
|
+
}), /* @__PURE__ */ jsx("aside", {
|
|
26
|
+
className: "hidden xl:block",
|
|
27
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
28
|
+
className: "sticky top-0 flex max-h-[calc(100svh-8rem)] flex-col",
|
|
29
|
+
children: /* @__PURE__ */ jsx(TableOfContents, {
|
|
30
|
+
toc,
|
|
31
|
+
...tocLabel ? { label: tocLabel } : {}
|
|
32
|
+
})
|
|
33
|
+
})
|
|
34
|
+
})]
|
|
35
|
+
})]
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export { DocsPage };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/docs/reading.ts
|
|
2
|
+
/** Index of the section being read: the last heading at or above the reading line. */
|
|
3
|
+
function currentSection(reading) {
|
|
4
|
+
let index = -1;
|
|
5
|
+
reading.starts.forEach((start, position) => {
|
|
6
|
+
if (start <= reading.top + 1) index = position;
|
|
7
|
+
});
|
|
8
|
+
return index;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Calls `onFrame` with the reading state once per animation frame while the page scrolls
|
|
12
|
+
* or resizes, and once at the start. Reads layout only, so it never forces extra layout.
|
|
13
|
+
*/
|
|
14
|
+
function watchReading(anchor, toc, onFrame) {
|
|
15
|
+
const area = anchor.closest("[data-scroll-area]");
|
|
16
|
+
const content = anchor.closest("[data-docs-page]")?.querySelector("[data-docs-content]") ?? document.body;
|
|
17
|
+
const headings = toc.map((entry) => document.getElementById(entry.id)).filter((heading) => heading !== null);
|
|
18
|
+
let frame = 0;
|
|
19
|
+
const update = () => {
|
|
20
|
+
frame = 0;
|
|
21
|
+
const box = area ? area.getBoundingClientRect() : {
|
|
22
|
+
top: 0,
|
|
23
|
+
bottom: window.innerHeight
|
|
24
|
+
};
|
|
25
|
+
const margin = headings[0] ? Number.parseFloat(getComputedStyle(headings[0]).scrollMarginTop) || 0 : 0;
|
|
26
|
+
const scroller = area ?? document.documentElement;
|
|
27
|
+
const range = scroller.scrollHeight - scroller.clientHeight;
|
|
28
|
+
onFrame({
|
|
29
|
+
top: box.top + margin,
|
|
30
|
+
bottom: box.bottom,
|
|
31
|
+
starts: headings.map((heading) => heading.getBoundingClientRect().top),
|
|
32
|
+
end: content.getBoundingClientRect().bottom,
|
|
33
|
+
progress: range > 0 ? Math.min(1, Math.max(0, scroller.scrollTop / range)) : 1
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
const schedule = () => {
|
|
37
|
+
if (!frame) frame = requestAnimationFrame(update);
|
|
38
|
+
};
|
|
39
|
+
update();
|
|
40
|
+
const target = area ?? window;
|
|
41
|
+
target.addEventListener("scroll", schedule, { passive: true });
|
|
42
|
+
const observer = new ResizeObserver(schedule);
|
|
43
|
+
observer.observe(content);
|
|
44
|
+
return () => {
|
|
45
|
+
cancelAnimationFrame(frame);
|
|
46
|
+
target.removeEventListener("scroll", schedule);
|
|
47
|
+
observer.disconnect();
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Scrolls to a heading the way an anchor would, smoothly unless motion is reduced. */
|
|
51
|
+
function jumpTo(event, id) {
|
|
52
|
+
if (event.button !== 0 || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return false;
|
|
53
|
+
const target = document.getElementById(id);
|
|
54
|
+
if (!target) return false;
|
|
55
|
+
event.preventDefault();
|
|
56
|
+
const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
57
|
+
target.scrollIntoView({
|
|
58
|
+
behavior: reduce ? "auto" : "smooth",
|
|
59
|
+
block: "start"
|
|
60
|
+
});
|
|
61
|
+
window.history.replaceState(null, "", `#${id}`);
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
export { currentSection, jumpTo, watchReading };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import Link from "next/link";
|
|
3
|
+
import { usePathname } from "next/navigation";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { Brand } from "../components/brand.js";
|
|
6
|
+
import { SearchIcon } from "../components/icons.js";
|
|
7
|
+
import { useSearch } from "../search.js";
|
|
8
|
+
import { useSite } from "../site-context.js";
|
|
9
|
+
import { Sidebar } from "./sidebar.js";
|
|
10
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
// src/docs/shell.tsx
|
|
12
|
+
const ICON_BUTTON = "flex size-10 items-center justify-center rounded-lg text-fd-foreground/80 outline-none transition-[color,background-color,scale] duration-150 hover:bg-fd-accent hover:text-fd-foreground focus-visible:ring-2 focus-visible:ring-fd-ring active:scale-[0.96]";
|
|
13
|
+
const BAR = "origin-center transition-transform duration-300 ease-[cubic-bezier(0.2,0,0,1)] transform-fill motion-reduce:transition-none";
|
|
14
|
+
function DocsShell({ tree, children }) {
|
|
15
|
+
const site = useSite();
|
|
16
|
+
const pathname = usePathname();
|
|
17
|
+
const { setOpen: setSearch } = useSearch();
|
|
18
|
+
const [open, setOpen] = useState(false);
|
|
19
|
+
const close = () => setOpen(false);
|
|
20
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
21
|
+
className: "docs-ground flex h-svh flex-col overflow-hidden lg:grid lg:grid-cols-[15rem_minmax(0,1fr)]",
|
|
22
|
+
children: [
|
|
23
|
+
/* @__PURE__ */ jsx("aside", {
|
|
24
|
+
className: "hidden h-svh lg:block",
|
|
25
|
+
children: /* @__PURE__ */ jsx(Sidebar, { tree })
|
|
26
|
+
}),
|
|
27
|
+
/* @__PURE__ */ jsxs("div", {
|
|
28
|
+
className: "flex h-14 shrink-0 items-center justify-between px-2 lg:hidden",
|
|
29
|
+
children: [/* @__PURE__ */ jsx(Link, {
|
|
30
|
+
href: "/",
|
|
31
|
+
"aria-label": `${site.name} home`,
|
|
32
|
+
className: "flex h-8 items-center rounded-lg px-2 text-[0.9375rem] outline-none focus-visible:ring-2 focus-visible:ring-fd-ring",
|
|
33
|
+
children: /* @__PURE__ */ jsx(Brand, {})
|
|
34
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
35
|
+
className: "flex items-center",
|
|
36
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
37
|
+
type: "button",
|
|
38
|
+
"aria-label": "Search the docs",
|
|
39
|
+
onClick: () => setSearch(true),
|
|
40
|
+
className: ICON_BUTTON,
|
|
41
|
+
children: /* @__PURE__ */ jsx(SearchIcon, { className: "size-4" })
|
|
42
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
43
|
+
type: "button",
|
|
44
|
+
"aria-expanded": open,
|
|
45
|
+
"aria-controls": "docs-mobile-sidebar",
|
|
46
|
+
"aria-label": open ? "Close menu" : "Open menu",
|
|
47
|
+
onClick: () => setOpen((value) => !value),
|
|
48
|
+
className: ICON_BUTTON,
|
|
49
|
+
children: /* @__PURE__ */ jsxs("svg", {
|
|
50
|
+
viewBox: "0 0 16 16",
|
|
51
|
+
fill: "none",
|
|
52
|
+
stroke: "currentColor",
|
|
53
|
+
strokeWidth: "1.5",
|
|
54
|
+
strokeLinecap: "round",
|
|
55
|
+
"aria-hidden": true,
|
|
56
|
+
className: "size-4.5",
|
|
57
|
+
children: [/* @__PURE__ */ jsx("path", {
|
|
58
|
+
d: "M2.75 5.5h10.5",
|
|
59
|
+
className: `${BAR} ${open ? "translate-y-[2.5px] rotate-45" : ""}`
|
|
60
|
+
}), /* @__PURE__ */ jsx("path", {
|
|
61
|
+
d: "M2.75 10.5h10.5",
|
|
62
|
+
className: `${BAR} ${open ? "translate-y-[-2.5px] -rotate-45" : ""}`
|
|
63
|
+
})]
|
|
64
|
+
})
|
|
65
|
+
})]
|
|
66
|
+
})]
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ jsxs("div", {
|
|
69
|
+
"data-open": open ? "" : void 0,
|
|
70
|
+
className: "pointer-events-none fixed inset-0 z-40 data-open:pointer-events-auto lg:hidden",
|
|
71
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
72
|
+
type: "button",
|
|
73
|
+
tabIndex: -1,
|
|
74
|
+
"aria-label": "Close menu",
|
|
75
|
+
onClick: close,
|
|
76
|
+
className: "absolute inset-0 bg-black/20 opacity-0 transition-opacity duration-200 in-data-open:opacity-100"
|
|
77
|
+
}), /* @__PURE__ */ jsx("aside", {
|
|
78
|
+
id: "docs-mobile-sidebar",
|
|
79
|
+
inert: !open,
|
|
80
|
+
className: "docs-ground absolute inset-y-0 left-0 w-72 max-w-[85vw] -translate-x-full transition-[translate,box-shadow] duration-300 ease-[cubic-bezier(0.2,0,0,1)] in-data-open:translate-x-0 in-data-open:shadow-xl",
|
|
81
|
+
children: /* @__PURE__ */ jsx(Sidebar, {
|
|
82
|
+
tree,
|
|
83
|
+
onNavigate: close
|
|
84
|
+
})
|
|
85
|
+
})]
|
|
86
|
+
}),
|
|
87
|
+
/* @__PURE__ */ jsx("main", {
|
|
88
|
+
className: "flex min-h-0 min-w-0 flex-1 flex-col px-2 pb-2 lg:h-svh lg:py-2 lg:pr-2 lg:pl-0",
|
|
89
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
90
|
+
className: "docs-panel relative min-h-0 flex-1 rounded-xl",
|
|
91
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
92
|
+
"data-scroll-area": true,
|
|
93
|
+
className: "docs-scroll h-full overflow-y-auto overscroll-y-contain rounded-xl px-5 py-10 sm:px-8 lg:px-12 lg:py-14",
|
|
94
|
+
children
|
|
95
|
+
}, pathname)
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
]
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
export { DocsShell };
|