修复自定义post-index标签不高亮问题 (#304)

This commit is contained in:
Giresharu 2023-07-18 13:45:19 +08:00 committed by GitHub
parent 6516b2a68e
commit dae9a259a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -40,7 +40,9 @@ function layoutDiv() {
if (theme['post-index']) {
const obj = theme['post-index'];
for (let key of Object.keys(obj)) {
if (full_url_for(page.path) == full_url_for(obj[key])) {
// 当 page 的末尾为 index.html 或者处于该 page 的某个子页面时也应该匹配
// if (full_url_for(page.path) == full_url_for(obj[key])) {
if (full_url_for(page.path).startsWith(full_url_for(obj[key]))){
el += '<a class="active" href="' + url_for(obj[key]) + '">' + key + '</a>';
} else {
el += '<a href="' + url_for(obj[key]) + '">' + key + '</a>';