mirror of
https://github.com/docsifyjs/docsify.git
synced 2025-12-08 19:55:52 +00:00
max-sub-level => sub-max-level
This commit is contained in:
parent
7a10e4aecf
commit
e932ff66b9
@ -1,3 +1,10 @@
|
||||
## 1.4.0
|
||||
### Features
|
||||
- Display TOC in the custom sidebar.
|
||||
- Custom background in coverpage.
|
||||
|
||||
### Bug fixes
|
||||
- Fix scroll highlight when Vue exist.
|
||||
|
||||
## 1.3.5
|
||||
### Bug fixes
|
||||
|
||||
@ -201,7 +201,7 @@ The contents of the file can be:
|
||||
- [HTML5 History Mode](/history-mode)
|
||||
```
|
||||
|
||||
#### max-sub-level
|
||||
#### sub-max-level
|
||||
|
||||
Display TOC in the custom sidebar. The default value is 0.
|
||||
|
||||
|
||||
@ -206,7 +206,7 @@ Sidebar 开关按钮
|
||||
- [HTML5 History Mode](/history-mode)
|
||||
```
|
||||
|
||||
#### max-sub-level
|
||||
#### sub-max-level
|
||||
|
||||
显示 TOC 在自定义的侧边栏里,默认最大显示 0 层。
|
||||
|
||||
|
||||
26
src/event.js
26
src/event.js
@ -66,18 +66,20 @@ export function activeLink (dom, activeParent) {
|
||||
if (!dom) return
|
||||
let target
|
||||
|
||||
;[].slice.call(dom.querySelectorAll('a')).forEach(node => {
|
||||
if (node.href === host && !target) {
|
||||
activeParent
|
||||
? node.parentNode.setAttribute('class', 'active')
|
||||
: node.setAttribute('class', 'active')
|
||||
target = node
|
||||
} else {
|
||||
activeParent
|
||||
? node.parentNode.removeAttribute('class')
|
||||
: node.removeAttribute('class')
|
||||
}
|
||||
})
|
||||
;[].slice.call(dom.querySelectorAll('a'))
|
||||
.sort((a, b) => b.href.length - a.href.length)
|
||||
.forEach(node => {
|
||||
if (host.indexOf(node.href) === 0 && !target) {
|
||||
activeParent
|
||||
? node.parentNode.setAttribute('class', 'active')
|
||||
: node.setAttribute('class', 'active')
|
||||
target = node
|
||||
} else {
|
||||
activeParent
|
||||
? node.parentNode.removeAttribute('class')
|
||||
: node.removeAttribute('class')
|
||||
}
|
||||
})
|
||||
|
||||
return target
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ const OPTIONS = {
|
||||
el: '#app',
|
||||
repo: '',
|
||||
maxLevel: 6,
|
||||
maxSubLevel: 0,
|
||||
subMaxLevel: 0,
|
||||
sidebar: '',
|
||||
sidebarToggle: false,
|
||||
loadSidebar: null,
|
||||
|
||||
@ -121,8 +121,8 @@ export function renderSidebar (content) {
|
||||
}
|
||||
|
||||
export function renderSubSidebar (target) {
|
||||
if (!OPTIONS.maxSubLevel) return
|
||||
target.parentNode.innerHTML += tpl.tree(genTree(toc, OPTIONS.maxSubLevel), '<ul>')
|
||||
if (!OPTIONS.subMaxLevel) return
|
||||
target.parentNode.innerHTML += tpl.tree(genTree(toc, OPTIONS.subMaxLevel), '<ul>')
|
||||
}
|
||||
|
||||
/**
|
||||
@ -134,7 +134,14 @@ export function renderCover (content) {
|
||||
renderCover.dom.classList.add('hidden')
|
||||
} else {
|
||||
renderCover.dom.classList.remove('hidden')
|
||||
!renderCover.rendered && renderTo('.cover-main', marked(content))
|
||||
if (!renderCover.rendered) {
|
||||
const html = marked(content)
|
||||
const div = document.createElement('div')
|
||||
div.innerHTML = html
|
||||
const a = div.querySelector('p:last-child')
|
||||
console.log(a)
|
||||
renderTo('.cover-main', marked(content))
|
||||
}
|
||||
renderCover.rendered = true
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user