Fix bugs caused by the previous version, fixed #56

This commit is contained in:
qingwei.li 2017-01-13 23:32:38 +08:00
parent 8630591bd2
commit fb8bf89d73
3 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,7 @@
## 1.7.4
### Bug fixes
- Fix bugs caused by the previous version
## 1.7.3 ## 1.7.3
### Bug fixes ### Bug fixes
- Add `hr` style - Add `hr` style

View File

@ -25,11 +25,13 @@ const script = document.currentScript || [].slice.call(document.getElementsByTag
if (script) { if (script) {
for (const prop in OPTIONS) { for (const prop in OPTIONS) {
const val = script.getAttribute('data-' + camel2kebab(prop)) const val = script.getAttribute('data-' + camel2kebab(prop))
OPTIONS[prop] = isNil(val) ? OPTIONS[prop] : (typeof OPTIONS[prop] === 'string' ? val : true) OPTIONS[prop] = isNil(val) ? OPTIONS[prop] : (val || true)
} }
if (OPTIONS.loadSidebar === true) OPTIONS.loadSidebar = '_sidebar.md' if (OPTIONS.loadSidebar === true) OPTIONS.loadSidebar = '_sidebar.md'
if (OPTIONS.loadNavbar === true) OPTIONS.loadNavbar = '_navbar.md' if (OPTIONS.loadNavbar === true) OPTIONS.loadNavbar = '_navbar.md'
if (OPTIONS.coverpage === true) OPTIONS.coverpage = '_coverpage.md' if (OPTIONS.coverpage === true) OPTIONS.coverpage = '_coverpage.md'
if (OPTIONS.repo === true) OPTIONS.repo = ''
if (OPTIONS.name === true) OPTIONS.name = ''
if (OPTIONS.sidebar) OPTIONS.sidebar = window[OPTIONS.sidebar] if (OPTIONS.sidebar) OPTIONS.sidebar = window[OPTIONS.sidebar]
} }

View File

@ -160,9 +160,12 @@ export function renderCover (content) {
if (renderCover.rendered) return event.sticky() if (renderCover.rendered) return event.sticky()
// render cover // render cover
const cacheToc = toc.slice()
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>$')
toc = cacheToc.slice()
// render background // render background
if (match) { if (match) {
const coverEl = document.querySelector('section.cover') const coverEl = document.querySelector('section.cover')