fixed custom cover background, fixed #52
This commit is contained in:
parent
d9eedf609e
commit
557a165349
2 changed files with 5 additions and 2 deletions
|
|
@ -1,3 +1,6 @@
|
||||||
|
### Bug fixes
|
||||||
|
- fixed custom cover background, fixed #52
|
||||||
|
|
||||||
## 1.6.1
|
## 1.6.1
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
- Fixed sidebar bug when the coverpage exist
|
- Fixed sidebar bug when the coverpage exist
|
||||||
|
|
|
||||||
|
|
@ -158,14 +158,14 @@ export function renderCover (content) {
|
||||||
|
|
||||||
// render cover
|
// render cover
|
||||||
let html = markdown(content)
|
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
|
// render background
|
||||||
if (match) {
|
if (match) {
|
||||||
const coverEl = document.querySelector('section.cover')
|
const coverEl = document.querySelector('section.cover')
|
||||||
|
|
||||||
if (match[2] === 'color') {
|
if (match[2] === 'color') {
|
||||||
coverEl.style.background = match[1]
|
coverEl.style.background = match[1] + (match[3] || '')
|
||||||
} else {
|
} else {
|
||||||
coverEl.classList.add('has-mask')
|
coverEl.classList.add('has-mask')
|
||||||
coverEl.style.backgroundImage = `url(${match[1]})`
|
coverEl.style.backgroundImage = `url(${match[1]})`
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue