Fuma Content
Runtime integration

Bun

Use Fuma Content in Bun

Installation

npm i fuma-content

Create a config file to define collections:

content.config.ts (Example)
import { defineConfig } from "fuma-content/config";
import { mdxCollection } from "fuma-content/collections/mdx";

const docs = mdxCollection({
  dir: "content/docs",
});

export default defineConfig({
  collections: { docs },
});

Each collection generates its files in the .content folder, it's recommended to add a path alias:

tsconfig.json
{
  "compilerOptions": {
    "paths": {
      "content/*": ["./.content/*"]
    }
  }
}

Add the Fuma Content plugin, make sure to add it in preload script as it is a loader plugin.

import { createContent } from "fumadocs-mdx/bun";

export const content = await createContent();

// register loader plugins
Bun.plugin(content.createBunPlugin());

Usage

The content object exposes low-level API of Fuma Content, you can see Standalone for available APIs & usage.

For example, to generate collection files:

await content.emit();

With Bun plugin configured, you can access the generated collection outputs:

import { docs } from "content/docs";

// the content inside is compiled
console.log(docs.list());

On this page