[fix] toc tag-plugin

This commit is contained in:
xaoxuu 2022-12-11 20:20:30 +08:00
parent 612df73968
commit eb9c2742a8
1 changed files with 5 additions and 4 deletions

View File

@ -7,12 +7,13 @@
'use strict' 'use strict'
function layoutDocTree(pages) { function layoutDocTree(ctx, pages) {
const url_for = require('hexo-util').url_for.bind(ctx)
var el = '' var el = ''
el += '<ul class="toc">' el += '<ul class="toc">'
pages.forEach((p, i) => { pages.forEach((p, i) => {
el += '<li>' el += '<li>'
el += '<a class="list-link" href="' + p.permalink + '">' el += '<a class="list-link" href="' + url_for(p.path) + '">'
el += '<span>' + (p.title || p.seo_title) + '</span>' el += '<span>' + (p.title || p.seo_title) + '</span>'
el += '</a>' el += '</a>'
el += '</li>' el += '</li>'
@ -53,14 +54,14 @@ module.exports = ctx => function(args) {
el += '<div class="header">' el += '<div class="header">'
el += sec.title el += sec.title
el += '</div>' el += '</div>'
el += layoutDocTree(sec.pages) el += layoutDocTree(ctx, sec.pages)
el += '</section>' el += '</section>'
}) })
el += '</div>' el += '</div>'
} else { } else {
el += '<div class="body fs14">' el += '<div class="body fs14">'
el += '<div class="body">' el += '<div class="body">'
el += layoutDocTree(proj.pages) el += layoutDocTree(ctx, proj.pages)
el += '</div>' el += '</div>'
el += '</div>' el += '</div>'
} }