From 9927d52aebc5a575f0bb1b73ecfc43c75862886e Mon Sep 17 00:00:00 2001 From: Takumi Sueda Date: Mon, 12 Dec 2022 22:13:06 +0900 Subject: [PATCH] Move all posts into collections and update Liquid templates --- _config.yml | 58 +++++++--- _data/navigation.yml | 4 +- _layouts/categories.html | 100 ++++++------------ _layouts/tags.html | 76 +++++++++++++ .../_beginners/get-started.md | 0 .../_beginners/roadmap.md | 0 .../_build/copy-sd-card.md | 0 .../_build/linux.md | 2 +- .../_build/uboot.md | 2 +- .../_linux/brain-config.md | 0 .../_linux/package-list.md | 0 .../_linux/xorg.md | 0 .../_meta/how-to-edit-wiki.md | 0 .../_tips/otg.md | 0 .../_tips/swap.md | 0 .../_tips/touch-panel.md | 7 -- .../_tips/usb-ethernet-gadget.md | 0 .../_tips/web-browser.md | 0 .../_u-boot/boot-eboot.md | 0 .../_u-boot/boot-usb.md | 0 package.json | 6 +- 21 files changed, 156 insertions(+), 99 deletions(-) create mode 100644 _layouts/tags.html rename _posts/2021-12-04-beginner-get-started.md => collections/_beginners/get-started.md (100%) rename _posts/2021-12-04-roadmap.md => collections/_beginners/roadmap.md (100%) rename _posts/2021-12-04-linux-copy-sd-card.md => collections/_build/copy-sd-card.md (100%) rename _posts/2021-12-04-linux-build.md => collections/_build/linux.md (97%) rename _posts/2021-12-04-u-boot-build.md => collections/_build/uboot.md (96%) rename _posts/2021-12-04-brain-config.md => collections/_linux/brain-config.md (100%) rename _posts/2021-12-04-linux-package-list.md => collections/_linux/package-list.md (100%) rename _posts/2021-12-04-linux-xorg.md => collections/_linux/xorg.md (100%) rename _posts/2021-12-04-meta-how-to-edit-wiki.md => collections/_meta/how-to-edit-wiki.md (100%) rename _posts/2021-12-04-tips-otg.md => collections/_tips/otg.md (100%) rename _posts/2021-12-04-tips-swap.md => collections/_tips/swap.md (100%) rename _posts/2021-12-04-tips-touch-panel.md => collections/_tips/touch-panel.md (92%) rename _posts/2021-12-04-tips-usb-ethernet-gadget.md => collections/_tips/usb-ethernet-gadget.md (100%) rename _posts/2021-12-04-tips-web-browser.md => collections/_tips/web-browser.md (100%) rename _posts/2021-12-04-u-boot-boot-eboot.md => collections/_u-boot/boot-eboot.md (100%) rename _posts/2021-12-04-u-boot-boot-usb.md => collections/_u-boot/boot-usb.md (100%) diff --git a/_config.yml b/_config.yml index 2149cf2..fdb5e45 100644 --- a/_config.yml +++ b/_config.yml @@ -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 diff --git a/_data/navigation.yml b/_data/navigation.yml index 086b092..d1f95b0 100644 --- a/_data/navigation.yml +++ b/_data/navigation.yml @@ -1,7 +1,7 @@ main: - title: "初めての方へ" - url: /for%20beginners/beginner-get-started/ + url: /beginners/get-started/ - title: "タグ一覧" url: /tags/ - title: "この Wiki について" - url: /about/ \ No newline at end of file + url: /about/ diff --git a/_layouts/categories.html b/_layouts/categories.html index 4dd3b40..f8dc790 100644 --- a/_layouts/categories.html +++ b/_layouts/categories.html @@ -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 %} -

カテゴリ一覧

{% assign entries_layout = page.entries_layout | default: 'list' %} -{% for category in site.categories %} - {% for stay in stay_on_top %} - {% if category[0] == stay %} -
-

{{ category[0] }}

-
- {% for post in category.last %} - {% include archive-single.html type=entries_layout %} - {% endfor %} -
- {{ site.data.ui-text[site.locale].back_to_top | default: 'Back to Top' }} ↑ -
- {% 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 %} -
-

{{ category[0] }}

+{% for label in site.collections_order %} + {% assign collection = site.collections | where: "label", label | first %} +
+

{{ collection.name }}

- {% 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 %} +

{{docpath}} not found!

+ {% 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 %}
{{ site.data.ui-text[site.locale].back_to_top | default: 'Back to Top' }} ↑ diff --git a/_layouts/tags.html b/_layouts/tags.html new file mode 100644 index 0000000..158b47d --- /dev/null +++ b/_layouts/tags.html @@ -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 %} + + +
    + {% for i in (1..tags_max) reversed %} + {% for tag in unique_tags %} + {% if tags_count[forloop.index0] == i %} +
  • + + {{ tag }} {{ i }} + +
  • + {% endif %} + {% endfor %} + {% endfor %} +
