wiki/_includes/list-contents.md

27 lines
931 B
Markdown
Raw Normal View History

2017-12-02 02:04:52 -08:00
{% comment %}
引数:
type: 表示するコンテンツの種類
list: 表示するデータのリスト
キー: アンカー名
値: データ:
name: データ名
2017-12-02 02:04:52 -08:00
{% endcomment %}
2018-08-12 00:29:14 -07:00
<!-- 全アンカー名をスペース区切りで結合 -->
{% capture anchors %}
{% for data in include.list %} {{ data[0] }} {% endfor %}
2017-12-02 02:04:52 -08:00
{% endcapture %}
2018-08-12 00:29:14 -07:00
<!-- anchorsを空白で区切ってソート -->
{% assign sorted-anchors = anchors | split: " " | sort %}
2017-12-02 02:04:52 -08:00
2018-08-12 00:29:14 -07:00
<!-- detailsタイプからテンプレートファイル名を作成 -->
{% capture template-name %}content-{{ include.type }}.md{% endcapture %}
2017-12-02 02:04:52 -08:00
2018-08-12 00:29:14 -07:00
<!-- ソートしたアンカー順でリスト展開 -->
<!-- NOTE: Markdownはインデントできないのでforの中身はインデントなし -->
{% for anchor in sorted-anchors %}
# {{ include.list[anchor].name }} {#{{ anchor }}}
{% include {{ template-name }} list=include.list key=anchor %}
2017-12-02 02:04:52 -08:00
{% endfor %}