Skip to content

Commit

Permalink
[Features] Add stats.json
Browse files Browse the repository at this point in the history
  • Loading branch information
zhonger committed Mar 26, 2024
1 parent 3b3aa00 commit 9d7dffa
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
22 changes: 22 additions & 0 deletions _layouts/stats.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{% capture stats_data %}
{"calendar":[
{% assign vdate = "2001-01-01" %}
{% assign vcount = 0 %}
{% assign total = 0 %}
{% for post in site.posts %}
{% assign cdate = post.date | date: "%Y-%m-%d" %}
{% if vdate == cdate %}
{% assign vcount = vcount | plus: 1 %}
{% else %}
{% if vdate != "2001-01-01" %}
{"date": "{{ vdate }}", "count": {{ vcount }} },
{% endif %}
{% assign vdate = cdate %}
{% assign vcount = 1 %}
{% endif %}
{% assign total = total | plus: 1 %}
{% endfor %}
{"date": "{{ vdate }}", "count": {{ vcount }} }],
"total": {{total}}
}
{% endcapture %}{{ stats_data | strip | strip_newlines}}
4 changes: 4 additions & 0 deletions pages/stats.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
layout: stats
permalink: /stats.json
---

0 comments on commit 9d7dffa

Please sign in to comment.