feat: custom sidebar, #4 (#5)

* feat: custom sidebar, #4

* fix dev html

* fix doc

* fix doc
This commit is contained in:
cinwell.li
2016-11-27 18:53:31 +08:00
committed by GitHub
parent fc2e5b6fb9
commit 37e7984e7e
6 changed files with 71 additions and 15 deletions

View File

@@ -21,7 +21,7 @@ const renderer = new marked.Renderer()
renderer.heading = function (text, level) {
const slug = text.replace(/<(?:.|\n)*?>/gm, '').toLowerCase().replace(/[\s\n\t]+/g, '-')
toc.push({ level, slug, title: text })
toc.push({ level, slug: '#' + slug, title: text })
return `<h${level} id="${slug}"><a href="#${slug}" class="anchor"></a>${text}</h${level}>`
}
@@ -45,7 +45,7 @@ export default function (content, opts = {}) {
const section = `<section class="content">
<article class="markdown-section">${marked(content)}</article>
</section>`
const sidebar = `<aside class="sidebar">${genToc(toc, opts['max-level'])}</aside>`
const sidebar = `<aside class="sidebar">${genToc(toc, opts)}</aside>`
return `${corner}<main>${sidebar}${section}</main>`
}