Add name option
This commit is contained in:
parent
67c1d0cd7d
commit
aa939147c6
4 changed files with 18 additions and 2 deletions
2
dev.html
2
dev.html
|
|
@ -8,5 +8,5 @@
|
||||||
<body class="">
|
<body class="">
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
</body>
|
</body>
|
||||||
<script src="/lib/docsify.js" data-repo="qingwei-li/docsify" data-auto2top data-sidebar-toggle data-router></script>
|
<script src="/lib/docsify.js" data-repo="qingwei-li/docsify" data-name="docsify" data-auto2top data-sidebar-toggle data-router></script>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,8 @@ const OPTIONS = merge({
|
||||||
homepage: 'README.md',
|
homepage: 'README.md',
|
||||||
coverpage: '',
|
coverpage: '',
|
||||||
basePath: '',
|
basePath: '',
|
||||||
auto2top: false
|
auto2top: false,
|
||||||
|
name: ''
|
||||||
}, window.$docsify)
|
}, window.$docsify)
|
||||||
const script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop()
|
const script = document.currentScript || [].slice.call(document.getElementsByTagName('script')).pop()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,12 +125,15 @@ export function renderSidebar (content) {
|
||||||
|
|
||||||
if (content) {
|
if (content) {
|
||||||
html = markdown(content)
|
html = markdown(content)
|
||||||
|
// find url tag
|
||||||
|
html = html.match(/<ul[^>]*>([\s\S]+)<\/ul>/g)[0]
|
||||||
} else if (OPTIONS.sidebar) {
|
} else if (OPTIONS.sidebar) {
|
||||||
html = tpl.tree(OPTIONS.sidebar, '<ul>')
|
html = tpl.tree(OPTIONS.sidebar, '<ul>')
|
||||||
} else {
|
} else {
|
||||||
html = tpl.tree(genTree(toc, OPTIONS.maxLevel), '<ul>')
|
html = tpl.tree(genTree(toc, OPTIONS.maxLevel), '<ul>')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
html = (OPTIONS.name ? `<h1><a href="/">${OPTIONS.name}</a></h1>` : '') + html
|
||||||
renderTo('aside.sidebar', html)
|
renderTo('aside.sidebar', html)
|
||||||
const target = event.activeLink('aside.sidebar', true)
|
const target = event.activeLink('aside.sidebar', true)
|
||||||
if (target) renderSubSidebar(target)
|
if (target) renderSubSidebar(target)
|
||||||
|
|
|
||||||
|
|
@ -188,6 +188,18 @@ main {
|
||||||
width: $sidebar-width;
|
width: $sidebar-width;
|
||||||
z-index: 20;
|
z-index: 20;
|
||||||
|
|
||||||
|
> h1 {
|
||||||
|
text-align: center;
|
||||||
|
margin: 0 auto 1em;
|
||||||
|
font-size: 1.5em;
|
||||||
|
font-weight: 300;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue