fix: resolve path of image and embed files, fixed #412
This commit is contained in:
parent
74ff68a40e
commit
bfd0d18e48
8 changed files with 29 additions and 23 deletions
|
|
@ -4,7 +4,7 @@ import {helper as helperTpl, tree as treeTpl} from './tpl'
|
|||
import {genTree} from './gen-tree'
|
||||
import {slugify} from './slugify'
|
||||
import {emojify} from './emojify'
|
||||
import {isAbsolutePath, getPath} from '../router/util'
|
||||
import {isAbsolutePath, getPath, getParentPath} from '../router/util'
|
||||
import {isFn, merge, cached, isPrimitive} from '../util/core'
|
||||
|
||||
const cachedLinks = {}
|
||||
|
|
@ -112,7 +112,11 @@ export class Compiler {
|
|||
|
||||
if (config.include) {
|
||||
if (!isAbsolutePath(href)) {
|
||||
href = getPath(process.env.SSR ? '' : this.contentBase, href)
|
||||
href = getPath(
|
||||
process.env.SSR ? '' : this.contentBase,
|
||||
getParentPath(this.router.getCurrentPath()),
|
||||
href
|
||||
)
|
||||
}
|
||||
|
||||
let media
|
||||
|
|
@ -254,7 +258,7 @@ export class Compiler {
|
|||
}
|
||||
|
||||
if (!isAbsolutePath(href)) {
|
||||
url = getPath(contentBase, href)
|
||||
url = getPath(contentBase, getParentPath(router.getCurrentPath()), href)
|
||||
}
|
||||
|
||||
return `<img src="${url}"data-origin="${href}" alt="${text}"${attrs}>`
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue