Skip to content
Blume
Esc
↑↓navigate↵open⌘Jpreview
On this page

Payload

Read a Payload collection through its REST API with the payload() source, lowering Lexical rich text bodies to Markdown with nothing to install.

The built-in payload() adapter reads a collection through the Payload REST API (/api/<collection>) and lowers each document’s Lexical body to Markdown: paragraphs, headings, bullet, numbered, and check lists, quotes, links, uploads, and horizontal rules. A body held in a text field passes through as Markdown, except that a link that isn’t a web, mail, phone, or relative address keeps only its label. Nothing to install.

import { defineConfig } from "blume";
import { filesystem, payload } from "blume/sources";

export default defineConfig({
  content: {
    sources: [
      filesystem({ root: "docs" }),
      payload({
        prefix: "handbook",
        url: "https://cms.example.com",
        collection: "docs",
        // Field paths default to title / description / slug / content /
        // updatedAt; order (no default) sets the sidebar order
        fields: { body: "richText" },
        // Extra query parameters: where[...], sort
        params: { sort: "title" },
      }),
    ],
  },
});

The API key comes from the PAYLOAD_API_KEY environment variable and is sent as users API-Key <key>; set authCollection when the key belongs to another auth-enabled collection. Only published documents are imported — --preview requests drafts and stages them with draft: true. Documents are fetched with depth: 1 so uploads carry their URLs, and a relative upload path (/media/x.png) resolves against url. Uploads are referenced at that URL rather than downloaded, since it doesn’t expire the way Notion’s do, so readers’ browsers load them from your Payload server or its storage; to have Blume download and optimize them at build instead, authorize the host in image.domains. A block or inlineBlock node maps to a Blume component through the engine’s serializers option, keyed by blockType, when you construct payloadSource directly and pass it to custom(). Setting serializers writes the source’s pages as MDX so the returned components render; a body held in a Markdown text field stays Markdown. A node with no Markdown equivalent, or a block with no serializer, is left out as a comment, and the source warns with BLUME_SOURCE_UNSUPPORTED_NODE naming it and the page.

Build a documentation website with Payload CMS walks through it end to end: a collection published as a searchable docs site, with draft previews and a rebuild whenever an editor publishes.

Last updated on

Was this page helpful?