Fumapress
Generate Open Graph images and page metadata for every docs page with the built-in Fumapress Takumi plugin.
Fumapress is a docs framework on Waku. It ships a Takumi plugin that renders an image for every docs page and adds the matching meta tags. See the Fumapress Takumi docs for the full plugin API.
Default setup
The plugin is part of Fumapress's recommended preset, which is on by default. With no setup, every docs page gets a 1200 × 630 WebP image and these tags:
<meta property="og:image" content="/docs/page.webp" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta property="twitter:card" content="summary_large_image" />Set site.baseUrl so og:image is an absolute URL. Without it, the tag holds a relative path,
which most crawlers cannot follow.
import { createPress } from "fumapress";
export default createPress(content).config({
site: {
baseUrl: "https://example.com",
},
});Customize the image
Pass ogImage to recommendedPreset() to set options. It takes the options of takumiPlugin(), and ogImage: false turns the images off.
import { createPress, recommendedPreset } from "fumapress";
export default createPress(content).config({
preset: recommendedPreset({ ogImage: { width: 1200 } }),
});getImage returns the image for one page. It runs with the app context as this, so this.siteConfig and the loaders are available. This example uses the docs card from fumadocs-ui/og/takumi with a Google font:
import { generate as generateOgNode } from "fumadocs-ui/og/takumi";
import { recommendedPreset } from "fumapress";
import { googleFonts } from "takumi-js/helpers";
recommendedPreset({
ogImage: {
getImage(page) {
return {
node: generateOgNode({
title: page.data.title,
description: page.data.description,
site: this.siteConfig.name,
}),
};
},
options: {
fonts: googleFonts([{ name: "Noto Serif", weight: [600, 800] }]),
},
},
});getImage returns:
| Field | Type | Role |
|---|---|---|
node | ReactNode | The content Takumi renders |
options | ImageResponseOptions, partial | Forwarded to ImageResponse, no format |
Options
These come from TakumiOptions in fumapress/plugins/takumi:
| Option | Default | Notes |
|---|---|---|
getImage | A built-in title and description card | (page) => { node, options? } 1 |
options | None | ImageResponse options shared by every image 2 |
width | 1200 | Image width, also written to og:image:width |
height | 630 | Image height, also written to og:image:height |
path | / (static) or /_takumi (dynamic) | Route prefix for image URLs |
1 Inside getImage, this is the app context.
2 getImage overrides them per page.
The plugin always encodes WebP, so format is not an option.
Image paths
Image paths follow page slugs. A page at /docs/styles gets /docs/styles.webp under path, and a section index gets index.webp. With i18n, the locale segment comes first.
Fonts
Takumi never reads system fonts. To cover characters outside the built-in Latin font, load families through options.fonts. Put fonts every page uses in the shared options, so they resolve once.
Last updated on