nimbus-docs 0.0.2
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 +25 -0
- package/dist/cli/index.d.ts +1 -0
- package/dist/cli/index.js +692 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client.d.ts +167 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +367 -0
- package/dist/client.js.map +1 -0
- package/dist/content.d.ts +126 -0
- package/dist/content.d.ts.map +1 -0
- package/dist/content.js +57 -0
- package/dist/content.js.map +1 -0
- package/dist/index.d.ts +255 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1478 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/pkgm.d.ts +41 -0
- package/dist/lib/pkgm.d.ts.map +1 -0
- package/dist/lib/pkgm.js +76 -0
- package/dist/lib/pkgm.js.map +1 -0
- package/dist/schemas.d.ts +164 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +110 -0
- package/dist/schemas.js.map +1 -0
- package/dist/types.d.ts +274 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/package.json +81 -0
- package/src/components/NimbusHead.astro +161 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../src/client/mount.ts","../src/client/ids.ts","../src/client/disclosure.ts","../src/client/dom.ts","../src/client/tabs-controller.ts","../src/client/scroll-lock.ts","../src/client/code-copy.ts","../src/client/heading-anchors.ts"],"sourcesContent":["/**\n * mount.ts — Discover, mount, and unmount component instances.\n *\n * The single entry point used by every `*.client.ts` to wire its component.\n * Handles three concerns:\n *\n * 1. Initial discovery — finds elements matching `selector` and calls `init`\n * on each, storing the returned teardown.\n * 2. View transitions — on `astro:before-swap`, runs every teardown so\n * document/window listeners come down before the DOM is replaced.\n * 3. Re-mount — on `astro:page-load`, re-runs discovery against the new DOM.\n *\n * The init function receives the root element and returns a `destroy()`\n * function. The root element is the keying mechanism — calling mount again\n * against an already-tracked element is a no-op.\n *\n * Usage:\n *\n * mount(\"[data-nb-collapsible]\", (root) => {\n * const disclosure = makeDisclosure({ ... });\n * return () => disclosure.destroy();\n * });\n */\n\ntype Init = (root: HTMLElement) => () => void;\n\nexport function mount(selector: string, init: Init): void {\n const instances = new Map<HTMLElement, () => void>();\n\n function setup() {\n document.querySelectorAll<HTMLElement>(selector).forEach((el) => {\n if (instances.has(el)) return;\n instances.set(el, init(el));\n });\n }\n\n function teardown() {\n instances.forEach((destroy) => destroy());\n instances.clear();\n }\n\n // Module scripts are deferred, so DOM is parsed by the time this runs.\n // Belt-and-braces check anyway.\n if (document.readyState === \"loading\") {\n document.addEventListener(\"DOMContentLoaded\", setup, { once: true });\n } else {\n setup();\n }\n\n document.addEventListener(\"astro:before-swap\", teardown);\n document.addEventListener(\"astro:page-load\", setup);\n}\n","/**\n * Generate a unique ID with a prefix, scoped to the page.\n *\n * Used to build ARIA relationships (`aria-controls` / `aria-labelledby`)\n * between elements that don't have a stable author-provided id.\n */\n\nlet counter = 0;\n\nexport function generateId(prefix: string): string {\n counter += 1;\n return `${prefix}-${counter}`;\n}\n","/**\n * disclosure.ts — Open/close state with ARIA wiring.\n *\n * The shared module for any \"click trigger, reveals content\" pattern.\n * Owns:\n * - open/closed state (in-memory + reflected as `data-nb-state` on both\n * trigger and content)\n * - ARIA: `aria-expanded` on trigger, `aria-controls` linking to content\n * - Click handler on the trigger\n *\n * Animation is intentionally out of scope — CSS targets the `data-nb-state`\n * attribute and runs whatever transition the component wants. Returning\n * a teardown means the caller can clean up on unmount.\n *\n * Used by: Collapsible, and any future Accordion / Sidebar group /\n * dismissable Banner that wants the standard disclosure semantics.\n */\n\nimport { generateId } from \"./ids\";\n\nexport interface DisclosureOptions {\n /** The element users click to toggle. Usually a `<button>`. */\n trigger: HTMLElement;\n /** The element that's shown/hidden. Gets `id` + `data-nb-state`. */\n content: HTMLElement;\n /** Initial open state. Default `false`. */\n defaultOpen?: boolean;\n /** Called whenever open changes. */\n onOpenChange?: (open: boolean) => void;\n}\n\nexport interface DisclosureInstance {\n open(): void;\n close(): void;\n toggle(): void;\n isOpen(): boolean;\n destroy(): void;\n}\n\nexport function makeDisclosure(opts: DisclosureOptions): DisclosureInstance {\n const { trigger, content, defaultOpen = false, onOpenChange } = opts;\n\n let open = defaultOpen;\n\n // Ensure ARIA relationship exists.\n if (!content.id) {\n content.id = generateId(\"nb-disclosure\");\n }\n trigger.setAttribute(\"aria-controls\", content.id);\n\n function syncState() {\n const state = open ? \"open\" : \"closed\";\n trigger.setAttribute(\"data-nb-state\", state);\n content.setAttribute(\"data-nb-state\", state);\n trigger.setAttribute(\"aria-expanded\", String(open));\n }\n\n function setOpen(value: boolean) {\n if (open === value) return;\n open = value;\n syncState();\n onOpenChange?.(value);\n }\n\n function handleClick(e: MouseEvent) {\n e.preventDefault();\n setOpen(!open);\n }\n\n syncState();\n trigger.addEventListener(\"click\", handleClick);\n\n return {\n open() {\n setOpen(true);\n },\n close() {\n setOpen(false);\n },\n toggle() {\n setOpen(!open);\n },\n isOpen() {\n return open;\n },\n destroy() {\n trigger.removeEventListener(\"click\", handleClick);\n },\n };\n}\n","/**\n * Shared DOM constants for client-side interaction primitives.\n */\n\n/** CSS selector for focusable elements within a container. */\nexport const FOCUSABLE =\n 'a[href], button:not([disabled]), input:not([disabled]):not([type=\"hidden\"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([disabled]):not([tabindex=\"-1\"])';\n","/**\n * Shared tab activation primitive.\n *\n * Handles aria-selected, panel visibility, roving tabindex,\n * keyboard navigation, sliding indicator, and cross-instance sync.\n *\n * Used by: Tabs.astro, PackageManagers.astro\n */\n\nimport { FOCUSABLE } from \"./dom\";\n\nexport interface TabsConfig {\n /** Root container holding tabs + panels */\n container: Element;\n /** CSS selector for tab trigger buttons */\n tabSelector: string;\n /** CSS selector for tab panels */\n panelSelector: string;\n /** Optional sliding indicator element */\n indicator?: HTMLElement | null;\n /** Enable roving tabindex + arrow key navigation (default: true) */\n rovingTabindex?: boolean;\n /** Cross-instance persistence config */\n sync?: {\n key: string;\n storage?: \"local\" | \"session\";\n /** Extract sync label from a tab element. Default: textContent.trim() */\n getLabel?: (tab: HTMLElement) => string;\n };\n /** Called after a tab is activated */\n onActivate?: (index: number) => void;\n}\n\nexport interface TabsInstance {\n activate(index: number, options?: { emitSync?: boolean }): void;\n readonly currentIndex: number;\n destroy(): void;\n}\n\nexport function initTabs(config: TabsConfig): TabsInstance {\n const { container, tabSelector, panelSelector, indicator = null, rovingTabindex = true, sync, onActivate } = config;\n\n const tabs = Array.from(container.querySelectorAll<HTMLElement>(tabSelector));\n const panels = Array.from(container.querySelectorAll<HTMLElement>(panelSelector));\n const tablist = container.querySelector(\"[role=tablist]\") ?? container;\n\n let currentIndex = -1;\n let isInitialActivation = true;\n\n function getStorage(kind: \"local\" | \"session\"): Storage | null {\n try {\n return kind === \"session\" ? sessionStorage : localStorage;\n } catch {\n return null;\n }\n }\n\n function getLabel(tab: HTMLElement): string {\n return sync?.getLabel?.(tab) ?? tab.textContent?.trim() ?? \"\";\n }\n\n function updateIndicator(index: number) {\n if (!indicator || !tabs[index]) return;\n indicator.style.left = `${tabs[index].offsetLeft}px`;\n indicator.style.width = `${tabs[index].offsetWidth}px`;\n }\n\n function activate(index: number, options?: { emitSync?: boolean }) {\n const emitSync = options?.emitSync ?? true;\n if (index === currentIndex) return;\n\n // Capture scroll position before DOM changes to prevent layout jump\n const rect = container.getBoundingClientRect();\n const scrollBefore = rect.top;\n\n currentIndex = index;\n\n tabs.forEach((tab, i) => {\n const active = i === index;\n tab.setAttribute(\"aria-selected\", String(active));\n if (rovingTabindex) {\n tab.setAttribute(\"tabindex\", active ? \"0\" : \"-1\");\n }\n });\n\n panels.forEach((panel, i) => {\n const visible = i === index;\n panel.hidden = !visible;\n // Panels with no focusable children need tabindex=\"0\" so keyboard\n // users can Tab into the content (WAI-ARIA Tabs pattern).\n if (visible) {\n const hasFocusable = panel.querySelector(FOCUSABLE) !== null;\n if (!hasFocusable) {\n panel.setAttribute(\"tabindex\", \"0\");\n } else {\n panel.removeAttribute(\"tabindex\");\n }\n }\n });\n\n updateIndicator(index);\n onActivate?.(index);\n\n // Compensate scroll position after panel height change (skip on first paint)\n if (emitSync && !isInitialActivation) {\n const scrollAfter = container.getBoundingClientRect().top;\n const delta = scrollAfter - scrollBefore;\n if (Math.abs(delta) > 1) {\n window.scrollTo({\n top: window.scrollY + delta,\n behavior: \"instant\",\n });\n }\n }\n isInitialActivation = false;\n\n if (sync && emitSync) {\n const label = getLabel(tabs[index]);\n const store = getStorage(sync.storage === \"session\" ? \"session\" : \"local\");\n store?.setItem(sync.key, label);\n window.dispatchEvent(\n new CustomEvent(\"ui-tab-sync\", {\n detail: { key: sync.key, label, origin: container },\n }),\n );\n }\n }\n\n // Resolve initial index from sync storage\n let initialIndex = 0;\n if (sync) {\n const store = getStorage(sync.storage === \"session\" ? \"session\" : \"local\");\n const saved = store?.getItem(sync.key);\n if (saved) {\n const idx = tabs.findIndex((t) => getLabel(t) === saved);\n if (idx >= 0) initialIndex = idx;\n }\n }\n\n // Click delegation on tablist\n function handleClick(e: Event) {\n const target = (e.target as HTMLElement).closest(tabSelector);\n if (!target) return;\n const idx = tabs.indexOf(target as HTMLElement);\n if (idx >= 0) {\n activate(idx);\n if (rovingTabindex) (target as HTMLElement).focus();\n }\n }\n\n // Keyboard navigation (roving tabindex)\n function handleKeydown(e: KeyboardEvent) {\n if (!rovingTabindex) return;\n const ci = tabs.indexOf(e.target as HTMLElement);\n if (ci < 0) return;\n\n let next: number;\n switch (e.key) {\n case \"ArrowRight\":\n next = ci + 1;\n break;\n case \"ArrowLeft\":\n next = ci - 1;\n break;\n case \"Home\":\n next = 0;\n break;\n case \"End\":\n next = tabs.length - 1;\n break;\n default:\n return;\n }\n // No-wrap: ignore if out of bounds\n if (!tabs[next]) return;\n e.preventDefault();\n activate(next);\n tabs[next].focus();\n }\n\n // Cross-instance sync via CustomEvent\n function handleSync(e: Event) {\n const detail = (e as CustomEvent).detail;\n if (detail.key === sync?.key && detail.origin !== container) {\n const idx = tabs.findIndex((t) => getLabel(t) === detail.label);\n if (idx >= 0) activate(idx, { emitSync: false });\n }\n }\n\n // Wire events\n tablist.addEventListener(\"click\", handleClick);\n tablist.addEventListener(\"keydown\", handleKeydown as EventListener);\n if (sync) window.addEventListener(\"ui-tab-sync\", handleSync);\n\n // Initial activation — skip indicator transition for first paint\n if (indicator) indicator.style.transition = \"none\";\n activate(initialIndex);\n if (indicator) {\n void indicator.offsetHeight; // force reflow\n indicator.style.transition = \"\";\n }\n\n return {\n activate,\n get currentIndex() {\n return currentIndex;\n },\n destroy() {\n tablist.removeEventListener(\"click\", handleClick);\n tablist.removeEventListener(\"keydown\", handleKeydown as EventListener);\n if (sync) window.removeEventListener(\"ui-tab-sync\", handleSync);\n },\n };\n}\n","/**\n * scroll-lock.ts — Body scroll lock with scrollbar-width compensation.\n *\n * Prevents background scrolling when a modal/overlay is open.\n * Compensates for the scrollbar disappearing to avoid layout shift\n * (visible on Windows/Linux where scrollbars have width).\n *\n * Uses a data attribute + CSS for the overflow lock, and inline\n * paddingRight for the scrollbar compensation.\n *\n * Used by: Dialog (and any future overlay primitive).\n */\n\nconst ATTR = \"data-scroll-locked\";\n\nlet lockCount = 0;\nlet savedPaddingRight = \"\";\n\nexport function lockScroll(): void {\n lockCount++;\n if (lockCount > 1) return;\n\n const scrollbarW = window.innerWidth - document.documentElement.clientWidth;\n savedPaddingRight = document.body.style.paddingRight;\n\n document.body.setAttribute(ATTR, \"\");\n if (scrollbarW > 0) {\n document.body.style.paddingRight = `${scrollbarW}px`;\n }\n}\n\nexport function unlockScroll(): void {\n if (lockCount === 0) return;\n lockCount--;\n if (lockCount > 0) return;\n\n document.body.removeAttribute(ATTR);\n document.body.style.paddingRight = savedPaddingRight;\n}\n","/**\n * code-copy.ts — Injects a Nimbus-styled copy button into every Shiki\n * code block rendered by Astro's built-in `<Code>` and fenced\n * code blocks in MDX.\n *\n * Astro emits `<pre class=\"astro-code shiki ...\">` for syntax-highlighted\n * blocks. We attach a copy button positioned in the top-right corner.\n *\n * Page-wide enhancement, not tied to a single component. Call `codeCopy()`\n * once (e.g. from BaseLayout). Uses `mount` for lifecycle so the buttons\n * are torn down on view transitions and re-added against the new DOM.\n *\n * The original code text comes from the `<code>` element's textContent —\n * Shiki's wrapper spans flatten down to the raw source.\n *\n * Code blocks rendered inside [data-cg-row] (CodeGroup) are skipped\n * because CodeGroup brings its own copy button per panel.\n */\n\nimport { mount } from \"./mount\";\n\nconst COPY_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z\"/></svg>`;\nconst CHECK_ICON = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 256 256\" fill=\"currentColor\" aria-hidden=\"true\"><path d=\"M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34Z\"/></svg>`;\n\nfunction getCodeText(pre: HTMLElement): string {\n const codeEl = pre.querySelector<HTMLElement>(\"code\");\n return codeEl?.textContent ?? pre.textContent ?? \"\";\n}\n\nfunction initCodeCopy(pre: HTMLElement): () => void {\n // Skip code blocks owned by CodeGroup — that component renders its own\n // copy button per panel.\n if (pre.closest(\"[data-cg-row]\")) return () => {};\n\n const btn = document.createElement(\"button\");\n btn.type = \"button\";\n btn.className = \"nb-code-copy\";\n btn.setAttribute(\"aria-label\", \"Copy code to clipboard\");\n btn.innerHTML = COPY_ICON;\n\n let resetTimer: number | undefined;\n\n async function handleClick() {\n const text = getCodeText(pre);\n if (!text) return;\n\n try {\n await navigator.clipboard.writeText(text);\n } catch {\n return;\n }\n\n btn.innerHTML = CHECK_ICON;\n btn.dataset.state = \"copied\";\n btn.setAttribute(\"aria-label\", \"Copied!\");\n\n if (resetTimer) window.clearTimeout(resetTimer);\n resetTimer = window.setTimeout(() => {\n btn.innerHTML = COPY_ICON;\n delete btn.dataset.state;\n btn.setAttribute(\"aria-label\", \"Copy code to clipboard\");\n }, 1500);\n }\n\n btn.addEventListener(\"click\", handleClick);\n\n // The button positions absolutely against the <pre>; make sure <pre> is\n // a positioning context.\n if (getComputedStyle(pre).position === \"static\") {\n pre.style.position = \"relative\";\n }\n pre.appendChild(btn);\n\n return () => {\n if (resetTimer) window.clearTimeout(resetTimer);\n btn.removeEventListener(\"click\", handleClick);\n btn.remove();\n };\n}\n\n/** Wire copy buttons onto all Shiki code blocks on the page. Call once. */\nexport function codeCopy(): void {\n mount(\"pre.astro-code\", initCodeCopy);\n}\n","/** Add hoverable self-links to markdown headings with ids. */\n\nfunction applyHeadingAnchors() {\n document.querySelectorAll<HTMLElement>(\".docs-content :is(h2, h3, h4)[id]\").forEach((heading) => {\n if (heading.hasAttribute(\"data-heading-anchor-ready\")) return;\n heading.setAttribute(\"data-heading-anchor-ready\", \"true\");\n\n const link = document.createElement(\"a\");\n link.href = `#${heading.id}`;\n link.className = \"heading-anchor\";\n link.setAttribute(\"aria-label\", `Link to ${heading.textContent?.trim() ?? \"section\"}`);\n link.textContent = \"#\";\n heading.appendChild(link);\n });\n}\n\n/**\n * Add hoverable `#` self-links to all `h2`–`h4` headings in `.docs-content`.\n * Re-runs on `astro:page-load` for View Transitions. Call once (e.g. from\n * BaseLayout).\n */\nexport function headingAnchors(): void {\n applyHeadingAnchors();\n document.addEventListener(\"astro:page-load\", applyHeadingAnchors);\n}\n"],"mappings":";AA0BA,SAAgB,MAAM,UAAkB,MAAkB;CACxD,MAAM,4BAAY,IA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AAa,cAAc,WAAW,QAAQ,aAAa,MAAM,IAAI,YAAY;AACtF,OAAK,cAAc;AACnB,UAAQ,YAAY,KAAK;GACzB;;;;;;;AAQJ,SAAgB,iBAAuB;AACrC,sBAAqB;AACrB,UAAS,iBAAiB,mBAAmB,oBAAoB"}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { z } from "astro/zod";
|
|
2
|
+
import * as astro_loaders0 from "astro/loaders";
|
|
3
|
+
|
|
4
|
+
//#region src/content.d.ts
|
|
5
|
+
interface DocsCollectionOptions {
|
|
6
|
+
/**
|
|
7
|
+
* Directory under `src/content/` to load docs from.
|
|
8
|
+
* Default: `"docs"`.
|
|
9
|
+
*/
|
|
10
|
+
base?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Glob pattern relative to `base`.
|
|
13
|
+
* Default: `"** /*.{md,mdx}"` (space added to avoid breaking this comment).
|
|
14
|
+
*/
|
|
15
|
+
pattern?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Extra fields merged into the default docs schema. Lets users add
|
|
18
|
+
* project-specific frontmatter (author, tags, etc.) without rebuilding
|
|
19
|
+
* the whole schema.
|
|
20
|
+
*/
|
|
21
|
+
schemaFields?: Record<string, z.ZodTypeAny>;
|
|
22
|
+
}
|
|
23
|
+
interface PartialsCollectionOptions {
|
|
24
|
+
/**
|
|
25
|
+
* Directory under `src/content/` to load partials from.
|
|
26
|
+
* Default: `"partials"`.
|
|
27
|
+
*/
|
|
28
|
+
base?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Glob pattern relative to `base`.
|
|
31
|
+
* Default: `"** /*.{md,mdx}"`.
|
|
32
|
+
*/
|
|
33
|
+
pattern?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Returns an Astro content-collection config (`{ loader, schema }`) for the
|
|
37
|
+
* docs collection. Pass to `defineCollection()`.
|
|
38
|
+
*/
|
|
39
|
+
declare function docsCollection(options?: DocsCollectionOptions): {
|
|
40
|
+
loader: astro_loaders0.Loader;
|
|
41
|
+
schema: z.ZodObject<{
|
|
42
|
+
title: z.ZodString;
|
|
43
|
+
description: z.ZodOptional<z.ZodString>;
|
|
44
|
+
template: z.ZodDefault<z.ZodEnum<{
|
|
45
|
+
doc: "doc";
|
|
46
|
+
splash: "splash";
|
|
47
|
+
}>>;
|
|
48
|
+
sidebar: z.ZodOptional<z.ZodObject<{
|
|
49
|
+
order: z.ZodOptional<z.ZodNumber>;
|
|
50
|
+
label: z.ZodOptional<z.ZodString>;
|
|
51
|
+
badge: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
52
|
+
text: z.ZodString;
|
|
53
|
+
variant: z.ZodDefault<z.ZodEnum<{
|
|
54
|
+
success: "success";
|
|
55
|
+
default: "default";
|
|
56
|
+
info: "info";
|
|
57
|
+
note: "note";
|
|
58
|
+
tip: "tip";
|
|
59
|
+
warning: "warning";
|
|
60
|
+
caution: "caution";
|
|
61
|
+
danger: "danger";
|
|
62
|
+
}>>;
|
|
63
|
+
}, z.core.$strip>]>>;
|
|
64
|
+
hidden: z.ZodOptional<z.ZodBoolean>;
|
|
65
|
+
hideChildren: z.ZodOptional<z.ZodBoolean>;
|
|
66
|
+
}, z.core.$strip>>;
|
|
67
|
+
hero: z.ZodOptional<z.ZodObject<{
|
|
68
|
+
title: z.ZodOptional<z.ZodString>;
|
|
69
|
+
tagline: z.ZodOptional<z.ZodString>;
|
|
70
|
+
actions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
71
|
+
text: z.ZodString;
|
|
72
|
+
link: z.ZodString;
|
|
73
|
+
variant: z.ZodDefault<z.ZodEnum<{
|
|
74
|
+
primary: "primary";
|
|
75
|
+
secondary: "secondary";
|
|
76
|
+
outline: "outline";
|
|
77
|
+
}>>;
|
|
78
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
79
|
+
}, z.core.$strip>>>;
|
|
80
|
+
}, z.core.$strip>>;
|
|
81
|
+
head: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
82
|
+
tag: z.ZodEnum<{
|
|
83
|
+
link: "link";
|
|
84
|
+
meta: "meta";
|
|
85
|
+
script: "script";
|
|
86
|
+
style: "style";
|
|
87
|
+
}>;
|
|
88
|
+
attrs: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
89
|
+
content: z.ZodOptional<z.ZodString>;
|
|
90
|
+
}, z.core.$strip>>>;
|
|
91
|
+
draft: z.ZodDefault<z.ZodBoolean>;
|
|
92
|
+
noindex: z.ZodDefault<z.ZodBoolean>;
|
|
93
|
+
llms: z.ZodDefault<z.ZodBoolean>;
|
|
94
|
+
aiDeprioritize: z.ZodDefault<z.ZodBoolean>;
|
|
95
|
+
pagefind: z.ZodDefault<z.ZodBoolean>;
|
|
96
|
+
tableOfContents: z.ZodOptional<z.ZodObject<{
|
|
97
|
+
minHeadingLevel: z.ZodDefault<z.ZodNumber>;
|
|
98
|
+
maxHeadingLevel: z.ZodDefault<z.ZodNumber>;
|
|
99
|
+
}, z.core.$strip>>;
|
|
100
|
+
lastUpdated: z.ZodOptional<z.ZodCoercedDate<unknown>>;
|
|
101
|
+
socialImage: z.ZodOptional<z.ZodString>;
|
|
102
|
+
prev: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
103
|
+
link: z.ZodOptional<z.ZodString>;
|
|
104
|
+
label: z.ZodOptional<z.ZodString>;
|
|
105
|
+
}, z.core.$strip>, z.ZodLiteral<false>]>>;
|
|
106
|
+
next: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
107
|
+
link: z.ZodOptional<z.ZodString>;
|
|
108
|
+
label: z.ZodOptional<z.ZodString>;
|
|
109
|
+
}, z.core.$strip>, z.ZodLiteral<false>]>>;
|
|
110
|
+
}, z.core.$strip> | z.ZodObject<{
|
|
111
|
+
[x: string]: z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
};
|
|
114
|
+
/**
|
|
115
|
+
* Returns an Astro content-collection config (`{ loader, schema }`) for the
|
|
116
|
+
* partials collection. Pass to `defineCollection()`.
|
|
117
|
+
*/
|
|
118
|
+
declare function partialsCollection(options?: PartialsCollectionOptions): {
|
|
119
|
+
loader: astro_loaders0.Loader;
|
|
120
|
+
schema: z.ZodDefault<z.ZodObject<{
|
|
121
|
+
params: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
};
|
|
124
|
+
//#endregion
|
|
125
|
+
export { DocsCollectionOptions, PartialsCollectionOptions, docsCollection, partialsCollection };
|
|
126
|
+
//# sourceMappingURL=content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.d.ts","names":[],"sources":["../src/content.ts"],"mappings":";;;;UAyBiB,qBAAA;EAsCD;;;;EAjCd,IAAA;;;;;EAKA,OAAA;;;;;;EAMA,YAAA,GAAe,MAAA,SAAe,CAAA,CAAE,UAAA;AAAA;AAAA,UAGjB,yBAAA;;;;;EAKf,IAAA;;;;;EAKA,OAAA;AAAA;;;;;iBASc,cAAA,CAAe,OAAA,GAAS,qBAAA;UAA0B,cAAA,CAAA,MAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAelD,kBAAA,CAAmB,OAAA,GAAS,yBAAA;UAA8B,cAAA,CAAA,MAAA"}
|
package/dist/content.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { defineDocSchema, partialsSchema } from "./schemas.js";
|
|
2
|
+
import { glob } from "astro/loaders";
|
|
3
|
+
|
|
4
|
+
//#region src/content.ts
|
|
5
|
+
/**
|
|
6
|
+
* Content collection helpers for `nimbus-docs/content`.
|
|
7
|
+
*
|
|
8
|
+
* Users plug these into their `src/content.config.ts`:
|
|
9
|
+
*
|
|
10
|
+
* import { defineCollection } from "astro:content";
|
|
11
|
+
* import { docsCollection, partialsCollection } from "nimbus-docs/content";
|
|
12
|
+
*
|
|
13
|
+
* export const collections = {
|
|
14
|
+
* docs: defineCollection(docsCollection()),
|
|
15
|
+
* partials: defineCollection(partialsCollection()),
|
|
16
|
+
* };
|
|
17
|
+
*
|
|
18
|
+
* Extend the docs schema with extra frontmatter fields:
|
|
19
|
+
*
|
|
20
|
+
* docs: defineCollection(docsCollection({
|
|
21
|
+
* schemaFields: { author: z.string(), tags: z.array(z.string()) },
|
|
22
|
+
* })),
|
|
23
|
+
*/
|
|
24
|
+
const DEFAULT_PATTERN = "**/*.{md,mdx}";
|
|
25
|
+
/**
|
|
26
|
+
* Returns an Astro content-collection config (`{ loader, schema }`) for the
|
|
27
|
+
* docs collection. Pass to `defineCollection()`.
|
|
28
|
+
*/
|
|
29
|
+
function docsCollection(options = {}) {
|
|
30
|
+
const base = `./src/content/${options.base ?? "docs"}`;
|
|
31
|
+
const pattern = options.pattern ?? DEFAULT_PATTERN;
|
|
32
|
+
const schema = defineDocSchema({ fields: options.schemaFields });
|
|
33
|
+
return {
|
|
34
|
+
loader: glob({
|
|
35
|
+
base,
|
|
36
|
+
pattern
|
|
37
|
+
}),
|
|
38
|
+
schema
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Returns an Astro content-collection config (`{ loader, schema }`) for the
|
|
43
|
+
* partials collection. Pass to `defineCollection()`.
|
|
44
|
+
*/
|
|
45
|
+
function partialsCollection(options = {}) {
|
|
46
|
+
return {
|
|
47
|
+
loader: glob({
|
|
48
|
+
base: `./src/content/${options.base ?? "partials"}`,
|
|
49
|
+
pattern: options.pattern ?? DEFAULT_PATTERN
|
|
50
|
+
}),
|
|
51
|
+
schema: partialsSchema
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
//#endregion
|
|
56
|
+
export { docsCollection, partialsCollection };
|
|
57
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","names":[],"sources":["../src/content.ts"],"sourcesContent":["/**\n * Content collection helpers for `nimbus-docs/content`.\n *\n * Users plug these into their `src/content.config.ts`:\n *\n * import { defineCollection } from \"astro:content\";\n * import { docsCollection, partialsCollection } from \"nimbus-docs/content\";\n *\n * export const collections = {\n * docs: defineCollection(docsCollection()),\n * partials: defineCollection(partialsCollection()),\n * };\n *\n * Extend the docs schema with extra frontmatter fields:\n *\n * docs: defineCollection(docsCollection({\n * schemaFields: { author: z.string(), tags: z.array(z.string()) },\n * })),\n */\n\nimport { glob } from \"astro/loaders\";\nimport type { z } from \"astro/zod\";\n\nimport { defineDocSchema, partialsSchema } from \"./schemas.js\";\n\nexport interface DocsCollectionOptions {\n /**\n * Directory under `src/content/` to load docs from.\n * Default: `\"docs\"`.\n */\n base?: string;\n /**\n * Glob pattern relative to `base`.\n * Default: `\"** /*.{md,mdx}\"` (space added to avoid breaking this comment).\n */\n pattern?: string;\n /**\n * Extra fields merged into the default docs schema. Lets users add\n * project-specific frontmatter (author, tags, etc.) without rebuilding\n * the whole schema.\n */\n schemaFields?: Record<string, z.ZodTypeAny>;\n}\n\nexport interface PartialsCollectionOptions {\n /**\n * Directory under `src/content/` to load partials from.\n * Default: `\"partials\"`.\n */\n base?: string;\n /**\n * Glob pattern relative to `base`.\n * Default: `\"** /*.{md,mdx}\"`.\n */\n pattern?: string;\n}\n\nconst DEFAULT_PATTERN = \"**/*.{md,mdx}\";\n\n/**\n * Returns an Astro content-collection config (`{ loader, schema }`) for the\n * docs collection. Pass to `defineCollection()`.\n */\nexport function docsCollection(options: DocsCollectionOptions = {}) {\n const base = `./src/content/${options.base ?? \"docs\"}`;\n const pattern = options.pattern ?? DEFAULT_PATTERN;\n const schema = defineDocSchema({ fields: options.schemaFields });\n\n return {\n loader: glob({ base, pattern }),\n schema,\n };\n}\n\n/**\n * Returns an Astro content-collection config (`{ loader, schema }`) for the\n * partials collection. Pass to `defineCollection()`.\n */\nexport function partialsCollection(options: PartialsCollectionOptions = {}) {\n const base = `./src/content/${options.base ?? \"partials\"}`;\n const pattern = options.pattern ?? DEFAULT_PATTERN;\n\n return {\n loader: glob({ base, pattern }),\n schema: partialsSchema,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAyDA,MAAM,kBAAkB;;;;;AAMxB,SAAgB,eAAe,UAAiC,EAAE,EAAE;CAClE,MAAM,OAAO,iBAAiB,QAAQ,QAAQ;CAC9C,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,SAAS,gBAAgB,EAAE,QAAQ,QAAQ,cAAc,CAAC;AAEhE,QAAO;EACL,QAAQ,KAAK;GAAE;GAAM;GAAS,CAAC;EAC/B;EACD;;;;;;AAOH,SAAgB,mBAAmB,UAAqC,EAAE,EAAE;AAI1E,QAAO;EACL,QAAQ,KAAK;GAAE,MAJJ,iBAAiB,QAAQ,QAAQ;GAIvB,SAHP,QAAQ,WAAW;GAGH,CAAC;EAC/B,QAAQ;EACT"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { BadgeVariant, Breadcrumb, NimbusConfig, PrevNext, PrevNextLink, PrevNextOverrides, SearchProvider, SearchResult, SidebarBadge, SidebarConfig, SidebarConfigItem, SidebarExternalLinkItem, SidebarGroupItem, SidebarItem, SidebarLinkItem, SidebarSection, TOCItem } from "./types.js";
|
|
2
|
+
import mdx from "@astrojs/mdx";
|
|
3
|
+
import * as astro_content0 from "astro:content";
|
|
4
|
+
import { CollectionEntry } from "astro:content";
|
|
5
|
+
import { AstroGlobal, AstroIntegration, GetStaticPaths } from "astro";
|
|
6
|
+
import { ShikiTransformer } from "shiki";
|
|
7
|
+
|
|
8
|
+
//#region src/_internal/content.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* Return visible entries from one or more collections. Drafts are
|
|
11
|
+
* filtered out in production builds (matching the existing
|
|
12
|
+
* single-collection behaviour).
|
|
13
|
+
*
|
|
14
|
+
* Defaults to `["docs"]` — the framework's primary collection.
|
|
15
|
+
* Cross-collection callers (llms.txt aggregators, custom indexes,
|
|
16
|
+
* etc.) pass an explicit list.
|
|
17
|
+
*
|
|
18
|
+
* Returns a flat `CollectionEntry<string>[]` so cross-collection
|
|
19
|
+
* traversal doesn't need to know the user's collection names at type
|
|
20
|
+
* time. Callers that need per-collection type safety should call
|
|
21
|
+
* `getCollection("api")` directly.
|
|
22
|
+
*/
|
|
23
|
+
declare function getVisibleEntries(collections?: string[]): Promise<CollectionEntry<string>[]>;
|
|
24
|
+
//#endregion
|
|
25
|
+
//#region src/_internal/sidebar.d.ts
|
|
26
|
+
/** Hash the sidebar structure into a short string for sessionStorage invalidation. */
|
|
27
|
+
declare function sidebarHash(items: SidebarItem[]): string;
|
|
28
|
+
//#endregion
|
|
29
|
+
//#region src/_internal/transform.d.ts
|
|
30
|
+
/**
|
|
31
|
+
* MDX → markdown transform for AI-readable static routes.
|
|
32
|
+
*
|
|
33
|
+
* This intentionally starts small and dependency-free: it operates on the
|
|
34
|
+
* raw MDX body that Astro's content layer exposes and maps the starter's
|
|
35
|
+
* default components to plain markdown equivalents. The route that calls this
|
|
36
|
+
* lives in user code, so replacing or bypassing this transformer is a one-line
|
|
37
|
+
* edit.
|
|
38
|
+
*/
|
|
39
|
+
interface MarkdownComponentRenderContext {
|
|
40
|
+
name: string;
|
|
41
|
+
attrs: Record<string, string | boolean>;
|
|
42
|
+
children: string;
|
|
43
|
+
}
|
|
44
|
+
type MarkdownComponentRenderer = (context: MarkdownComponentRenderContext) => string;
|
|
45
|
+
interface RenderEntryAsMarkdownOptions {
|
|
46
|
+
/**
|
|
47
|
+
* Override how specific MDX components are rendered. Keys are component
|
|
48
|
+
* names (e.g. `Aside`, `Tabs`, `PackageManagers`).
|
|
49
|
+
*/
|
|
50
|
+
componentMap?: Record<string, MarkdownComponentRenderer>;
|
|
51
|
+
/** Strip YAML frontmatter if the raw body includes it. Default: true. */
|
|
52
|
+
stripFrontmatter?: boolean;
|
|
53
|
+
}
|
|
54
|
+
interface MarkdownEntry {
|
|
55
|
+
body?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Render an Astro content entry's raw MDX body as plain markdown.
|
|
59
|
+
*
|
|
60
|
+
* This handles the starter's default MDX components. Users can pass a
|
|
61
|
+
* `componentMap` to override individual component renderers or replace this
|
|
62
|
+
* function entirely from their user-owned `.md` route.
|
|
63
|
+
*/
|
|
64
|
+
declare function renderEntryAsMarkdown(entry: MarkdownEntry, options?: RenderEntryAsMarkdownOptions): string;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/integration.d.ts
|
|
67
|
+
interface NimbusIntegrationOptions {
|
|
68
|
+
/** MDX options forwarded to `@astrojs/mdx`. */
|
|
69
|
+
mdx?: Parameters<typeof mdx>[0];
|
|
70
|
+
/** Skip sitemap integration. Default: enabled when `site.url` is set. */
|
|
71
|
+
sitemap?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Build-time MDX PascalCase tag validation.
|
|
74
|
+
*
|
|
75
|
+
* - `true` (default): parse `src/components.ts` for the globals
|
|
76
|
+
* registry and fail the build on unknown PascalCase tags found
|
|
77
|
+
* in `src/content/**\/*.mdx`.
|
|
78
|
+
* - `false`: skip validation entirely.
|
|
79
|
+
* - `{ componentsPath }`: override the registry file location.
|
|
80
|
+
* Relative paths resolve to the project root.
|
|
81
|
+
* - `{ contentDirs }`: override the scanned directories. Relative
|
|
82
|
+
* paths resolve to the project root. Default: `["src/content"]`.
|
|
83
|
+
* - `{ skip }`: filter out files (e.g. vendored or generated MDX).
|
|
84
|
+
*
|
|
85
|
+
* Runs as a pre-build content pass rather than as a remark plugin so
|
|
86
|
+
* it works regardless of which markdown processor is wired into
|
|
87
|
+
* `markdown.processor`. Sätteri (the default) replaces unified's
|
|
88
|
+
* pipeline, which silently disables remark plugins attached via
|
|
89
|
+
* `mdx({ remarkPlugins })`.
|
|
90
|
+
*/
|
|
91
|
+
validateMdx?: boolean | {
|
|
92
|
+
componentsPath?: string;
|
|
93
|
+
contentDirs?: string[];
|
|
94
|
+
skip?: (filePath: string) => boolean;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
declare function nimbus(rawConfig: NimbusConfig, options?: NimbusIntegrationOptions): AstroIntegration;
|
|
98
|
+
//#endregion
|
|
99
|
+
//#region src/_internal/code-transformers.d.ts
|
|
100
|
+
/**
|
|
101
|
+
* The canonical Shiki transformer chain for Nimbus. Returns a fresh
|
|
102
|
+
* array each call so callers don't accidentally mutate a shared list.
|
|
103
|
+
*
|
|
104
|
+
* Used by:
|
|
105
|
+
* - `integration.ts` → `shikiConfig.transformers` (fenced MDX blocks)
|
|
106
|
+
* - `Code.astro` in the starter → `transformers` prop on Astro's
|
|
107
|
+
* built-in `<Code>` component (and by extension, anything that
|
|
108
|
+
* composes `<Code>` such as `<CodeGroup>`)
|
|
109
|
+
*/
|
|
110
|
+
declare function defaultCodeTransformers(): ShikiTransformer[];
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region src/index.d.ts
|
|
113
|
+
/**
|
|
114
|
+
* Define a typed Nimbus config. Returns the config unchanged but inferred.
|
|
115
|
+
*/
|
|
116
|
+
declare function defineConfig<T extends NimbusConfig>(config: T): T;
|
|
117
|
+
/**
|
|
118
|
+
* Build the sidebar tree for the given current path, scoped to the
|
|
119
|
+
* top-level section containing that page.
|
|
120
|
+
*
|
|
121
|
+
* Reads `sidebar` from the user's nimbus.config. If `sidebar.items` is set,
|
|
122
|
+
* resolves config-driven sidebar. Otherwise auto-generates from filesystem
|
|
123
|
+
* (i.e. the `docs` collection's entry IDs).
|
|
124
|
+
*
|
|
125
|
+
* The returned tree is always scoped: only the current section's children
|
|
126
|
+
* are returned. To enumerate every top-level section (for header tabs or
|
|
127
|
+
* a section switcher), use `getSidebarSections`.
|
|
128
|
+
*
|
|
129
|
+
* @param currentSlug - The current page's URL path (e.g. "/getting-started").
|
|
130
|
+
* Used to set `isCurrent` on matching links and to pick
|
|
131
|
+
* which top-level section to surface.
|
|
132
|
+
*/
|
|
133
|
+
declare function getSidebar(currentSlug: string): Promise<SidebarItem[]>;
|
|
134
|
+
/**
|
|
135
|
+
* Derive one section per top-level group in the sidebar — used by
|
|
136
|
+
* `Header.astro` to render the section tab strip (and by any other
|
|
137
|
+
* cross-section navigation).
|
|
138
|
+
*
|
|
139
|
+
* Reads the un-scoped tree so every section is visible, then collapses
|
|
140
|
+
* each top-level group to `{ label, href, isActive }`.
|
|
141
|
+
*/
|
|
142
|
+
declare function getSidebarSections(currentSlug: string): Promise<SidebarSection[]>;
|
|
143
|
+
/**
|
|
144
|
+
* Resolve prev/next links for the current page.
|
|
145
|
+
*
|
|
146
|
+
* Walks the flattened sidebar; returns the surrounding entries. Honors
|
|
147
|
+
* `prev`/`next` frontmatter overrides if provided.
|
|
148
|
+
*/
|
|
149
|
+
declare function getPrevNext(currentSlug: string, options?: {
|
|
150
|
+
overrides?: PrevNextOverrides;
|
|
151
|
+
sidebarTree?: SidebarItem[];
|
|
152
|
+
}): Promise<PrevNext>;
|
|
153
|
+
/**
|
|
154
|
+
* Build breadcrumb trail from "/" to the current page.
|
|
155
|
+
*
|
|
156
|
+
* Phase 5: simple URL-segment derivation. Later phases may enrich with
|
|
157
|
+
* sidebar-aware labels.
|
|
158
|
+
*/
|
|
159
|
+
declare function getBreadcrumbs(currentSlug: string, options?: {
|
|
160
|
+
homeLabel?: string;
|
|
161
|
+
}): Promise<Breadcrumb[]>;
|
|
162
|
+
/**
|
|
163
|
+
* Build an edit URL for a content entry using `config.editPattern`.
|
|
164
|
+
*
|
|
165
|
+
* `{path}` is replaced with the entry's source path when Astro provides it,
|
|
166
|
+
* falling back to the default docs collection path convention.
|
|
167
|
+
*/
|
|
168
|
+
declare function getEditUrl(entry: {
|
|
169
|
+
id: string;
|
|
170
|
+
filePath?: string;
|
|
171
|
+
}): Promise<string | undefined>;
|
|
172
|
+
/**
|
|
173
|
+
* Resolve a content entry's `lastUpdated` date from `git log`.
|
|
174
|
+
*
|
|
175
|
+
* Reads the author date (`%aI`) of the most recent commit that touched
|
|
176
|
+
* the entry's source file. Author date is stable across rebases — the
|
|
177
|
+
* value reflects when the content was actually changed, not when the
|
|
178
|
+
* commit happened to land in this branch.
|
|
179
|
+
*
|
|
180
|
+
* Returns `undefined` when git can't answer (no `.git`, shallow clone,
|
|
181
|
+
* file untracked, command not on PATH, etc.) so the caller can chain a
|
|
182
|
+
* fallback:
|
|
183
|
+
*
|
|
184
|
+
* const lastUpdated = entry.data.lastUpdated ?? await getLastUpdated(entry);
|
|
185
|
+
*
|
|
186
|
+
* Frontmatter always wins. Per-process cached so repeated calls for
|
|
187
|
+
* the same entry don't re-spawn `git`.
|
|
188
|
+
*
|
|
189
|
+
* Production note: most CI/CD systems do shallow clones by default
|
|
190
|
+
* (Vercel, Cloudflare Pages, GitHub Actions checkout@v4) — set
|
|
191
|
+
* `fetch-depth: 0` to make full history available, otherwise git
|
|
192
|
+
* returns nothing and the helper falls back to frontmatter or nothing.
|
|
193
|
+
*/
|
|
194
|
+
declare function getLastUpdated(entry: {
|
|
195
|
+
id: string;
|
|
196
|
+
filePath?: string;
|
|
197
|
+
}): Promise<Date | undefined>;
|
|
198
|
+
/**
|
|
199
|
+
* Filter heading list to the configured min/max heading levels.
|
|
200
|
+
*
|
|
201
|
+
* @param headings - Raw `headings` from Astro's `render(entry)` return value.
|
|
202
|
+
* @param options - Override min/max heading levels. Defaults: min=2, max=3.
|
|
203
|
+
*/
|
|
204
|
+
declare function getTOC(headings: {
|
|
205
|
+
depth: number;
|
|
206
|
+
text: string;
|
|
207
|
+
slug: string;
|
|
208
|
+
}[], options?: {
|
|
209
|
+
minHeadingLevel?: number;
|
|
210
|
+
maxHeadingLevel?: number;
|
|
211
|
+
}): TOCItem[];
|
|
212
|
+
/**
|
|
213
|
+
* `getStaticPaths` implementation for a docs catch-all route.
|
|
214
|
+
*
|
|
215
|
+
* Returns one path per visible entry in the `docs` collection. Drafts are
|
|
216
|
+
* filtered in production. Each path passes `{ entry }` as props so the
|
|
217
|
+
* page component can access it via `getDocsPageProps(Astro)`.
|
|
218
|
+
*
|
|
219
|
+
* Usage:
|
|
220
|
+
*
|
|
221
|
+
* // src/pages/[...slug].astro
|
|
222
|
+
* export const prerender = true;
|
|
223
|
+
* export const getStaticPaths = getDocsStaticPaths;
|
|
224
|
+
*
|
|
225
|
+
* The entry's `id` is used verbatim as the slug. So `docs/index.mdx` →
|
|
226
|
+
* `/index`, `docs/guides/setup.mdx` → `/guides/setup`. If you want a docs
|
|
227
|
+
* entry at the root URL, name it appropriately and decide whether to use
|
|
228
|
+
* a static `pages/index.astro` or let the catch-all handle root.
|
|
229
|
+
*/
|
|
230
|
+
declare const getDocsStaticPaths: GetStaticPaths;
|
|
231
|
+
/**
|
|
232
|
+
* Read the current entry from `Astro.props`, render it, and return the
|
|
233
|
+
* pieces a docs page needs: the typed entry, the renderable `<Content />`
|
|
234
|
+
* component, and the headings list (for TOC generation).
|
|
235
|
+
*
|
|
236
|
+
* Pass the page's `Astro` global. Throws if `Astro.props.entry` is missing,
|
|
237
|
+
* which indicates the page didn't wire `getDocsStaticPaths` (or a custom
|
|
238
|
+
* equivalent) correctly.
|
|
239
|
+
*
|
|
240
|
+
* Usage:
|
|
241
|
+
*
|
|
242
|
+
* const { entry, Content, headings } = await getDocsPageProps(Astro);
|
|
243
|
+
*/
|
|
244
|
+
declare function getDocsPageProps(astro: AstroGlobal): Promise<{
|
|
245
|
+
entry: astro_content0.CollectionEntry<"docs">;
|
|
246
|
+
Content: unknown;
|
|
247
|
+
headings: {
|
|
248
|
+
depth: number;
|
|
249
|
+
text: string;
|
|
250
|
+
slug: string;
|
|
251
|
+
}[];
|
|
252
|
+
}>;
|
|
253
|
+
//#endregion
|
|
254
|
+
export { type BadgeVariant, type Breadcrumb, type NimbusConfig, type NimbusIntegrationOptions, type PrevNext, type PrevNextLink, type PrevNextOverrides, type SearchProvider, type SearchResult, type SidebarBadge, type SidebarConfig, type SidebarConfigItem, type SidebarExternalLinkItem, type SidebarGroupItem, type SidebarItem, type SidebarLinkItem, type SidebarSection, type TOCItem, nimbus as default, defaultCodeTransformers, defineConfig, getBreadcrumbs, getDocsPageProps, getDocsStaticPaths, getEditUrl, getLastUpdated, getPrevNext, getSidebar, getSidebarSections, getTOC, getVisibleEntries, renderEntryAsMarkdown, sidebarHash };
|
|
255
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/_internal/content.ts","../src/_internal/sidebar.ts","../src/_internal/transform.ts","../src/integration.ts","../src/_internal/code-transformers.ts","../src/index.ts"],"mappings":";;;;;;;;;;;;;ACqoBA;;;;;;;;AC3nBA;iBFwBsB,iBAAA,CACpB,WAAA,cACC,OAAA,CAAQ,eAAA;;;;iBCimBK,WAAA,CAAY,KAAA,EAAO,WAAA;;;;;;;;;;;ADnmBnC;UExBiB,8BAAA;EACf,IAAA;EACA,KAAA,EAAO,MAAA;EACP,QAAA;AAAA;AAAA,KAGU,yBAAA,IACV,OAAA,EAAS,8BAAA;AAAA,UAGM,4BAAA;EFgBS;;;;EEXxB,YAAA,GAAe,MAAA,SAAe,yBAAA;ED4mBL;EC1mBzB,gBAAA;AAAA;AAAA,UAGQ,aAAA;EACR,IAAA;AAAA;;AArBF;;;;;;iBAiNgB,qBAAA,CACd,KAAA,EAAO,aAAA,EACP,OAAA,GAAS,4BAAA;;;UC7KM,wBAAA;EDpCR;ECsCP,GAAA,GAAM,UAAA,QAAkB,GAAA;EDrChB;ECuCR,OAAA;EDpCU;;;;;AAIZ;;;;;;;;;;AAQC;;;;EC4CC,WAAA;IAGM,cAAA;IACA,WAAA;IACA,IAAA,IAAQ,QAAA;EAAA;AAAA;AAAA,iBAIA,MAAA,CACd,SAAA,EAAW,YAAA,EACX,OAAA,GAAS,wBAAA,GACR,gBAAA;;;AFijBH;;;;;;;;AC3nBA;;AD2nBA,iBGjlBgB,uBAAA,CA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