Skip to content

Commit c1930c0

Browse files
committed
fix: pass markdown theme to preloadContentLanguages for correct shiki initialization
preloadContentLanguages initialized the shiki highlighter with default themes (vitesse-light/vitesse-dark) because it never received the user's configured theme. When renderMarkdown later called codeToHast with the actual theme, the highlighter didn't have it loaded, silently falling back to plain text for all code blocks.
1 parent c5660bc commit c1930c0

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

packages/markopress/src/build/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ export async function build(options: BuildOptions = {}): Promise<BuildResult> {
310310
console.log(' Public assets synced\n');
311311

312312
// Preload syntax highlighting languages from content + config
313-
await preloadContentLanguages(modules, config.markdown?.languages, debug);
313+
await preloadContentLanguages(modules, config.markdown?.languages, debug, config.markdown?.theme);
314314

315315
// Step 4a: Build search index
316316
if (config.search?.enabled !== false) {

packages/markopress/src/markdown/loader.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,13 @@ export function scanCodeBlockLanguages(content: string): string[] {
465465
export async function preloadContentLanguages(
466466
modules: Array<{ files: Array<{ filePath: string }> }>,
467467
configLanguages: string[] = [],
468-
debug = false
468+
debug = false,
469+
theme?: { light?: string; dark?: string }
469470
): Promise<void> {
471+
// Ensure highlighter is initialized with the correct theme before loading languages
472+
if (!highlighterInstance && theme) {
473+
await getHighlighterInstance(theme);
474+
}
470475
const scannedLanguages = new Set<string>();
471476
for (const mod of modules) {
472477
for (const file of mod.files) {

0 commit comments

Comments
 (0)