Examples
Practical examples. Live demos.
Pick an example to open it full screen, with the live preview and its source side by side.
Pick an example to open it full screen, with the live preview and its source side by side.
Docs is a layout with child routes. A topic renders in its outlet() and ./topic links resolve against the layout's route. Type in the notes, then switch topics: the layout is never rebuilt.
nuclo-router is not part of nuclo and must be installed:npm install nuclo nuclo-router// Docs.ts: a layout page. Its child route renders inside outlet(), and // moving between topics never rebuilds this page: the input keeps its text. import type { PageProps, RouteContext } from "nuclo-router"; import { router } from "../routes.ts"; import { s } from "../styles.ts"; const topics = ["intro", "install", "api"]; export default function Docs(_ctx: RouteContext, { outlet }: PageProps) { return div( h1("Docs"), div( s.docs, aside( s.side, // "./intro" resolves against this page's route: /docs/intro ...topics.map((t) => a({ href: router.href(`./${t}`) }, t)), input({ placeholder: "Notes (kept)" }), ), section(outlet()), ), ); }