[fix] author’s page #367

This commit is contained in:
xaoxuu 2024-01-22 15:56:40 +08:00
parent 7b6b0d2691
commit 4bfe9e2c57
2 changed files with 3 additions and 2 deletions

View File

@ -17,7 +17,7 @@ function layoutArchiveList() {
} }
el += `<div class="post-list archives">` el += `<div class="post-list archives">`
var years = [] var years = []
const posts = page.author != null ? site.posts.filter(p => (p.author || theme.default_author.name) == page.author.name) : site.posts const posts = page.author != null ? site.posts.filter(p => (p.author || theme.default_author.id) == page.author.id) : site.posts
posts.sort('date', -1).each(function(post) { posts.sort('date', -1).each(function(post) {
post.year = date(post.date, 'YYYY') post.year = date(post.date, 'YYYY')
if (post.year && (years.includes(post.year) == false) && (post.title || post.date)) { if (post.year && (years.includes(post.year) == false) && (post.title || post.date)) {

View File

@ -6,10 +6,11 @@ hexo.extend.generator.register('author', function (locals) {
const { site_tree, authors } = hexo.theme.config const { site_tree, authors } = hexo.theme.config
var pages = [] var pages = []
for (let key of Object.keys(authors)) { for (let key of Object.keys(authors)) {
const author = authors[key] var author = authors[key]
if (author.hidden) { if (author.hidden) {
continue continue
} }
author.id = key
pages.push({ pages.push({
path: author.path, path: author.path,
layout: ['archive'], layout: ['archive'],