fix: resolve snippets from original file path - align with include behavior

pull/2876/head
Divyansh Singh 2 years ago
parent 4f01f1a09c
commit 8aa032f60c

@ -125,10 +125,9 @@ export const snippetPlugin = (md: MarkdownIt, srcDir: string) => {
title ? `[${title}]` : '' title ? `[${title}]` : ''
}` }`
const resolvedPath = path.resolve( const { realPath, path: _path } = state.env as MarkdownEnv
path.dirname((state.env as MarkdownEnv).path), const resolvedPath = path.resolve(path.dirname(realPath ?? _path), filepath)
filepath
)
// @ts-ignore // @ts-ignore
token.src = [resolvedPath, region.slice(1)] token.src = [resolvedPath, region.slice(1)]
token.markup = '```' token.markup = '```'

@ -128,7 +128,8 @@ export async function createMarkdownToVueRenderFn(
path: file, path: file,
relativePath, relativePath,
cleanUrls, cleanUrls,
includes includes,
realPath: fileOrig
} }
const html = md.render(src, env) const html = md.render(src, env)
const { const {

1
types/shared.d.ts vendored

@ -136,4 +136,5 @@ export interface MarkdownEnv {
cleanUrls: boolean cleanUrls: boolean
links?: string[] links?: string[]
includes?: string[] includes?: string[]
realPath?: string
} }

Loading…
Cancel
Save