fix(render): support html file

This commit is contained in:
qingwei.li 2017-02-19 00:10:38 +08:00 committed by cinwell.li
commit 7b6a2ac404
7 changed files with 35 additions and 18 deletions

View file

@ -5,7 +5,7 @@ import { genTree } from './gen-tree'
import { slugify, clearSlugCache } from './slugify'
import { emojify } from './emojify'
import { toURL, parse } from '../route/hash'
import { getBasePath, getPath } from '../route/util'
import { getBasePath, isResolvePath, getPath } from '../route/util'
import { isFn, merge, cached } from '../util/core'
let markdownCompiler = marked
@ -84,9 +84,13 @@ renderer.paragraph = function (text) {
return `<p>${text}</p>`
}
renderer.image = function (href, title, text) {
const url = getPath(contentBase, href)
let url = href
const titleHTML = title ? ` title="${title}"` : ''
if (!isResolvePath(href)) {
url = getPath(contentBase, href)
}
return `<img src="${url}" data-origin="${href}" alt="${text}"${titleHTML}>`
}