Shared components, layouts, shortcodes, theme, and build tooling for NukeHub documentation sites.
- Astro layouts:
BaseLayout,DocLayout - Docs components:
TableOfContents,Pagination,EditLink,NotFound - React components: header, footer, sidebar, command palette, theme toggle, search, scroll progress, context menu, lightbox
- UI primitives:
Button,Input,Label,Textarea,Checkbox,RadioGroup,Select,Switch,Combobox,MultiSelect,Slider,TimePicker,Calendar,DateRangePicker,Modal,Dialog,ConfirmDialog,SearchInput,Badge,Skeleton,Toast,Toaster - MDX shortcodes:
Callout,Tabs,TabItem,FileTree,Mermaid,Steps,Step,YouTube,Odysee,ImageFigure,DataTable,Citation - Opt-in interactive shortcodes:
PlotlyandModel3D(requires installingplotly.js-dist-minandthree, then passing the components toDocLayoutviamdxComponents) - Theme: Tailwind CSS v4 tokens, dark/light/system mode, accent-color picker, and global styles. The favicon and theme-color meta tag follow the selected accent.
- Utilities:
cn, sidebar/pagination helpers, theme helpers - Build integration:
markdownNegotiationemits a Markdown sibling for every HTML page - Sync CLI:
nukehub-sync-docscopies and cleans docs from../docs/intosrc/content/docs/, rewriting Markdown links and injecting frontmatter (includingeditPath, the repo-relative source path used byEditLink— declareeditPath: z.string().optional()in your docs collection schema)
npm install @nukehub/docs-kit-
Create a fresh Astro project or use the
docs-templaterepo as a starting point. -
Add project-specific files:
src/ ├── content.config.ts ├── data/ │ ├── site.ts │ ├── nav.ts │ └── footer.ts ├── env.d.ts └── pages/ ├── [...slug].astro └── 404.astro -
Import layouts from the kit:
--- import DocLayout from "@nukehub/docs-kit/components/layout/DocLayout.astro"; import BaseLayout from "@nukehub/docs-kit/components/layout/BaseLayout.astro"; ---
Pass your
site,navItems,footerColumns, andfooterLegalas props toDocLayoutandBaseLayout. -
Add
astro.config.mjsusing the kit'smarkdownNegotiationintegration and@tailwindcss/vite. -
Add docs under
docs/and runnpx nukehub-sync-docs.
The kit generates a dynamic, theme-aware favicon so the tab icon matches the user's selected accent and resolved light/dark mode.
- Place a
favicon.svgin your project'spublic/directory. It is used as the no-JS fallback. - When JavaScript runs, the kit replaces it with a data-URI SVG colored from the current
--primaryCSS variable. - The dynamic favicon uses the built-in NukeHub logo paths. To use a custom logo dynamically, pass
faviconPathsin yourSiteConfig. The string should contain SVG elements that usefill="currentColor"/stroke="currentColor"so the kit can tint them with the selected accent. IffaviconPathsis omitted, the default NukeHub logo is used.
Use the NotFound component for a themed 404 page:
---
import BaseLayout from "@nukehub/docs-kit/components/layout/BaseLayout.astro";
import NotFound from "@nukehub/docs-kit/components/docs/NotFound.astro";
---
<BaseLayout site={SITE} navItems={navItems} title={`404 — Page not found | ${SITE.name}`}>
<NotFound base={SITE.base} />
</BaseLayout>The kit also provides Plotly and Model3D shortcodes, but they are not enabled by default because they pull in large runtime dependencies.
To use them:
-
Install the optional peer dependencies in the consumer project:
npm install plotly.js-dist-min three npm install -D @types/plotly.js @types/three
-
Import the shortcodes and pass them to
DocLayout:--- import DocLayout from "@nukehub/docs-kit/components/layout/DocLayout.astro"; import Plotly from "@nukehub/docs-kit/components/mdx/shortcodes/Plotly.astro"; import Model3D from "@nukehub/docs-kit/components/mdx/shortcodes/Model3D.astro"; --- <DocLayout ... mdxComponents={{ Plotly, Model3D }} />
-
Use them in
.mdxfiles:<Plotly data={[{ x: [1, 2, 3], y: [1, 4, 9], type: "scatter", mode: "lines+markers" }]} layout={{ title: "Sample chart" }} /> <Model3D src="/models/example.glb" caption="A sample 3D model." />
Both components dynamically load their runtime libraries and only render on the client.
Docs can declare references in frontmatter and cite them inline. DocLayout renders a linked bibliography automatically and offers copy-to-clipboard exports in plain text, BibTeX, and RIS.
-
Add a
referencesarray to your content schema (the shape is exported from@nukehub/docs-kit):import { z } from "zod"; import type { Reference } from "@nukehub/docs-kit"; const docs = defineCollection({ loader: glob({ pattern: "**/*.{md,mdx}", base: "./src/content/docs" }), schema: z.object({ title: z.string(), references: z .array( z.object({ id: z.string(), title: z.string(), url: z.string().url(), source: z.string().optional(), date: z.string().optional(), authors: z.array(z.string()).optional(), type: z.enum(["article", "book", "inproceedings", "techreport", "misc"]).optional(), publisher: z.string().optional(), doi: z.string().optional(), arxiv: z.string().optional(), journal: z.string().optional(), volume: z.string().optional(), issue: z.string().optional(), pages: z.string().optional(), }), ) .default([]), }), });
-
Pass the references to
DocLayout:--- import DocLayout from "@nukehub/docs-kit/components/layout/DocLayout.astro"; --- <DocLayout doc={doc} headings={headings} allDocs={allDocs} site={SITE} navItems={navItems} footerColumns={footerColumns} footerLegal={footerLegal} references={doc.data.references} />
-
Declare references in frontmatter and cite them in the MDX body:
--- title: Nuclear data references: - id: openmc-docs title: OpenMC Documentation url: https://docs.openmc.org/ source: OpenMC Development Team date: "2023" --- OpenMC uses continuous-energy nuclear data<Citation id="openmc-docs" />.
For custom layouts, import References directly from @nukehub/docs-kit/components/mdx/shortcodes/References.
When the kit improves, pull the latest version in any consuming project:
npm update @nukehub/docs-kitNo need to copy files or cherry-pick template changes.
docs-template— reference consumer of this kit.