Repository navigation
Replies: 2 comments
|
Alternative Approach for OG Image Prerendering in FurmaDocs
The inconvenients of this approach are:
|
|
Hit this on a marketing site (Start prerender + fumadocs, images rendered with takumi). Sharing a finding in case it is useful. The limitation comes down to one line in const html = await res.text();
const filepath = path.join(outputDir, filename);
await promises.mkdir(path.dirname(filepath), { recursive: true });
await promises.writeFile(filepath, html);
Nitro handles this without branching on content type. It buffers unconditionally and exposes the text lazily, so the link crawler and any consumer of the string are unaffected (prerender.ts): let dataBuff: Buffer | undefined = Buffer.from(await res.arrayBuffer());
Object.defineProperty(_route, "contents", {
get: () => (dataBuff ? dataBuff.toString("utf8") : undefined),
set(value: string) { if (dataBuff) dataBuff = Buffer.from(value); },
});
...
await writeFile(filePath, dataBuff!);Applied here that would be roughly: buffer the response, keep passing Discovery seems worth treating as a separate problem. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hi! 👋
I'm using TanStack Start with Fumadocs and would like to prerender og:image.
My first attempt was to add a hidden
<a herf="/api/og/key" />to the page route so the prerenderer scrawler would generate it, but I realized it only processes text/html responses.I also considered generating the images from onSuccess hook, but it doesn't seem like a great fit with the Fumadocs vite plugin and i don't have access to the prerender server either.
Would supporting non-HTML responses (e.g. image/png) be within the scope of the prerender plugin? Since these routes are deterministic, it seems like they could be generated alongside HTML pages.
I'm happy to help implement this once there's agreement on the design.
All reactions