feat: Add title to sidebar links (#1286)

This commit is contained in:
沈唁 2020-07-19 09:00:23 +08:00 committed by GitHub
parent 117405b2d7
commit 667496b85d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 1 deletions

View File

@ -86,6 +86,8 @@ export function getAndActive(router, el, isParent, autoTitle) {
const href = a.getAttribute('href');
const node = isParent ? a.parentNode : a;
a.title = a.innerText;
if (hash.indexOf(href) === 0 && !target) {
target = a;
dom.toggleClass(node, 'add', 'active');

View File

@ -91,7 +91,7 @@ export function tree(toc, tpl = '<ul class="app-sub-sidebar">{inner}</ul>') {
let innerHTML = '';
toc.forEach(node => {
innerHTML += `<li><a class="section-link" href="${node.slug}">${node.title}</a></li>`;
innerHTML += `<li><a class="section-link" href="${node.slug}" title="${node.title}">${node.title}</a></li>`;
if (node.children) {
innerHTML += tree(node.children, tpl);
}