mirror of
https://github.com/zhigang1992/docsify.git
synced 2026-04-05 22:36:03 +08:00
fixed custom cover background, fixed #52
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
### Bug fixes
|
||||
- fixed custom cover background, fixed #52
|
||||
|
||||
## 1.6.1
|
||||
### Bug fixes
|
||||
- Fixed sidebar bug when the coverpage exist
|
||||
|
||||
@@ -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]})`
|
||||
|
||||
Reference in New Issue
Block a user