fixed custom cover background, fixed #52

This commit is contained in:
qingwei.li
2017-01-12 18:44:41 +08:00
parent d9eedf609e
commit 557a165349
2 changed files with 5 additions and 2 deletions
+3
View File
@@ -1,3 +1,6 @@
### Bug fixes
- fixed custom cover background, fixed #52
## 1.6.1
### Bug fixes
- Fixed sidebar bug when the coverpage exist
+2 -2
View File
@@ -158,14 +158,14 @@ export function renderCover (content) {
// render cover
let html = markdown(content)
const match = html.trim().match('<p><img[^s]+src="(.*?)"[^a]+alt="(.*?)"></p>$')
const match = html.trim().match('<p><img[^s]+src="(.*?)"[^a]+alt="(.*?)">([^<]*?)</p>$')
// render background
if (match) {
const coverEl = document.querySelector('section.cover')
if (match[2] === 'color') {
coverEl.style.background = match[1]
coverEl.style.background = match[1] + (match[3] || '')
} else {
coverEl.classList.add('has-mask')
coverEl.style.backgroundImage = `url(${match[1]})`