Skip to content

Commit

Permalink
feat: Add title to sidebar links (#1286)
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records committed Jul 19, 2020
1 parent 117405b commit 667496b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/core/event/sidebar.js
Expand Up @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion src/core/render/tpl.js
Expand Up @@ -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);
}
Expand Down

1 comment on commit 667496b

@vercel
Copy link

@vercel vercel bot commented on 667496b Jul 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.