2021-02-19 23:33:19 +08:00
|
|
|
<%
|
2021-02-21 13:44:11 +08:00
|
|
|
page.robots = 'noindex,follow';
|
2021-02-21 03:13:21 +08:00
|
|
|
if (page.menu_id == undefined) {
|
|
|
|
page.menu_id = 'post';
|
2021-02-19 23:33:19 +08:00
|
|
|
}
|
2024-01-04 22:50:57 +08:00
|
|
|
if (page.author) {
|
2024-01-17 14:07:30 +08:00
|
|
|
page.header = false;
|
2024-01-04 22:50:57 +08:00
|
|
|
}
|
|
|
|
function layoutArchiveList() {
|
|
|
|
var el = ''
|
2024-02-06 14:07:46 +08:00
|
|
|
var cls = ''
|
2024-01-04 22:50:57 +08:00
|
|
|
if (page.author) {
|
|
|
|
page.title = page.author.name
|
2024-02-06 14:07:46 +08:00
|
|
|
page.banner = page.author.banner
|
|
|
|
page.banner_info = {
|
|
|
|
avatar: page.author.avatar,
|
|
|
|
subtitle: page.author.description
|
|
|
|
}
|
|
|
|
el += partial('_partial/main/navbar/article_banner')
|
|
|
|
cls += ' author'
|
2024-01-04 22:50:57 +08:00
|
|
|
} else {
|
|
|
|
page.title = __('btn.archives')
|
2024-01-14 17:04:00 +08:00
|
|
|
el += partial('_partial/main/navbar/nav_tabs_blog')
|
2024-01-04 22:50:57 +08:00
|
|
|
}
|
2024-02-06 14:07:46 +08:00
|
|
|
el += `<div class="post-list${cls} archives">`
|
2024-01-04 22:50:57 +08:00
|
|
|
var years = []
|
2024-01-22 15:56:40 +08:00
|
|
|
const posts = page.author != null ? site.posts.filter(p => (p.author || theme.default_author.id) == page.author.id) : site.posts
|
2024-01-22 12:19:10 +08:00
|
|
|
posts.sort('date', -1).each(function(post) {
|
2024-01-04 22:50:57 +08:00
|
|
|
post.year = date(post.date, 'YYYY')
|
|
|
|
if (post.year && (years.includes(post.year) == false) && (post.title || post.date)) {
|
|
|
|
years.push(post.year)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
for (let year of years) {
|
2024-01-19 01:05:44 +08:00
|
|
|
el += `<article class="${scrollreveal('')}" id="archive">`
|
2024-01-04 22:50:57 +08:00
|
|
|
el += `<div class='archive-header h4'>${year}</div>`
|
2024-01-22 12:19:10 +08:00
|
|
|
posts.sort('date', -1).filter(function (post) {
|
2024-01-04 22:50:57 +08:00
|
|
|
post.year = date(post.date, 'YYYY')
|
|
|
|
return post.year == year
|
|
|
|
}).each(function(post) {
|
|
|
|
el += `<div class="archive-list">`
|
|
|
|
el +=`<a class='post fs14' href="${url_for(post.link || post.path)}">`
|
|
|
|
el += `<time>${date(post.date, 'MM-DD')}</time>`
|
|
|
|
el += `<span>`
|
|
|
|
if (post.title) {
|
|
|
|
el += post.title
|
|
|
|
} else if (post.date) {
|
|
|
|
el += date(post.date, config.date_format)
|
|
|
|
}
|
|
|
|
el += `</span>`
|
|
|
|
el += `</a>`
|
|
|
|
el += `</div>`
|
|
|
|
})
|
|
|
|
el += `</article>`
|
|
|
|
}
|
|
|
|
el += `</div>`
|
|
|
|
return el
|
|
|
|
}
|
|
|
|
function layoutDiv() {
|
|
|
|
if (page.posts && (is_category() || is_tag())) {
|
|
|
|
return partial('index')
|
|
|
|
} else {
|
|
|
|
return layoutArchiveList()
|
|
|
|
}
|
|
|
|
}
|
2021-02-19 23:33:19 +08:00
|
|
|
%>
|
2024-01-04 22:50:57 +08:00
|
|
|
|
|
|
|
<%- layoutDiv() %>
|