Skip to content

Commit

Permalink
fix: resolve snippets from original file path - align with include be…
Browse files Browse the repository at this point in the history
…havior
  • Loading branch information
brc-dd committed Aug 28, 2023
1 parent 4f01f1a commit 8aa032f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/node/markdown/plugins/snippet.ts
Expand Up @@ -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 = '```'
Expand Down
3 changes: 2 additions & 1 deletion src/node/markdownToVue.ts
Expand Up @@ -128,7 +128,8 @@ export async function createMarkdownToVueRenderFn(
path: file,
relativePath,
cleanUrls,
includes
includes,
realPath: fileOrig
}
const html = md.render(src, env)
const {
Expand Down
1 change: 1 addition & 0 deletions types/shared.d.ts
Expand Up @@ -136,4 +136,5 @@ export interface MarkdownEnv {
cleanUrls: boolean
links?: string[]
includes?: string[]
realPath?: string
}

0 comments on commit 8aa032f

Please sign in to comment.