@wrksz/docs 0.0.0-stage → 0.1.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.
Files changed (156) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -2
  3. package/dist/agents.d.ts +30 -0
  4. package/dist/agents.js +70 -0
  5. package/dist/components/agent-logos.js +90 -0
  6. package/dist/components/agent-prompt.d.ts +29 -0
  7. package/dist/components/agent-prompt.js +100 -0
  8. package/dist/components/badge.d.ts +16 -0
  9. package/dist/components/badge.js +26 -0
  10. package/dist/components/brand.js +32 -0
  11. package/dist/components/callout.d.ts +24 -0
  12. package/dist/components/callout.js +58 -0
  13. package/dist/components/cards.d.ts +26 -0
  14. package/dist/components/cards.js +48 -0
  15. package/dist/components/code-body.js +18 -0
  16. package/dist/components/code-group.d.ts +20 -0
  17. package/dist/components/code-group.js +41 -0
  18. package/dist/components/code-tabs.d.ts +30 -0
  19. package/dist/components/code-tabs.js +49 -0
  20. package/dist/components/content-tabs.d.ts +14 -0
  21. package/dist/components/content-tabs.js +27 -0
  22. package/dist/components/copy-code.js +41 -0
  23. package/dist/components/deferred-analytics.js +5 -0
  24. package/dist/components/details.d.ts +20 -0
  25. package/dist/components/details.js +29 -0
  26. package/dist/components/heading-link.js +23 -0
  27. package/dist/components/heading.d.ts +5 -0
  28. package/dist/components/heading.js +22 -0
  29. package/dist/components/icons.js +362 -0
  30. package/dist/components/image.d.ts +27 -0
  31. package/dist/components/image.js +204 -0
  32. package/dist/components/inline-text.js +14 -0
  33. package/dist/components/install.d.ts +22 -0
  34. package/dist/components/install.js +62 -0
  35. package/dist/components/mdx-tabs.d.ts +22 -0
  36. package/dist/components/mdx-tabs.js +30 -0
  37. package/dist/components/practice.d.ts +41 -0
  38. package/dist/components/practice.js +99 -0
  39. package/dist/components/props.d.ts +37 -0
  40. package/dist/components/props.js +70 -0
  41. package/dist/components/status.js +35 -0
  42. package/dist/components/steps.d.ts +18 -0
  43. package/dist/components/steps.js +23 -0
  44. package/dist/components/theme-switch.js +31 -0
  45. package/dist/components/ui/kbd.js +410 -0
  46. package/dist/components/ui/scroll-area.js +169 -0
  47. package/dist/components/ui/table.d.ts +33 -0
  48. package/dist/components/ui/table.js +103 -0
  49. package/dist/components/ui/tabs.js +69 -0
  50. package/dist/components/ui/toast.js +629 -0
  51. package/dist/components/ui/tooltip.js +31 -0
  52. package/dist/components/wrksz-mark.js +12 -0
  53. package/dist/docs/index.d.ts +8 -0
  54. package/dist/docs/index.js +8 -0
  55. package/dist/docs/layout.d.ts +6 -0
  56. package/dist/docs/layout.js +10 -0
  57. package/dist/docs/page-actions.d.ts +36 -0
  58. package/dist/docs/page-actions.js +136 -0
  59. package/dist/docs/page-footer.d.ts +14 -0
  60. package/dist/docs/page-footer.js +68 -0
  61. package/dist/docs/page-header.d.ts +13 -0
  62. package/dist/docs/page-header.js +57 -0
  63. package/dist/docs/page.d.ts +16 -0
  64. package/dist/docs/page.js +38 -0
  65. package/dist/docs/reading.js +64 -0
  66. package/dist/docs/shell.js +101 -0
  67. package/dist/docs/sidebar.js +161 -0
  68. package/dist/docs/toc-bar.d.ts +12 -0
  69. package/dist/docs/toc-bar.js +132 -0
  70. package/dist/docs/toc.d.ts +11 -0
  71. package/dist/docs/toc.js +127 -0
  72. package/dist/fonts/Inter-Italic.woff2 +0 -0
  73. package/dist/fonts/Inter-LICENSE.txt +92 -0
  74. package/dist/fonts/Inter.woff2 +0 -0
  75. package/dist/fonts/IoskeleyMono-Bold.woff2 +0 -0
  76. package/dist/fonts/IoskeleyMono-Italic.woff2 +0 -0
  77. package/dist/fonts/IoskeleyMono-LICENSE.txt +92 -0
  78. package/dist/fonts/IoskeleyMono-Regular.woff2 +0 -0
  79. package/dist/fonts.d.ts +1 -0
  80. package/dist/fonts.js +38 -0
  81. package/dist/home/features.d.ts +39 -0
  82. package/dist/home/features.js +75 -0
  83. package/dist/home/footer.d.ts +4 -0
  84. package/dist/home/footer.js +79 -0
  85. package/dist/home/hero-content.js +102 -0
  86. package/dist/home/hero-install.js +128 -0
  87. package/dist/home/hero-stage.d.ts +4 -0
  88. package/dist/home/hero-stage.js +9 -0
  89. package/dist/home/hero.d.ts +6 -0
  90. package/dist/home/hero.js +16 -0
  91. package/dist/home/home-header.d.ts +1 -0
  92. package/dist/home/home-header.js +173 -0
  93. package/dist/home/index.d.ts +7 -0
  94. package/dist/home/index.js +7 -0
  95. package/dist/home/layout.d.ts +6 -0
  96. package/dist/home/layout.js +15 -0
  97. package/dist/home/reveal.js +31 -0
  98. package/dist/index.d.ts +4 -0
  99. package/dist/index.js +4 -0
  100. package/dist/lib/clipboard.js +55 -0
  101. package/dist/lib/cn.js +1 -0
  102. package/dist/lib/format.js +9 -0
  103. package/dist/lib/package-manager-script.js +12 -0
  104. package/dist/lib/package-manager.js +54 -0
  105. package/dist/lib/theme-config.js +10 -0
  106. package/dist/llms.d.ts +34 -0
  107. package/dist/llms.js +111 -0
  108. package/dist/next.d.ts +18 -0
  109. package/dist/next.js +45 -0
  110. package/dist/node_modules/.pnpm/@types_mdast@4.0.4/node_modules/@types/mdast/index.d.ts +930 -0
  111. package/dist/node_modules/.pnpm/@types_mdx@2.0.14/node_modules/@types/mdx/types.d.ts +81 -0
  112. package/dist/node_modules/.pnpm/@types_unist@3.0.3/node_modules/@types/unist/index.d.ts +80 -0
  113. package/dist/registry.d.ts +61 -0
  114. package/dist/registry.js +113 -0
  115. package/dist/root.d.ts +9 -0
  116. package/dist/root.js +34 -0
  117. package/dist/search.d.ts +5 -0
  118. package/dist/search.js +43 -0
  119. package/dist/seo/index.d.ts +6 -0
  120. package/dist/seo/index.js +6 -0
  121. package/dist/seo/json-ld.d.ts +17 -0
  122. package/dist/seo/json-ld.js +88 -0
  123. package/dist/seo/metadata.d.ts +21 -0
  124. package/dist/seo/metadata.js +75 -0
  125. package/dist/seo/robots.d.ts +14 -0
  126. package/dist/seo/robots.js +18 -0
  127. package/dist/seo/sitemap.d.ts +16 -0
  128. package/dist/seo/sitemap.js +26 -0
  129. package/dist/seo/url.d.ts +6 -0
  130. package/dist/seo/url.js +11 -0
  131. package/dist/server.js +63 -0
  132. package/dist/site-context.js +17 -0
  133. package/dist/site.d.ts +41 -0
  134. package/dist/site.js +13 -0
  135. package/dist/source/compile.d.ts +6 -0
  136. package/dist/source/compile.js +32 -0
  137. package/dist/source/errors.d.ts +4 -0
  138. package/dist/source/errors.js +10 -0
  139. package/dist/source/frontmatter.d.ts +13 -0
  140. package/dist/source/frontmatter.js +102 -0
  141. package/dist/source/highlight.js +102 -0
  142. package/dist/source/index.d.ts +36 -0
  143. package/dist/source/index.js +102 -0
  144. package/dist/source/markdown.d.ts +48 -0
  145. package/dist/source/markdown.js +393 -0
  146. package/dist/source/prompt.js +33 -0
  147. package/dist/source/scan.d.ts +8 -0
  148. package/dist/source/scan.js +64 -0
  149. package/dist/source/toc.d.ts +5 -0
  150. package/dist/source/toc.js +28 -0
  151. package/dist/source/tree.d.ts +29 -0
  152. package/dist/source/tree.js +91 -0
  153. package/dist/styles.css +879 -0
  154. package/dist/typography.d.ts +101 -0
  155. package/dist/typography.js +232 -0
  156. package/package.json +84 -4
