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}]` : ''
}`
const resolvedPath = path.resolve(
path.dirname((state.env as MarkdownEnv).path),
filepath
)
const { realPath, path: _path } = state.env as MarkdownEnv
const resolvedPath = path.resolve(path.dirname(realPath ?? _path), filepath)
// @ts-ignore
token.src = [resolvedPath, region.slice(1)]
token.markup = '```'

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

1
types/shared.d.ts vendored

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

Loading…
Cancel
Save