0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-02-17 22:44:24 -05:00

fix: properly show mdoc errors in overlay

This commit is contained in:
bholmesdev 2023-03-17 17:56:13 -04:00
parent ec003b5b53
commit 83af723ac5

View file

@ -125,6 +125,7 @@ export interface AstroErrorPayload {
// Shiki does not support `mjs` or `cjs` aliases by default.
// Map these to `.js` during error highlighting.
const ALTERNATIVE_JS_EXTS = ['cjs', 'mjs'];
const ALTERNATIVE_MD_EXTS = ['mdoc'];
/**
* Generate a payload for Vite's error overlay
@ -158,6 +159,9 @@ export async function getViteErrorPayload(err: ErrorWithMetadata): Promise<Astro
if (ALTERNATIVE_JS_EXTS.includes(highlighterLang ?? '')) {
highlighterLang = 'js';
}
if (ALTERNATIVE_MD_EXTS.includes(highlighterLang ?? '')) {
highlighterLang = 'md';
}
const highlightedCode = err.fullCode
? highlighter.codeToHtml(err.fullCode, {
lang: highlighterLang,