Add post_count helper

This commit is contained in:
Mimi 2024-04-17 12:30:16 +08:00
parent 3d34a1163f
commit 26d682cfa2
3 changed files with 10 additions and 1 deletions

View File

@ -7,7 +7,7 @@
{%- if year !== current_year %}
{%- set current_year = year %}
<div class="collection-year">
<span class="collection-header">{{ current_year }}</span>
<span class="collection-header">{{ current_year }}{% if is_archive() %}<span class="collection-year-count">{{ post_count(year) }}</span>{% endif %}</span>
</div>
{%- endif %}

View File

@ -92,6 +92,10 @@ hexo.extend.helper.register('post_edit', function(src) {
});
});
hexo.extend.helper.register('post_count', function(year) {
return this.site.posts.filter(post => this.date(post.date, 'YYYY') === year).count();
});
hexo.extend.helper.register('gitalk_md5', function(path) {
const str = this.url_for(path);
return crypto.createHash('md5').update(str).digest('hex');

View File

@ -29,6 +29,11 @@
margin: 60px 0;
position: relative;
.collection-year-count {
font-size: $font-size-smallest;
badge();
}
&::before {
background: $grey;
margin-left: -4px;