Skip to content

2b2d. Hacking Stalight-Obsidian for MDX support

I used the Starlight Obsidian plugin for rendering my Obsidian vault in this site (0. nulspace). But there was a catch: Markdown files were copied as Markdown files. Which is okay, but I wanted them to be copied as MarkdownX files for support of React components.

What I ended up doing was forking the project and modifying packages/starlight-obsidian/libs/markdown.ts like this:

aliases: file.data.aliases,
content: String(file),
skip: file.data.skip === true,
type: file.data.isMdx === true ? 'mdx' : 'markdown',
type: 'mdx',
}
}

With this change, all files were copied as MarkdownX, enabling React support out of the box.