+ +{% 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 %} +
+

{{ tag }}

+
+ {% for post in tagged_docs[forloop.index0] %} + {% include archive-single.html type=entries_layout %} + {% endfor %} +
+ {{ site.data.ui-text[site.locale].back_to_top | default: 'Back to Top' }} ↑ +
+ {% endif %} + {% endfor %} +{% endfor %} diff --git a/_posts/2021-12-04-beginner-get-started.md b/collections/_beginners/get-started.md similarity index 100% rename from _posts/2021-12-04-beginner-get-started.md rename to collections/_beginners/get-started.md diff --git a/_posts/2021-12-04-roadmap.md b/collections/_beginners/roadmap.md similarity index 100% rename from _posts/2021-12-04-roadmap.md rename to collections/_beginners/roadmap.md diff --git a/_posts/2021-12-04-linux-copy-sd-card.md b/collections/_build/copy-sd-card.md similarity index 100% rename from _posts/2021-12-04-linux-copy-sd-card.md rename to collections/_build/copy-sd-card.md diff --git a/_posts/2021-12-04-linux-build.md b/collections/_build/linux.md similarity index 97% rename from _posts/2021-12-04-linux-build.md rename to collections/_build/linux.md index ea3763b..80168f9 100644 --- a/_posts/2021-12-04-linux-build.md +++ b/collections/_build/linux.md @@ -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/)に続く… diff --git a/_posts/2021-12-04-u-boot-build.md b/collections/_build/uboot.md similarity index 96% rename from _posts/2021-12-04-u-boot-build.md rename to collections/_build/uboot.md index f7f9f26..1f87621 100644 --- a/_posts/2021-12-04-u-boot-build.md +++ b/collections/_build/uboot.md @@ -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/)に続く… diff --git a/_posts/2021-12-04-brain-config.md b/collections/_linux/brain-config.md similarity index 100% rename from _posts/2021-12-04-brain-config.md rename to collections/_linux/brain-config.md diff --git a/_posts/2021-12-04-linux-package-list.md b/collections/_linux/package-list.md similarity index 100% rename from _posts/2021-12-04-linux-package-list.md rename to collections/_linux/package-list.md diff --git a/_posts/2021-12-04-linux-xorg.md b/collections/_linux/xorg.md similarity index 100% rename from _posts/2021-12-04-linux-xorg.md rename to collections/_linux/xorg.md diff --git a/_posts/2021-12-04-meta-how-to-edit-wiki.md b/collections/_meta/how-to-edit-wiki.md similarity index 100% rename from _posts/2021-12-04-meta-how-to-edit-wiki.md rename to collections/_meta/how-to-edit-wiki.md diff --git a/_posts/2021-12-04-tips-otg.md b/collections/_tips/otg.md similarity index 100% rename from _posts/2021-12-04-tips-otg.md rename to collections/_tips/otg.md diff --git a/_posts/2021-12-04-tips-swap.md b/collections/_tips/swap.md similarity index 100% rename from _posts/2021-12-04-tips-swap.md rename to collections/_tips/swap.md diff --git a/_posts/2021-12-04-tips-touch-panel.md b/collections/_tips/touch-panel.md similarity index 92% rename from _posts/2021-12-04-tips-touch-panel.md rename to collections/_tips/touch-panel.md index 2460b2c..ecafa0a 100644 --- a/_posts/2021-12-04-tips-touch-panel.md +++ b/collections/_tips/touch-panel.md @@ -11,13 +11,6 @@ excerpt: タッチパネルのキャリブレーション(Brainux に同梱さ --- -# 事前に - -Xorgの設定ファイル ( xorg.conf )を設定していない場合は、下記のWikiを参照して設定してください。 - -[Xorg](/linux/linux-xorg/) - - # 必要なパッケージのインストール ```sh diff --git a/_posts/2021-12-04-tips-usb-ethernet-gadget.md b/collections/_tips/usb-ethernet-gadget.md similarity index 100% rename from _posts/2021-12-04-tips-usb-ethernet-gadget.md rename to collections/_tips/usb-ethernet-gadget.md diff --git a/_posts/2021-12-04-tips-web-browser.md b/collections/_tips/web-browser.md similarity index 100% rename from _posts/2021-12-04-tips-web-browser.md rename to collections/_tips/web-browser.md diff --git a/_posts/2021-12-04-u-boot-boot-eboot.md b/collections/_u-boot/boot-eboot.md similarity index 100% rename from _posts/2021-12-04-u-boot-boot-eboot.md rename to collections/_u-boot/boot-eboot.md diff --git a/_posts/2021-12-04-u-boot-boot-usb.md b/collections/_u-boot/boot-usb.md similarity index 100% rename from _posts/2021-12-04-u-boot-boot-usb.md rename to collections/_u-boot/boot-usb.md diff --git a/package.json b/package.json index bd4c2fe..4254eab 100644 --- a/package.json +++ b/package.json @@ -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/**/*" } }