From da7ff83823f90326ad4e85a9f78dabd2eb67cd4c Mon Sep 17 00:00:00 2001 From: Rui Date: Wed, 4 Apr 2018 20:50:08 +0900 Subject: [PATCH] =?UTF-8?q?update-history.md:=20=E3=82=AF=E3=83=AA?= =?UTF-8?q?=E3=83=BC=E3=83=B3=E3=82=A2=E3=83=83=E3=83=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _includes/menu.md | 4 +- _includes/update-history.md | 73 +++++-------------------------------- 2 files changed, 12 insertions(+), 65 deletions(-) diff --git a/_includes/menu.md b/_includes/menu.md index 2b2223b..56ff87a 100644 --- a/_includes/menu.md +++ b/_includes/menu.md @@ -69,4 +69,6 @@ # 更新履歴 -{% include update-history.md %} +{% include update-history.md + limit = 10 +%} diff --git a/_includes/update-history.md b/_includes/update-history.md index 50a98d5..4c1f9aa 100644 --- a/_includes/update-history.md +++ b/_includes/update-history.md @@ -1,69 +1,14 @@ {% comment %} -引数: なし + 引数: + limit: 表示する日付数 {% endcomment %} -{% comment %} -Markdownの作成 -{% endcomment %} -{% capture list %} - {% comment %} - 全てのページのリストを更新日時でソートし逆順にする - {% endcomment %} - {% assign sorted_pages = (site.pages | sort: "date" | reverse) %} - - {% for page in sorted_pages limit: 10 %} - {% comment %} - 更新日時未記入の場合スキップ - {% endcomment %} - {% if page.date == null %} - {% continue %} - {% endif %} - - {% comment %} - 日付を書式化 - {% endcomment %} - {% assign date = (page.date | date: "%Y-%m-%d") %} - - {% comment %} - 日付がループ前のものと一致しない場合 - {% endcomment %} - {% if date != current_date %} - {% comment %} - split用文字 - {% endcomment %} - {% if current_date %}\\{% endif %} - - {% comment %} - 日付見出し - {% endcomment %} - **{{ date }}** - - {% comment %} - 変数のスコープが切れないことを利用 - {% endcomment %} - {% assign current_date = date %} - {% endif %} - - {% comment %} - 改行 - {% endcomment %} -
- - {% comment %} - リンクの挿入 - {% endcomment %} - [{{ page.title }}]({{ site.github.url }}/{{ page.url }}) +{% assign groups = site.pages | where_exp: "item", "item.date != null" | group_by: "date" | sort: "name" | reverse %} +{% for group in groups limit: include.limit %} +

+ {{ group.name | date: "%Y-%m-%d" }} + {% for item in group.items %} +
{{ item.title }} {% endfor %} -{% endcapture %} - -{% comment %} -"\\"で区切ったリスト -{% endcomment %} -{% assign lines = (list | split: "\\") %} -{% for line in lines %} -{% comment %} -改行、空白を取り除いて表示 -Markdownはインデント不可 -{% endcomment %} -{{ line | strip_newlines | strip }} +

{% endfor %}