mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-17 18:22:33 +00:00
Add post_count helper
This commit is contained in:
parent
3d34a1163f
commit
26d682cfa2
@ -7,7 +7,7 @@
|
|||||||
{%- if year !== current_year %}
|
{%- if year !== current_year %}
|
||||||
{%- set current_year = year %}
|
{%- set current_year = year %}
|
||||||
<div class="collection-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>
|
</div>
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
|||||||
@ -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) {
|
hexo.extend.helper.register('gitalk_md5', function(path) {
|
||||||
const str = this.url_for(path);
|
const str = this.url_for(path);
|
||||||
return crypto.createHash('md5').update(str).digest('hex');
|
return crypto.createHash('md5').update(str).digest('hex');
|
||||||
|
|||||||
@ -29,6 +29,11 @@
|
|||||||
margin: 60px 0;
|
margin: 60px 0;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
|
.collection-year-count {
|
||||||
|
font-size: $font-size-smallest;
|
||||||
|
badge();
|
||||||
|
}
|
||||||
|
|
||||||
&::before {
|
&::before {
|
||||||
background: $grey;
|
background: $grey;
|
||||||
margin-left: -4px;
|
margin-left: -4px;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user