Skip to content
CelPlume
↑↓select·Enteropen·EscclosePowered by Pagefind
ZH

codeBlock() renders a framed code figure with an optional filename header and a ghost copy button. The copy button is wired by the runtime ([data-cpd-copy]).

Filename header
src/lib/ui/tokens.ts
export const LAYOUT = {
  sidebarWidth: 256,
  tocWidth: 256,
  pageMaxWidth: 800,
} as const;
codeBlock({
filename: 'src/lib/ui/tokens.ts',
lang: 'ts',
code: 'export const LAYOUT = {\n sidebarWidth: 256,\n tocWidth: 256,\n pageMaxWidth: 800,\n} as const;\n',
});
Bare code
Bash
bun install
bun run dev
codeBlock({
lang: 'bash',
code: 'bun install\nbun run dev\n',
});

Pass tabs to render a multi-file snippet: the header shows one tab per file; the copy button copies the active tab.

Snippet with tabs
export function renderDrawer(options) {
  // ...
}
export function initDrawers(root) {
  // ...
}
codeBlock({
lang: 'ts',
tabs: [
{ label: 'drawer.ts', code: 'export function renderDrawer(options) {\n // ...\n}\n' },
{ label: 'runtime.ts', code: 'export function initDrawers(root) {\n // ...\n}\n' },
],
});
code*string
Code text (required when tabs is omitted).
filenamestring
Filename shown in the header — also enables the copy button.
Default''
langstring
Language hint class (language-<lang>), no syntax highlighting.
Default''
tabsCodeBlockTab[]
Multi-file snippet: { label, code } per file; header renders tabs and the copy button copies the active tab.

Real docs pages render fences through Expressive Code (Shiki-based), themed to match the kit: the frame follows --cpd-* tokens and the copy button is the kit one. The codeBlock() builder above is for demo pages and other non-Markdown surfaces; inside .md/.mdx prefer plain fences.

A title meta renders a filename tab; shell languages get a terminal frame. showLineNumbers enables line numbers per block:

src/example.js
export function greet(name) {
return `Hello, ${name}!`;
}

{lines} highlights whole lines or ranges; del={} / ins={} mark removed and added lines — with optional labels for “before vs after” without a fake diff fence:

markers.js
const theme = 'light';
const theme = 'dark';
// keep an eye on this line
const retries = 3;
const cache = new Map();
const TIMEOUT_MS = 5000;
const CACHE_SIZE = 100;

Use diff as the fence language for git-style blocks; -/+ prefixes get removed/added styling. Attach a regular language to keep highlighting:

function greet(name: string) {
return "Hello, " + name;
return `Hello, ${name}!`;
}

Word marks highlight every occurrence of a quoted string; ins= / del= mark inline additions and removals:

const retries = readConfig().attempts;
log(`retrying, ${retries} attempts left`);

collapse={ranges} folds line ranges behind an expandable toggle:

2 collapsed lines
// …long header comment…
// …another boilerplate line…
function main() {
console.log('visible');
}
// …trailing boilerplate…
1 collapsed line
// …more trailing boilerplate…

Marker colors are driven by LCH hue tokens in astro.config.mjs (insHue: 150, delHue: 25, gold mark background via customizeTheme), aligned with the Plumest success / error / gold tokens — backgrounds, borders and indicators derive per theme, no CSS overrides needed.

```js title="src/example.js" showLineNumbers
export function greet(name) {
return `Hello, ${name}!`;
}
```

<!-- @include: … --> comments splice another file into the page at build time — whole files, line slices, or named #region blocks. Include comments are Markdown comments, so live expansion requires .md pages (MDX does not support HTML comments); the forms:

./_snippets/prereq.md
<!-- @include: ./src/config/site.ts{10-25} -->
<!-- @include: ./src/config/site.ts{5-} -->
<!-- @include: ./src/config/site.ts{-4} -->
<!-- @include: ./src/example.ts#auth-config -->
FormMeaning
pathWhole file
path{10-25}Lines 10–25 (1-based, inclusive)
path{5-}Line 5 to the end
path{-4}Start to line 4
path#regionBetween #region name and #endregion markers

Notes:

  • Paths resolve relative to the including file and must stay inside the workspace.
  • Markdown targets (md/mdx) splice as raw Markdown; any other target is wrapped in a code fence tagged with its extension.
  • Includes nest (recursively, with cycle detection); include comments inside fences stay literal; missing files and malformed ranges remain literal.
  • The builder escapes code — raw markup is never executed.
  • No syntax highlighting ships with the kit; the real docs pages use astro-expressive-code blocks instead (styled to match).
  • Copy uses navigator.clipboard with a fallback execCommand('copy').