---
title: "Reusable snippets"
description: "Write content once as a partial and include it anywhere with Render."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.klounge.kr/llms.txt
> Use this file to discover all available pages before exploring further.

# Reusable snippets

Partials are reusable content fragments. Write a snippet once, include it in many pages, and edit it in one place.

## Write a partial

Partials live in `src/content/partials/` as `.md` or `.mdx`, registered as a collection in `src/content.config.ts`:

```ts title="src/content.config.ts"
import { defineCollection } from "astro:content";
import { partialsCollection } from "@cloudflare/nimbus-docs/content";

export const collections = {
  partials: defineCollection(partialsCollection()),
};
```

```md title="src/content/partials/install-note.md"
Nimbus requires Node 22.12 or later and any package manager.
```

## Include it

`<Render>` is in the default registry. Reference a partial by its id — the path under `src/content/partials/` without the extension:

```mdx
<Render file="install-note" />
<Render file="workers/setup" />
```

If the ID does not resolve while rendering canonical HTML, `Render.astro` fails with a "did you mean..." suggestion and a list of available partials. Generated Markdown builds report the missing prepared partial by ID.

Nimbus expands partials in generated Markdown and merges their headings during the build. Circular or missing partials, a non-static or missing `file`, invalid `params`, undeclared parameters, and excluded or unknown visibility decisions fail the build before deployment.

### Custom partial IDs

If attributes on `<Render>` determine where a partial lives, configure one resolver on the Nimbus integration:

```ts title="astro.config.ts"
nimbus(config, {
  markdown: {
partialResolver: {
  revision: "product-v1",
  resolve: ({ file, product }) =>
    product ? `${product}/${file}` : file,
},
  },
});
```

The resolver controls partial IDs in alternate Markdown versions, `llms-full.txt`, and prepared headings. Change `revision` whenever its output rules change so Nimbus rebuilds the affected Markdown.

`Render.astro` is user-owned and resolves the canonical HTML partial separately. If you customize partial IDs, move the resolver function into a shared project file and call it from both `astro.config.ts` and `Render.astro` before `getVisibleEntry("partials", id)`. This keeps HTML, headings, and generated Markdown aligned.

Route-level `partialHeadings` options are not supported. Configure prepared heading resolution on the integration so request-rendered pages do not bundle generated-Markdown and heading logic. The user-owned `Render.astro` still loads and renders the selected partial as part of the HTML page.

## Parameters

Declare accepted params in the partial's frontmatter — suffix optional ones with `?`. They arrive as props:

```md title="src/content/partials/runtime-note.md"
---
params: [runtime, version?]
---
This page targets the {props.runtime} runtime.
```

```mdx
<Render file="runtime-note" params={{ runtime: "node" }} />
```

Missing required params and unexpected param names both fail the build with a clear message — partials are a typed contract, not string interpolation.

Source: https://docs.klounge.kr/writing/reusable-snippets/index.mdx
