[feat] author’s page #367

This commit is contained in:
xaoxuu 2024-01-22 12:19:10 +08:00
parent c2916732c1
commit dcff1e32a3
1 changed files with 3 additions and 2 deletions

View File

@ -17,7 +17,8 @@ function layoutArchiveList() {
} }
el += `<div class="post-list archives">` el += `<div class="post-list archives">`
var years = [] var years = []
site.posts.sort('date', -1).each(function(post) { const posts = page.author != null ? site.posts.filter(p => (p.author || theme.default_author.name) == page.author.name) : site.posts
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)) {
years.push(post.year) years.push(post.year)
@ -26,7 +27,7 @@ function layoutArchiveList() {
for (let year of years) { for (let year of years) {
el += `<article class="${scrollreveal('')}" id="archive">` el += `<article class="${scrollreveal('')}" id="archive">`
el += `<div class='archive-header h4'>${year}</div>` el += `<div class='archive-header h4'>${year}</div>`
site.posts.sort('date', -1).filter(function (post) { posts.sort('date', -1).filter(function (post) {
post.year = date(post.date, 'YYYY') post.year = date(post.date, 'YYYY')
return post.year == year return post.year == year
}).each(function(post) { }).each(function(post) {