preperation to run the code in nodejs

This commit is contained in:
Anton Wilhelm 2019-01-30 08:48:34 +01:00
commit fd86c727af
5 changed files with 694 additions and 4 deletions

View file

@ -87,7 +87,10 @@ export function scrollActiveSidebar(router) {
coverHeight = cover ? cover.offsetHeight : 0
const sidebar = dom.getNode('.sidebar')
const lis = dom.findAll(sidebar, 'li')
let lis = []
if (sidebar != null) {
lis = dom.findAll(sidebar, 'li')
}
for (let i = 0, len = lis.length; i < len; i += 1) {
const li = lis[i]

View file

@ -9,6 +9,9 @@ export function btn(el) {
const toggle = _ => dom.body.classList.toggle('close')
el = dom.getNode(el)
if (el == null) {
return
}
dom.on(el, 'click', e => {
e.stopPropagation()
toggle()
@ -24,7 +27,9 @@ export function btn(el) {
export function collapse(el) {
el = dom.getNode(el)
if (el == null) {
return
}
dom.on(el, 'click', ({target}) => {
if (
target.nodeName === 'A' &&
@ -60,8 +65,10 @@ export function sticky() {
*/
export function getAndActive(router, el, isParent, autoTitle) {
el = dom.getNode(el)
const links = dom.findAll(el, 'a')
let links = []
if (el != null) {
links = dom.findAll(el, 'a')
}
const hash = decodeURI(router.toURL(router.getCurrentPath()))
let target