fix: forward slash.
This commit is contained in:
parent
cbcfcf78ae
commit
08a9446744
2 changed files with 10 additions and 3 deletions
|
@ -1,8 +1,8 @@
|
|||
import type { AstroIntegration, AstroConfig } from 'astro';
|
||||
import { InlineConfig, normalizePath } from 'vite';
|
||||
import { InlineConfig } from 'vite';
|
||||
import type { Config } from '@markdoc/markdoc';
|
||||
import Markdoc from '@markdoc/markdoc';
|
||||
import { getAstroConfigPath, MarkdocError, parseFrontmatter } from './utils.js';
|
||||
import { prependForwardSlash, getAstroConfigPath, MarkdocError, parseFrontmatter } from './utils.js';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import fs from 'node:fs';
|
||||
|
||||
|
@ -39,7 +39,7 @@ export default function markdoc(markdocConfig: Config = {}): AstroIntegration {
|
|||
|
||||
validateRenderProperties(markdocConfig, config);
|
||||
const body =
|
||||
getEntryInfo({ fileUrl: new URL('/' + normalizePath(id), 'file://'), contents: code }).body;
|
||||
getEntryInfo({ fileUrl: new URL(prependForwardSlash(id), 'file://'), contents: code }).body;
|
||||
const ast = Markdoc.parse(body);
|
||||
const content = Markdoc.transform(ast, markdocConfig);
|
||||
|
||||
|
|
|
@ -102,3 +102,10 @@ export function getAstroConfigPath(fs: typeof fsMod, root: string): string | und
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see 'astro/src/core/path.ts'
|
||||
*/
|
||||
export function prependForwardSlash(path: string) {
|
||||
return path[0] === '/' ? path : '/' + path;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue