Move all posts into collections and update Liquid templates

This commit is contained in:
Takumi Sueda 2022-12-12 22:13:06 +09:00
parent dd5047c282
commit 9927d52aeb
21 changed files with 156 additions and 99 deletions

View File

@ -62,10 +62,6 @@ atom_feed:
og_image: "assets/images/og_image.jpg"
stay_on_top_categories:
- 初めての方へ
- a
footer:
links:
- label: "Twitter"
@ -82,7 +78,6 @@ defaults:
# _posts
- scope:
path: ""
type: posts
values:
layout: single
author_profile: false
@ -90,18 +85,49 @@ defaults:
show_date: false
toc: true
toc_sticky: true
# _pages
- scope:
path: "_pages"
type: pages
values:
layout: single
author_profile: false
show_date: false
category_archive:
type: liquid
path: /categories/
tag_archive:
type: liquid
path: /tags/
collections_dir: collections
collections_order:
- beginners
- build
- u-boot
- linux
- tips
- meta
collections:
beginners:
output: true
name: For Beginners
order:
- get-started.md
- roadmap.md
build:
output: true
name: 手動ビルド
order:
- uboot.md
- linux.md
- copy-sd-card.md
u-boot:
output: true
name: U-Boot
order:
- boot-eboot.md
- boot-usb.md
linux:
output: true
name: Linux
order:
- package-list.md
tips:
output: true
name: Tips
meta:
output: true
name: Meta

View File

@ -1,7 +1,7 @@
main:
- title: "初めての方へ"
url: /for%20beginners/beginner-get-started/
url: /beginners/get-started/
- title: "タグ一覧"
url: /tags/
- title: "この Wiki について"
url: /about/
url: /about/

View File

@ -4,88 +4,50 @@ layout: archive
{{ content }}
{% assign stay_on_top = site.stay_on_top_categories %}
{% assign categories_max = 0 %}
{% for category in site.categories %}
{% if category[1].size > categories_max %}
{% assign categories_max = category[1].size %}
{% endif %}
{% endfor %}
<img src="/assets/images/top.jpg">
<h3>カテゴリ一覧</h3>
<ul class="taxonomy__index">
{% comment %} Iterate the Stay-on-Top list and all categories and render matched categories {% endcomment %}
{% for category in site.categories %}
{% for stay in stay_on_top %}
<!--<p>category[0] = `{{ category[0]}}`, stay = `{{ stay }}`</p>-->
{% if category[0] == stay %}
<li>
<!-- Stay on top -->
<a href="#{{ category[0] | slugify }}">
<strong>{{ category[0] }}</strong>
</a>
</li>
{% endif %}
{% endfor %}
{% endfor %}
{% comment %} Iterate the Stay-on-Top list and all categories and render unmatched categories {% endcomment %}
{% for category in site.categories %}
{% assign skip = false %}
{% for stay in stay_on_top %}
{% if category[0] == stay %}
{% assign skip = true %}
{% endif %}
{% endfor %}
{% if skip %}
{% continue %}
{% endif %}
{% for label in site.collections_order %}
{% assign collection = site.collections | where: "label", label | first %}
<li>
<a href="#{{ category[0] | slugify }}">
<strong>{{ category[0] }}</strong> <span class="taxonomy__count">{{ i }}</span>
<a href="#{{ collection.label | slugify | downcase }}">
<strong>{{ collection.name }}</strong> <span class="taxonomy__count">{{ i }}</span>
</a>
</li>
{% endfor %}
</ul>
{% assign entries_layout = page.entries_layout | default: 'list' %}
{% for category in site.categories %}
{% for stay in stay_on_top %}
{% if category[0] == stay %}
<section id="{{ category[0] | slugify | downcase }}" class="taxonomy__section">
<h2 class="archive__subtitle">{{ category[0] }}</h2>
<div class="entries-{{ entries_layout }}">
{% for post in category.last %}
{% include archive-single.html type=entries_layout %}
{% endfor %}
</div>
<a href="#page-title" class="back-to-top">{{ site.data.ui-text[site.locale].back_to_top | default: 'Back to Top' }} &uarr;</a>
</section>
{% endif %}
{% endfor %}
{% endfor %}
{% for category in site.categories %}
{% assign skip = false %}
{% for stay in stay_on_top %}
{% if category[0] == stay %}
{% assign skip = true %}
{% endif %}
{% endfor %}
{% if skip %}
{% continue %}
{% endif %}
<section id="{{ category[0] | slugify | downcase }}" class="taxonomy__section">
<h2 class="archive__subtitle">{{ category[0] }}</h2>
{% for label in site.collections_order %}
{% assign collection = site.collections | where: "label", label | first %}
<section id="{{ collection.label | slugify | downcase }}" class="taxonomy__section">
<h2 class="archive__subtitle">{{ collection.name }}</h2>
<div class="entries-{{ entries_layout }}">
{% for post in category.last %}
{% include archive-single.html type=entries_layout %}
{% comment %} First, render ordered pages {% endcomment %}
{% assign ordered_post = "" | split: "" %}
{% if collection.order %}
{% for file in collection.order %}
{% assign docpath = "_" | append: collection.label | append: "/" | append: file %}
{% assign post = collection.docs | where: "path", docpath | first %}
{% if post %}
{% include archive-single.html type=entries_layout %}
{% assign ordered_post = ordered_post | push: docpath %}
{% else %}
<p style="color: #ff0000; font-weight: bolder">{{docpath}} not found!</p>
{% endif %}
{% endfor %}
{% endif %}
{% comment %} Second, render pages not listed in the order array {% endcomment %}
{% for post in collection.docs %}
{% assign already_rendered = ordered_post | where_exp: "path", "path == post.path" | size %}
{% if already_rendered == 0 %}
{% include archive-single.html type=entries_layout %}
{% endif %}
{% endfor %}
</div>
<a href="#page-title" class="back-to-top">{{ site.data.ui-text[site.locale].back_to_top | default: 'Back to Top' }} &uarr;</a>

76
_layouts/tags.html Normal file
View File

@ -0,0 +1,76 @@
---
layout: archive
---
{{ content }}
{% assign unique_tags = "" | split: "" %}
{% assign nested_docs = site.collections | map: "docs" %}
{% assign docs = "" | split: "" %}
{% for doc in nested_docs %}
{% assign docs = docs | concat: doc %}
{% endfor %}
{% assign found_tags = docs | map: "tags" %}
{% for tags in found_tags %}
{% assign all_tags = all_tags | concat: tags %}
{% endfor %}
{% assign unique_tags = all_tags | uniq %}
{% assign tags_count = "" | split: "" %}
{% assign tagged_docs = "" | split: "" %}
{% assign tags_max = 0 %}
{% for tag in unique_tags %}
{% comment %} Count the number of tag occurrence in all docs {% endcomment %}
{% assign count = 0 %}
{% for t in all_tags %}
{% if t == tag %}
{% assign count = count | plus: 1 %}
{% endif %}
{% endfor %}
{% assign tags_count = tags_count | push: count %}
{% comment %} Group docs by tags {% endcomment %}
{% assign found = docs | where_exp: "item", "item.tags contains tag" %}
{% assign tagged_docs = tagged_docs | push: found %}
{% if count > tags_max %}
{% assign tags_max = count %}
{% endif %}
{% endfor %}
<ul class="taxonomy__index">
{% for i in (1..tags_max) reversed %}
{% for tag in unique_tags %}
{% if tags_count[forloop.index0] == i %}
<li>
<a href="#{{ tag | slugify | downcase }}">
<strong>{{ tag }}</strong> <span class="taxonomy__count">{{ i }}</span>
</a>
</li>
{% endif %}
{% endfor %}
{% endfor %}
</ul>
{% assign entries_layout = page.entries_layout | default: 'list' %}
{% for i in (1..tags_max) reversed %}
{% for tag in unique_tags %}
{% if tags_count[forloop.index0] == i %}
<section id="{{ tag | slugify | downcase }}" class="taxonomy__section">
<h2 class="archive__subtitle">{{ tag }}</h2>
<div class="entries-{{ entries_layout }}">
{% for post in tagged_docs[forloop.index0] %}
{% include archive-single.html type=entries_layout %}
{% endfor %}
</div>
<a href="#page-title" class="back-to-top">{{ site.data.ui-text[site.locale].back_to_top | default: 'Back to Top' }} &uarr;</a>
</section>
{% endif %}
{% endfor %}
{% endfor %}

View File

@ -75,4 +75,4 @@ Linuxのカーネルの準備ができたら、カーネルの上で動くアプ
+ 52 apt install -y fbterm uim-fep uim-mozc
```
[SD カードへのコピー](/linux/linux-copy-sd-card/)に続く…
[SD カードへのコピー](/build/copy-sd-card/)に続く…

View File

@ -56,4 +56,4 @@ git clone --recursive https://github.com/brain-hackers/buildbrain.git
5. `make nk.bin` を実行します
[Linux のビルド](/linux/linux-build/)に続く…
[Linux のビルド](/build/linux/)に続く…

View File

@ -11,13 +11,6 @@ excerpt: タッチパネルのキャリブレーションBrainux に同梱さ
---
# 事前に
Xorgの設定ファイル ( xorg.conf )を設定していない場合は、下記のWikiを参照して設定してください。
[Xorg](/linux/linux-xorg/)
# 必要なパッケージのインストール
```sh

View File

@ -8,8 +8,8 @@
"textlint-rule-prh": "^5.3.0"
},
"scripts": {
"textlint": "textlint '_posts/*'",
"textlint-fix": "textlint --fix '_posts/*'",
"mdlint": "./node_modules/markdownlint-cli/markdownlint.js _posts"
"textlint": "textlint 'collections/**/*'",
"textlint-fix": "textlint --fix 'collections/**/*'",
"mdlint": "./node_modules/markdownlint-cli/markdownlint.js collections/**/*"
}
}