@@ -0,0 +1,81 @@
1
+ // Internal helper types
2
+ /**
3
+ * This is the global JSX.ElementType if it’s defined, otherwise never.
4
+ */
5
+ // @ts-ignore JSX runtimes may optionally define JSX.ElementType. The MDX types need to work regardless whether this is
6
+ // defined or not.
7
+ type ElementType = any extends JSX.ElementType ? never : JSX.ElementType;
8
+ /**
9
+ * This matches any function component types that ar part of `ElementType`.
10
+ */
11
+ type FunctionElementType = Extract<ElementType, (props: Record<string, any>) => any>;
12
+ /**
13
+ * This matches any class component types that ar part of `ElementType`.
14
+ */
15
+ type ClassElementType = Extract<ElementType, new (props: Record<string, any>) => any>;
16
+ /**
17
+ * A valid JSX string component.
18
+ */
19
+ type StringComponent = Extract<keyof JSX.IntrinsicElements, ElementType extends never ? string : ElementType>;
20
+ /**
21
+ * A JSX element returned by MDX content.
22
+ */
23
+ export type Element = JSX.Element;
24
+ /**
25
+ * A valid JSX function component.
26
+ */
27
+ type FunctionComponent<Props> = ElementType extends never ?
28
+ // If JSX.ElementType isn’t defined, the valid return type is JSX.Element
29
+ (props: Props) => Element | null : FunctionElementType extends never ?
30
+ // If JSX.ElementType is defined, but doesn’t allow function components, function components are disallowed.
31
+ never :
32
+ // If JSX.ElementType allows function components, its return value determines what is a valid.
33
+ (props: Props) => ReturnType<FunctionElementType>;
34
+ /**
35
+ * A valid JSX class component.
36
+ */
37
+ type ClassComponent<Props> = ElementType extends never ?
38
+ // If JSX.ElementType isn’t defined, the valid return type is a constructor that returns JSX.ElementClass
39
+ new (props: Props) => JSX.ElementClass : ClassElementType extends never ?
40
+ // If JSX.ElementType is defined, but doesn’t allow constructors, function components are disallowed.
41
+ never :
42
+ // If JSX.ElementType allows class components, its return value determines what is a valid.
43
+ new (props: Props) => InstanceType<ClassElementType>;
44
+ /**
45
+ * Any allowed JSX component.
46
+ */
47
+ type Component<Props> = FunctionComponent<Props> | ClassComponent<Props> | StringComponent;
48
+ interface NestedMDXComponents {
49
+ [key: string]: NestedMDXComponents | Component<any>;
50
+ }
51
+ // Public MDX helper types
52
+ /**
53
+ * MDX components may be passed as the `components`.
54
+ *
55
+ * The key is the name of the element to override. The value is the component to render instead.
56
+ */
57
+ export type MDXComponents = NestedMDXComponents & { [Key in StringComponent]?: Component<JSX.IntrinsicElements[Key]>; } & {
58
+ /**
59
+ * If a wrapper component is defined, the MDX content will be wrapped inside of it.
60
+ */
61
+ wrapper?: Component<any>;
62
+ };
63
+ /**
64
+ * The props that may be passed to an MDX component.
65
+ */
66
+ export interface MDXProps {
67
+ /**
68
+ * Which props exactly may be passed into the component depends on the contents of the MDX
69
+ * file.
70
+ */
71
+ [key: string]: unknown;
72
+ /**
73
+ * This prop may be used to customize how certain components are rendered.
74
+ */
75
+ components?: MDXComponents;
76
+ }
77
+ /**
78
+ * The type of the default export of an MDX module.
79
+ */
80
+ export type MDXContent = (props: MDXProps) => Element;
81
+ export {};
@@ -0,0 +1,80 @@
1
+ // ## Interfaces
2
+ /**
3
+ * Info associated with nodes by the ecosystem.
4
+ *
5
+ * This space is guaranteed to never be specified by unist or specifications
6
+ * implementing unist.
7
+ * But you can use it in utilities and plugins to store data.
8
+ *
9
+ * This type can be augmented to register custom data.
10
+ * For example:
11
+ *
12
+ * ```ts
13
+ * declare module 'unist' {
14
+ * interface Data {
15
+ * // `someNode.data.myId` is typed as `number | undefined`
16
+ * myId?: number | undefined
17
+ * }
18
+ * }
19
+ * ```
20
+ */
21
+ export interface Data {}
22
+ /**
23
+ * One place in a source file.
24
+ */
25
+ export interface Point {
26
+ /**
27
+ * Line in a source file (1-indexed integer).
28
+ */
29
+ line: number;
30
+ /**
31
+ * Column in a source file (1-indexed integer).
32
+ */
33
+ column: number;
34
+ /**
35
+ * Character in a source file (0-indexed integer).
36
+ */
37
+ offset?: number | undefined;
38
+ }
39
+ /**
40
+ * Position of a node in a source document.
41
+ *
42
+ * A position is a range between two points.
43
+ */
44
+ export interface Position {
45
+ /**
46
+ * Place of the first character of the parsed source region.
47
+ */
48
+ start: Point;
49
+ /**
50
+ * Place of the first character after the parsed source region.
51
+ */
52
+ end: Point;
53
+ }
54
+ /**
55
+ * Abstract unist node.
56
+ *
57
+ * The syntactic unit in unist syntax trees are called nodes.
58
+ *
59
+ * This interface is supposed to be extended.
60
+ * If you can use {@link Literal} or {@link Parent}, you should.
61
+ * But for example in markdown, a `thematicBreak` (`***`), is neither literal
62
+ * nor parent, but still a node.
63
+ */
64
+ export interface Node {
65
+ /**
66
+ * Node type.
67
+ */
68
+ type: string;
69
+ /**
70
+ * Info from the ecosystem.
71
+ */
72
+ data?: Data | undefined;
73
+ /**
74
+ * Position of a node in a source document.
75
+ *
76
+ * Nodes that are generated (not in the original source document) must not
77
+ * have a position.
78
+ */
79
+ position?: Position | undefined;
80
+ }
@@ -0,0 +1,61 @@
1
+ /**
2
+ * A package manager in a registry. Commands are templates: `{name}` becomes the package
3
+ * name, so a registry stays plain data that can travel from server to client.
4
+ */
5
+ export type PackageManager = {
6
+ /** Name shown in the picker, e.g. `pnpm`. */
7
+ name: string;
8
+ /** Command that adds the package, e.g. `pnpm add {name}`. */
9
+ install: string;
10
+ /** Command that adds it as a development dependency. Falls back to `install`. */
11
+ dev?: string;
12
+ };
13
+ /**
14
+ * Where a package lives and how to install it. Built in: `npm` and `pypi`; anything else is
15
+ * a `defineRegistry` call away.
16
+ */
17
+ export type Registry = {
18
+ /** Stable id; it also keys the reader's saved choice of package manager. */
19
+ id: string;
20
+ /** Name of the registry, e.g. `npm` or `PyPI`. */
21
+ label: string;
22
+ /** Package page, e.g. `https://www.npmjs.com/package/{name}`. */
23
+ url: string;
24
+ /** Package managers in the order the picker lists them. */
25
+ managers: readonly PackageManager[];
26
+ /** Name of the manager used until the reader picks one. Defaults to the first. */
27
+ fallback?: string;
28
+ /** Brand mark from the built-in set, shown next to the registry link. */
29
+ icon?: "npm" | "pypi";
30
+ /**
31
+ * Weekly downloads for the home page: a JSON endpoint and the dotted path to the
32
+ * number in its response, e.g. `{ url: "…/{name}", path: "data.last_week" }`.
33
+ */
34
+ downloads?: {
35
+ url: string;
36
+ path: string;
37
+ };
38
+ /**
39
+ * The latest published version, shown next to the site's name: a JSON endpoint and the
40
+ * dotted path to the version string, e.g. `{ url: "…/{name}/latest", path: "version" }`.
41
+ */
42
+ latest?: {
43
+ url: string;
44
+ path: string;
45
+ };
46
+ };
47
+ export type Package = {
48
+ name: string;
49
+ registry: Registry;
50
+ };
51
+ export declare function defineRegistry(registry: Registry): Registry;
52
+ export declare const npm: Registry;
53
+ export declare const pypi: Registry;
54
+ /** The command each manager runs to add `name`, as a development dependency with `dev`. */
55
+ export declare function installCommands(registry: Registry, name: string, { dev }?: {
56
+ dev?: boolean;
57
+ }): {
58
+ manager: string;
59
+ command: string;
60
+ }[];
61
+ export declare function registryUrl(pkg: Package): string;
@@ -0,0 +1,113 @@
1
+ // src/registry.ts
2
+ function defineRegistry(registry) {
3
+ return registry;
4
+ }
5
+ const npm = defineRegistry({
6
+ id: "npm",
7
+ label: "npm",
8
+ url: "https://www.npmjs.com/package/{name}",
9
+ icon: "npm",
10
+ fallback: "pnpm",
11
+ managers: [
12
+ {
13
+ name: "bun",
14
+ install: "bun add {name}",
15
+ dev: "bun add -d {name}"
16
+ },
17
+ {
18
+ name: "npm",
19
+ install: "npm install {name}",
20
+ dev: "npm install -D {name}"
21
+ },
22
+ {
23
+ name: "pnpm",
24
+ install: "pnpm add {name}",
25
+ dev: "pnpm add -D {name}"
26
+ },
27
+ {
28
+ name: "yarn",
29
+ install: "yarn add {name}",
30
+ dev: "yarn add -D {name}"
31
+ }
32
+ ],
33
+ downloads: {
34
+ url: "https://api.npmjs.org/downloads/point/last-week/{name}",
35
+ path: "downloads"
36
+ },
37
+ latest: {
38
+ url: "https://registry.npmjs.org/{name}/latest",
39
+ path: "version"
40
+ }
41
+ });
42
+ const pypi = defineRegistry({
43
+ id: "pypi",
44
+ label: "PyPI",
45
+ url: "https://pypi.org/project/{name}/",
46
+ icon: "pypi",
47
+ fallback: "uv",
48
+ managers: [
49
+ {
50
+ name: "uv",
51
+ install: "uv add {name}",
52
+ dev: "uv add --dev {name}"
53
+ },
54
+ {
55
+ name: "pip",
56
+ install: "pip install {name}"
57
+ },
58
+ {
59
+ name: "poetry",
60
+ install: "poetry add {name}",
61
+ dev: "poetry add --group dev {name}"
62
+ },
63
+ {
64
+ name: "pdm",
65
+ install: "pdm add {name}",
66
+ dev: "pdm add -dG dev {name}"
67
+ }
68
+ ],
69
+ downloads: {
70
+ url: "https://pypistats.org/api/packages/{name}/recent",
71
+ path: "data.last_week"
72
+ },
73
+ latest: {
74
+ url: "https://pypi.org/pypi/{name}/json",
75
+ path: "info.version"
76
+ }
77
+ });
78
+ /** Registries `<Install registry="…">` can name in MDX, besides the site's own. */
79
+ const BUILT_IN_REGISTRIES = {
80
+ npm,
81
+ pypi
82
+ };
83
+ /** Resolves a registry id against the site's registry and the built-in ones. */
84
+ function findRegistry(id, site) {
85
+ return site.id === id ? site : BUILT_IN_REGISTRIES[id];
86
+ }
87
+ function fill(template, name) {
88
+ return template.replaceAll("{name}", name);
89
+ }
90
+ /** The command each manager runs to add `name`, as a development dependency with `dev`. */
91
+ function installCommands(registry, name, { dev = false } = {}) {
92
+ return registry.managers.map((manager) => ({
93
+ manager: manager.name,
94
+ command: fill(dev ? manager.dev ?? manager.install : manager.install, name)
95
+ }));
96
+ }
97
+ function defaultManager(registry) {
98
+ return registry.fallback ?? registry.managers[0]?.name ?? "";
99
+ }
100
+ function registryUrl(pkg) {
101
+ return fill(pkg.registry.url, pkg.name);
102
+ }
103
+ function downloadsUrl(pkg) {
104
+ return pkg.registry.downloads ? fill(pkg.registry.downloads.url, pkg.name) : void 0;
105
+ }
106
+ function latestUrl(pkg) {
107
+ return pkg.registry.latest ? fill(pkg.registry.latest.url, pkg.name) : void 0;
108
+ }
109
+ /** Reads a dotted path such as `data.last_week` out of a JSON response. */
110
+ function pick(data, path) {
111
+ return path.split(".").reduce((node, key) => node && typeof node === "object" ? node[key] : void 0, data);
112
+ }
113
+ export { BUILT_IN_REGISTRIES, defaultManager, defineRegistry, downloadsUrl, findRegistry, installCommands, latestUrl, npm, pick, pypi, registryUrl };
package/dist/root.d.ts ADDED
@@ -0,0 +1,9 @@
1
+ import { ReactNode } from "react";
2
+ import "@wrksz/cue/styles.css";
3
+ import { SearchPage } from "./search.js";
4
+ import { Site } from "./site.js";
5
+ export declare function DocsRoot({ site, pages, children }: {
6
+ site: Site;
7
+ pages?: SearchPage[];
8
+ children: ReactNode;
9
+ }): Promise<import("react").JSX.Element>;
package/dist/root.js ADDED
@@ -0,0 +1,34 @@
1
+ import { ThemeProvider } from "@wrksz/themes/next";
2
+ import "@wrksz/cue/styles.css";
3
+ import { Analytics } from "./components/deferred-analytics.js";
4
+ import { Toaster } from "./components/ui/toast.js";
5
+ import { packageManagerScript } from "./lib/package-manager-script.js";
6
+ import { appThemes, themeProviderDefaults } from "./lib/theme-config.js";
7
+ import { SearchProvider } from "./search.js";
8
+ import { getVersion } from "./server.js";
9
+ import { SiteProvider } from "./site-context.js";
10
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
+ // src/root.tsx
12
+ async function DocsRoot({ site, pages = [], children }) {
13
+ const version = await getVersion(site);
14
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
15
+ /* @__PURE__ */ jsx("script", { dangerouslySetInnerHTML: { __html: packageManagerScript } }),
16
+ /* @__PURE__ */ jsx(ThemeProvider, {
17
+ ...themeProviderDefaults,
18
+ themes: appThemes,
19
+ children: /* @__PURE__ */ jsx(SiteProvider, {
20
+ site: {
21
+ ...site,
22
+ version: version ?? false
23
+ },
24
+ children: /* @__PURE__ */ jsx(SearchProvider, {
25
+ pages,
26
+ children
27
+ })
28
+ })
29
+ }),
30
+ /* @__PURE__ */ jsx(Toaster, {}),
31
+ /* @__PURE__ */ jsx(Analytics, {})
32
+ ] });
33
+ }
34
+ export { DocsRoot };
@@ -0,0 +1,5 @@
1
+ import "react";
2
+ export type SearchPage = {
3
+ url: string;
4
+ title: string;
5
+ };
package/dist/search.js ADDED
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { Cue } from "@wrksz/cue";
3
+ import { useRouter } from "next/navigation";
4
+ import { createContext, use, useMemo, useState } from "react";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/search.tsx
7
+ const SearchContext = createContext(null);
8
+ function useSearch() {
9
+ const state = use(SearchContext);
10
+ if (!state) throw new Error("useSearch needs <DocsRoot> above it.");
11
+ return state;
12
+ }
13
+ function SearchProvider({ pages, children }) {
14
+ const router = useRouter();
15
+ const [open, setOpen] = useState(false);
16
+ const state = useMemo(() => ({
17
+ open,
18
+ setOpen
19
+ }), [open]);
20
+ return /* @__PURE__ */ jsxs(SearchContext, {
21
+ value: state,
22
+ children: [children, /* @__PURE__ */ jsxs(Cue.Dialog, {
23
+ open,
24
+ onOpenChange: setOpen,
25
+ label: "Search the docs",
26
+ mobileSheet: true,
27
+ children: [/* @__PURE__ */ jsx(Cue.Input, { placeholder: "Search the docs" }), /* @__PURE__ */ jsxs(Cue.List, {
28
+ label: "Pages",
29
+ children: [/* @__PURE__ */ jsx(Cue.Group, {
30
+ id: "pages",
31
+ heading: "Pages",
32
+ children: pages.map((page) => /* @__PURE__ */ jsx(Cue.Item, {
33
+ id: page.url,
34
+ label: page.title,
35
+ onSelect: () => router.push(page.url),
36
+ children: /* @__PURE__ */ jsx(Cue.Highlight, {})
37
+ }, page.url))
38
+ }), /* @__PURE__ */ jsx(Cue.Empty, { children: "Nothing matches that." })]
39
+ })]
40
+ })]
41
+ });
42
+ }
43
+ export { SearchProvider, useSearch };
@@ -0,0 +1,6 @@
1
+ import { JsonLd, pageJsonLd, serializeJsonLd, siteJsonLd } from "./json-ld.js";
2
+ import { PageMetadataOptions, pageMetadata, siteMetadata } from "./metadata.js";
3
+ import { RobotsOptions, createRobots } from "./robots.js";
4
+ import { SitemapOptions, createSitemap } from "./sitemap.js";
5
+ import { absoluteUrl } from "./url.js";
6
+ export { type JsonLd, type PageMetadataOptions, type RobotsOptions, type SitemapOptions, absoluteUrl, createRobots, createSitemap, pageJsonLd, pageMetadata, serializeJsonLd, siteJsonLd, siteMetadata };
@@ -0,0 +1,6 @@
1
+ import { pageJsonLd, serializeJsonLd, siteJsonLd } from "./json-ld.js";
2
+ import { pageMetadata, siteMetadata } from "./metadata.js";
3
+ import { createRobots } from "./robots.js";
4
+ import { createSitemap } from "./sitemap.js";
5
+ import { absoluteUrl } from "./url.js";
6
+ export { absoluteUrl, createRobots, createSitemap, pageJsonLd, pageMetadata, serializeJsonLd, siteJsonLd, siteMetadata };
@@ -0,0 +1,17 @@
1
+ import { ContentPage } from "../source/scan.js";
2
+ import { Site } from "../site.js";
3
+ import { Source } from "../source/index.js";
4
+ export type JsonLd = Record<string, unknown>;
5
+ /**
6
+ * Builds Schema.org `WebSite` + `SoftwareSourceCode` JSON-LD for the home page.
7
+ */
8
+ export declare function siteJsonLd(site: Site): JsonLd;
9
+ /**
10
+ * Builds Schema.org `TechArticle` + `BreadcrumbList` JSON-LD for a docs page.
11
+ */
12
+ export declare function pageJsonLd(site: Site, source: Source, page: ContentPage): JsonLd;
13
+ /**
14
+ * Safely serializes a JSON-LD object for embedding inside a `<script type="application/ld+json">`
15
+ * tag by escaping `<` characters so closing script tags cannot break out.
16
+ */
17
+ export declare function serializeJsonLd(data: JsonLd): string;
@@ -0,0 +1,88 @@
1
+ import { githubUrl } from "../site.js";
2
+ import { absoluteUrl } from "./url.js";
3
+ // src/seo/json-ld.ts
4
+ /**
5
+ * Builds Schema.org `WebSite` + `SoftwareSourceCode` JSON-LD for the home page.
6
+ */
7
+ function siteJsonLd(site) {
8
+ const url = absoluteUrl(site, "/");
9
+ return {
10
+ "@context": "https://schema.org",
11
+ "@graph": [{
12
+ "@type": "WebSite",
13
+ name: site.package.name,
14
+ description: site.description,
15
+ url
16
+ }, {
17
+ "@type": "SoftwareSourceCode",
18
+ name: site.package.name,
19
+ description: site.description,
20
+ codeRepository: githubUrl(site),
21
+ url
22
+ }]
23
+ };
24
+ }
25
+ /**
26
+ * Builds Schema.org `TechArticle` + `BreadcrumbList` JSON-LD for a docs page.
27
+ */
28
+ function pageJsonLd(site, source, page) {
29
+ const homeUrl = absoluteUrl(site, "/");
30
+ const pageUrl = absoluteUrl(site, page.url);
31
+ const modified = source.updated(page);
32
+ const crumbs = [{
33
+ name: site.package.name,
34
+ item: homeUrl
35
+ }];
36
+ const baseUrl = page.slugs.length ? page.url.slice(0, page.url.length - page.slugs.join("/").length - 1) || "/" : page.url;
37
+ const indexPage = source.page([]);
38
+ if (page.slugs.length > 0) {
39
+ crumbs.push({
40
+ name: indexPage?.data.navTitle ?? indexPage?.data.title ?? "Docs",
41
+ item: absoluteUrl(site, baseUrl)
42
+ });
43
+ for (let i = 0; i < page.slugs.length; i++) {
44
+ const slice = page.slugs.slice(0, i + 1);
45
+ const match = source.page(slice);
46
+ const isLast = i === page.slugs.length - 1;
47
+ crumbs.push({
48
+ name: isLast ? page.data.title : match?.data.navTitle ?? match?.data.title ?? slice[i] ?? "",
49
+ item: absoluteUrl(site, match?.url ?? `${baseUrl}/${slice.join("/")}`)
50
+ });
51
+ }
52
+ } else crumbs.push({
53
+ name: page.data.title,
54
+ item: pageUrl
55
+ });
56
+ return {
57
+ "@context": "https://schema.org",
58
+ "@graph": [{
59
+ "@type": "TechArticle",
60
+ headline: page.data.title,
61
+ description: page.data.description ?? site.description,
62
+ url: pageUrl,
63
+ ...page.data.keywords?.length ? { keywords: page.data.keywords.join(", ") } : {},
64
+ ...modified ? { dateModified: modified.toISOString() } : {},
65
+ isPartOf: {
66
+ "@type": "WebSite",
67
+ name: site.package.name,
68
+ url: homeUrl
69
+ }
70
+ }, {
71
+ "@type": "BreadcrumbList",
72
+ itemListElement: crumbs.map((crumb, index) => ({
73
+ "@type": "ListItem",
74
+ position: index + 1,
75
+ name: crumb.name,
76
+ item: crumb.item
77
+ }))
78
+ }]
79
+ };
80
+ }
81
+ /**
82
+ * Safely serializes a JSON-LD object for embedding inside a `<script type="application/ld+json">`
83
+ * tag by escaping `<` characters so closing script tags cannot break out.
84
+ */
85
+ function serializeJsonLd(data) {
86
+ return JSON.stringify(data).replaceAll("<", "\\u003c");
87
+ }
88
+ export { pageJsonLd, serializeJsonLd, siteJsonLd };
@@ -0,0 +1,21 @@
1
+ import { ContentPage } from "../source/scan.js";
2
+ import { Metadata } from "next";
3
+ import { Site } from "../site.js";
4
+ import { Source } from "../source/index.js";
5
+ /** Options for `pageMetadata`. */
6
+ export type PageMetadataOptions = {
7
+ /** Optional resolver returning an absolute or root-relative Open Graph image URL for a page. */
8
+ ogImage?: (page: ContentPage) => string | undefined;
9
+ /** Additional metadata fields merged at the top level. */
10
+ overrides?: Metadata;
11
+ };
12
+ /**
13
+ * Builds root `Metadata` for `app/layout.tsx` from a `Site` definition.
14
+ */
15
+ export declare function siteMetadata(site: Site, overrides?: Metadata): Metadata;
16
+ /**
17
+ * Builds per-page `Metadata` for a documentation page, including canonical URL,
18
+ * Open Graph article timestamps, keywords, and automatic `noindex` for hidden
19
+ * or draft pages.
20
+ */
21
+ export declare function pageMetadata(site: Site, source: Source, page: ContentPage, options?: PageMetadataOptions): Metadata;
@@ -0,0 +1,75 @@
1
+ import { absoluteUrl } from "./url.js";
2
+ // src/seo/metadata.ts
3
+ /**
4
+ * Builds root `Metadata` for `app/layout.tsx` from a `Site` definition.
5
+ */
6
+ function siteMetadata(site, overrides) {
7
+ const name = site.package.name;
8
+ const url = absoluteUrl(site, "/");
9
+ return {
10
+ metadataBase: new URL(site.url),
11
+ title: {
12
+ default: name,
13
+ template: `%s | ${name}`
14
+ },
15
+ description: site.description,
16
+ alternates: { canonical: url },
17
+ openGraph: {
18
+ type: "website",
19
+ siteName: name,
20
+ title: name,
21
+ description: site.description,
22
+ url
23
+ },
24
+ twitter: {
25
+ card: "summary_large_image",
26
+ title: name,
27
+ description: site.description
28
+ },
29
+ ...overrides
30
+ };
31
+ }
32
+ /**
33
+ * Builds per-page `Metadata` for a documentation page, including canonical URL,
34
+ * Open Graph article timestamps, keywords, and automatic `noindex` for hidden
35
+ * or draft pages.
36
+ */
37
+ function pageMetadata(site, source, page, options) {
38
+ const title = page.data.title;
39
+ const description = page.data.description ?? site.description;
40
+ const url = absoluteUrl(site, page.url);
41
+ const modified = source.updated(page);
42
+ const imagePath = options?.ogImage?.(page);
43
+ const imageUrl = imagePath ? /^https?:\/\//.test(imagePath) ? imagePath : absoluteUrl(site, imagePath) : void 0;
44
+ const hidden = page.data.hidden === true || page.data.draft === true;
45
+ return {
46
+ title,
47
+ description,
48
+ ...page.data.keywords?.length ? { keywords: page.data.keywords } : {},
49
+ alternates: { canonical: url },
50
+ openGraph: {
51
+ type: "article",
52
+ siteName: site.package.name,
53
+ title,
54
+ description,
55
+ url,
56
+ ...modified ? { modifiedTime: modified.toISOString() } : {},
57
+ ...imageUrl ? { images: [{
58
+ url: imageUrl,
59
+ alt: title
60
+ }] } : {}
61
+ },
62
+ twitter: {
63
+ card: "summary_large_image",
64
+ title,
65
+ description,
66
+ ...imageUrl ? { images: [imageUrl] } : {}
67
+ },
68
+ ...hidden ? { robots: {
69
+ index: false,
70
+ follow: false
71
+ } } : {},
72
+ ...options?.overrides
73
+ };
74
+ }
75
+ export { pageMetadata, siteMetadata };
@@ -0,0 +1,14 @@
1
+ import { MetadataRoute } from "next";
2
+ import { Site } from "../site.js";
3
+ /** Options for `createRobots`. */
4
+ export type RobotsOptions = {
5
+ /** Paths disallowed from crawling. */
6
+ disallow?: string | string[];
7
+ /** Override sitemap path. Defaults to `"/sitemap.xml"`. */
8
+ sitemapPath?: string;
9
+ };
10
+ /**
11
+ * Generates a Next.js `MetadataRoute.Robots` response pointing crawlers to the
12
+ * site's canonical host and sitemap.
13
+ */
14
+ export declare function createRobots(site: Site, options?: RobotsOptions): MetadataRoute.Robots;
@@ -0,0 +1,18 @@
1
+ import { absoluteUrl } from "./url.js";
2
+ // src/seo/robots.ts
3
+ /**
4
+ * Generates a Next.js `MetadataRoute.Robots` response pointing crawlers to the
5
+ * site's canonical host and sitemap.
6
+ */
7
+ function createRobots(site, options) {
8
+ return {
9
+ rules: {
10
+ userAgent: "*",
11
+ allow: "/",
12
+ ...options?.disallow ? { disallow: options.disallow } : {}
13
+ },
14
+ sitemap: absoluteUrl(site, options?.sitemapPath ?? "/sitemap.xml"),
15
+ host: new URL(site.url).origin
16
+ };
17
+ }
18
+ export { createRobots };