From 57c3b364eb035cbfe968d170a19372f884d63f24 Mon Sep 17 00:00:00 2001 From: "wh.huajieyu" Date: Tue, 14 May 2024 10:58:16 +0800 Subject: [PATCH] add tag page --- _config.yml | 5 ++++- _includes/back_link.html | 2 +- _includes/collecttags.html | 18 ++++++++++++++++++ _includes/head.html | 4 +++- _layouts/post.html | 7 +++++++ _layouts/tag.html | 15 +++++++++++++++ api/post.json | 15 +++++++++++++++ api/tags.json | 9 +++++++++ generateTag.py | 27 +++++++++++++++++++++++++++ tag/Firefox.md | 5 +++++ tag/algorithm.md | 5 +++++ tag/binary_tree.md | 5 +++++ tag/blog.md | 5 +++++ tag/clipboard.md | 5 +++++ tag/debugger.md | 5 +++++ tag/git.md | 5 +++++ tag/html2canvas.md | 5 +++++ tag/linklist.md | 5 +++++ tag/pnpm.md | 5 +++++ tag/prime.md | 5 +++++ tag/quick_sort.md | 5 +++++ tag/safearea.md | 5 +++++ tag/shortest_path.md | 5 +++++ tag/vscode.md | 5 +++++ 24 files changed, 174 insertions(+), 3 deletions(-) create mode 100644 _includes/collecttags.html create mode 100644 _layouts/tag.html create mode 100644 api/post.json create mode 100644 api/tags.json create mode 100644 generateTag.py create mode 100644 tag/Firefox.md create mode 100644 tag/algorithm.md create mode 100644 tag/binary_tree.md create mode 100644 tag/blog.md create mode 100644 tag/clipboard.md create mode 100644 tag/debugger.md create mode 100644 tag/git.md create mode 100644 tag/html2canvas.md create mode 100644 tag/linklist.md create mode 100644 tag/pnpm.md create mode 100644 tag/prime.md create mode 100644 tag/quick_sort.md create mode 100644 tag/safearea.md create mode 100644 tag/shortest_path.md create mode 100644 tag/vscode.md diff --git a/_config.yml b/_config.yml index ec4cb72..cea13ea 100644 --- a/_config.yml +++ b/_config.yml @@ -36,6 +36,9 @@ collections: category: output: true permalink: /category/:slug/ + tag: + output: true + permalink: /tag/:tag/ #baseurl: "" # permalink: /blog/:slug @@ -53,7 +56,7 @@ About: /about # Add general links to site pages here links: Resume: /assets/resume.pdf - + # Add links for more focus here special_links: diff --git a/_includes/back_link.html b/_includes/back_link.html index b863ef2..3032051 100644 --- a/_includes/back_link.html +++ b/_includes/back_link.html @@ -1 +1 @@ -{{ site.theme_config.back_home_text }} \ No newline at end of file +{{ site.theme_config.back_home_text }} diff --git a/_includes/collecttags.html b/_includes/collecttags.html new file mode 100644 index 0000000..0f187e5 --- /dev/null +++ b/_includes/collecttags.html @@ -0,0 +1,18 @@ +{% assign rawtags = "" %} +{% for post in site.posts %} + {% assign ttags = post.tags | join:'|' | append:'|' %} + {% assign rawtags = rawtags | append:ttags %} +{% endfor %} +{% assign rawtags = rawtags | split:'|' | sort %} + +{% assign site.tags = "" %} +{% for tag in rawtags %} + {% if tag != "" %} + {% if tags == "" %} + {% assign tags = tag | split:'|' %} + {% endif %} + {% unless tags contains tag %} + {% assign tags = tags | join:'|' | append:'|' | append:tag | split:'|' %} + {% endunless %} + {% endif %} +{% endfor %} diff --git a/_includes/head.html b/_includes/head.html index 9806387..1ebc326 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -17,5 +17,7 @@ - + {% if site.tags != "" %} + {% include collecttags.html %} + {% endif %} diff --git a/_layouts/post.html b/_layouts/post.html index 8ee6a18..adfdb55 100644 --- a/_layouts/post.html +++ b/_layouts/post.html @@ -16,6 +16,13 @@

{{ page.title }}

{{ content }} +Tags: [ + {% for tag in page.tags %} + {% capture tag_name %}{{ tag }}{% endcapture %} + {{ tag_name }}  + {% endfor %} +] +