From e91411ab4264fc3e422e9f7e3f14c6da981e2903 Mon Sep 17 00:00:00 2001 From: Rishabh Date: Fri, 7 Aug 2026 10:27:05 +0530 Subject: [PATCH] fix: render unknown code fence languages as plain text Code fences using a language Shiki does not bundle threw at build time, for example "Language `logql` not found, you may need to load it first". Shiki's rehype integration only loads a language when it is in the bundle, and otherwise falls through to `fallbackLanguage`. That option was unset, so the unknown language reached `codeToHast` and threw. Set it to `text` so those blocks render unhighlighted instead of failing the page. Fumadocs' defaults are spread because the config type is not `Partial`; the highlighter factory merges them anyway, so themes, notation transformers and meta parsing are unaffected. Co-Authored-By: Claude Opus 5 (1M context) --- packages/chronicle/src/server/vite-config.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/chronicle/src/server/vite-config.ts b/packages/chronicle/src/server/vite-config.ts index a8477be..06196c3 100644 --- a/packages/chronicle/src/server/vite-config.ts +++ b/packages/chronicle/src/server/vite-config.ts @@ -1,5 +1,5 @@ import react from '@vitejs/plugin-react'; -import { remarkDirectiveAdmonition, remarkMdxMermaid } from 'fumadocs-core/mdx-plugins'; +import { rehypeCodeDefaultOptions, remarkDirectiveAdmonition, remarkMdxMermaid } from 'fumadocs-core/mdx-plugins'; import { defineConfig as defineFumadocsConfig } from 'fumadocs-mdx/config'; import mdx from 'fumadocs-mdx/vite'; import { nitro } from 'nitro/vite'; @@ -191,6 +191,13 @@ export async function createViteConfig( mdxOptions: { remarkImageOptions: false, valueToExport: ['readingTime', 'images'], + // Render fences in languages Shiki doesn't bundle (e.g. logql) as + // plain text instead of throwing. Defaults are spread because the + // config type isn't Partial — the factory merges them anyway. + rehypeCodeOptions: { + ...rehypeCodeDefaultOptions, + fallbackLanguage: 'text', + }, remarkPlugins: [ remarkDirective, [remarkDirectiveAdmonition, {