Skip to content

Layouts

The page shells Nimbus ships, and how to turn columns off per page or site-wide.

AI-generated · awaiting reviewUpdated

Layouts are user-owned .astro files in src/layouts/. The scaffolder writes them; you edit them freely.

The shells

  • BaseLayout — the outer shell: <html>, <head>, theme bootstrap, font preloads, metadata. Everything renders inside it.
  • DocsLayout — the docs page shape: sidebar rail, content column, table of contents, breadcrumbs, prev/next. The default for content pages.

Because they’re your files, the way to remove a piece of chrome is to delete it from the layout — drop <Pagination /> from DocsLayout and it’s gone site-wide.

On your own pages

A page under src/pages/ can use DocsLayout with just a title. It gets the header and content column, with no sidebar, table of contents, breadcrumbs or prev/next until you pass them:

src/pages/status.astroastro
---
import DocsLayout from "@/layouts/DocsLayout.astro";
import { getSidebar } from "@cloudflare/nimbus-docs/runtime";
---

<DocsLayout title="Status" sidebar={await getSidebar("/status")}>
  <p>All systems normal.</p>
</DocsLayout>

Pass sidebar for the docs sidebar, from getSidebar with the page’s path without the site base, or fill the sidebar slot with one of your own, such as the API sidebar.

Per-page toggles

Frontmatter turns individual columns off without touching the layout:

---
title: Wide page
sidebar: false           # hide the sidebar rail
tableOfContents: false   # hide the TOC column
---

For a page with no docs chrome at all — a landing or marketing page — use mode: custom:

---
title: Welcome
mode: custom
---

Site-wide toggles

The features block in your Nimbus config kills a column everywhere. The merge is AND — a column renders only when both the site-wide flag and the per-page field agree:

astro.config.tsts
const nimbusConfig = defineNimbusConfig({
  // …
  features: {
    sidebar: true,
    tableOfContents: false,   // no TOC on any page
  },
});

There’s no per-page opt-in to override a site-wide false: turn a column off site-wide and it stays off.

Keyboard shortcuts

Every shortcut is in one file, src/lib/shortcuts.ts. Change a key there, or set it to false to remove it with its hint:

src/lib/shortcuts.tsts
export const shortcuts = {
  search: "Mod+K", // ⌘K on macOS, Ctrl K elsewhere
  filterSidebar: "/",
  previousPage: "[",
  nextPage: "]",
} satisfies Shortcuts;

A key is a character, such as "/" or "?", or a combo, such as "Mod+K" or "Shift+Alt+P". Nothing fires while a reader types in a field, except combos.

Single keys, with no Ctrl, ⌘ or Alt, work anywhere on the page only while the reader can turn them off, as accessibility guidelines require. The “Single-key shortcuts” switch in the search dialog does that, or in the header when search is off.

A page without the switch keeps [ and ] to the previous/next bar while it has focus, and leaves / unbound. Single keys also wait while a dialog is open.

To add a shortcut of your own, name it in src/lib/shortcuts.ts and bind it with onShortcut from @cloudflare/nimbus-docs/client. Mark its hint data-nb-shortcut-hint and its control data-nb-shortcut-for, then call syncShortcutHints: the hint shows the key as the reader’s platform writes it, and hides with the other single keys.

src/components/help.client.tsts
import { mount, onShortcut, syncShortcutHints } from "@cloudflare/nimbus-docs/client";
import { shortcuts } from "@/lib/shortcuts";

// <button data-help data-nb-shortcut-for="?">Help <kbd data-nb-shortcut-hint="?">?</kbd></button>
mount("[data-help]", (button) => {
  syncShortcutHints(button);
  return onShortcut(shortcuts.help, () => button.click());
});

Type to search…

↑↓ navigate↵ selectEsc close