From 05bee3c8787340df084848345c53b4537b28d968 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Mon, 27 Dec 2021 19:35:42 -0500
Subject: [PATCH] add taxonomy and term lists

---
 assets/base.scss                | 93 +++++++++++++++++++++++++++------
 config.toml                     |  3 +-
 layouts/_default/section.html   | 16 +-----
 layouts/_default/single.html    |  5 ++
 layouts/_default/taxonomy.html  | 33 ++++++++++++
 layouts/_default/term.html      | 24 +++++++++
 layouts/partials/page-list.html | 15 ++++++
 7 files changed, 157 insertions(+), 32 deletions(-)
 create mode 100644 layouts/_default/taxonomy.html
 create mode 100644 layouts/_default/term.html
 create mode 100644 layouts/partials/page-list.html

diff --git a/assets/base.scss b/assets/base.scss
index 571ca22..c4447ee 100644
--- a/assets/base.scss
+++ b/assets/base.scss
@@ -108,25 +108,86 @@ td, th {
   margin: 0.5em 0;
 }
 
+.pagination {
+  list-style: none;
+  padding-left: 0;
+  display: flex;
+  margin-top: 2em;
+  gap: 1.5em;
+  justify-content: center;
+
+  & > li {
+    text-align: center;
+    display: inline-block;
+
+    & a {
+      background-color: transparent !important;
+    }
+
+    & a[href$="#"] {
+      opacity: 0.2;
+    }
+  }
+}
+
+.section {
+  & h3 > a {
+    font-weight: 700;
+    font-family: Inter;
+    margin: 0;
+  }
+  & p {
+    margin-top: 0;
+  }
+}
+
 article {
- & > .meta {
-   margin: -1.5em 0 1em 0;
-   opacity: 0.7;
- }
+  & > .meta {
+    margin: -1.5em 0 1em 0;
+    opacity: 0.7;
+  }
 
- & a {
-   font-family: Source Sans Pro;
-   font-weight: 600;
+  & > .tags {
+    list-style: none;
+    padding-left: 0;
 
-   // internal link
-   &[href^="./"], &[href^="/"] {
-     text-decoration: none;
-     background-color: transparentize(#8f9fa9, 0.85);
-     padding: 0 0.1em;
-     margin: auto -0.1em;
-     border-radius: 3px;
-   }
- }
+    & .meta {
+      & > h1 {
+        margin: 0;
+      }
+      & > p {
+        margin: 0;
+      }
+    }
+
+    & > li {
+      display: inline-block;
+    }
+    & > li > a {
+      border-radius: 8px;
+      border: var(--outlinegray) 1px solid;
+      padding: 0.2em 0.5em;
+      &::before {
+        content: "#";
+        margin-right: 0.3em;
+        color: var(--outlinegray);
+      }
+    }
+  }
+
+  & a {
+    font-family: Source Sans Pro;
+    font-weight: 600;
+
+    // internal link
+    &[href^="./"], &[href^="/"] {
+      text-decoration: none;
+      background-color: transparentize(#8f9fa9, 0.85);
+      padding: 0 0.1em;
+      margin: auto -0.1em;
+      border-radius: 3px;
+    }
+  }
 }
 
 .backlinks a {
diff --git a/config.toml b/config.toml
index a0d71f7..5c4dfcb 100644
--- a/config.toml
+++ b/config.toml
@@ -8,7 +8,8 @@ ignoreFiles = [
     "/content/templates/*",
     "/content/private/*",
 ]
-summaryLength = 35
+summaryLength = 20
+paginate = 10
 enableGitInfo = true
 
 [markup]
diff --git a/layouts/_default/section.html b/layouts/_default/section.html
index 286eb02..3b9741e 100644
--- a/layouts/_default/section.html
+++ b/layouts/_default/section.html
@@ -14,21 +14,7 @@
     </header>
     <article>
         <h1>All {{.Title}}</h1>
-        <ul class="section-ul">
-            {{- range .Pages.ByLastmod.Reverse -}}
-            <li class="section-li">
-                <div class="section">
-                    <div class="desc">
-                        <h3><a href="{{ .Permalink }}">{{- .Title -}}</a></h3>
-                        <p>{{- .Summary -}}{{if .Truncated}}...{{end}}</p>
-                    </div>
-                    <p class="meta">
-                        {{ .ReadingTime }} minute read. Last updated {{if ne .Date .Lastmod}}{{ .Lastmod.Format "January 2, 2006" }}{{else}}Unknown{{end}}
-                    </p>
-                </div>
-            </li>
-            {{- end -}}
-        </ul>
+        {{partial "page-list.html" .Pages.ByLastmod.Reverse }}
     </article>
     {{partial "contact.html" .}}
 </div>
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index fd061e5..a84ec91 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -17,6 +17,11 @@
       <p class="meta">
           Last updated {{if ne .Date .Lastmod}}{{ .Lastmod.Format "January 2, 2006" }}{{else}}Unknown{{end}}
       </p>
+      <ul class="tags">
+          {{ range (.GetTerms "tags") }}
+          <li><a href="{{ .Permalink }}">{{ .LinkTitle | humanize }}</a></li>
+          {{ end }}
+      </ul>
       {{if $.Site.Data.config.enableToc}}
       <aside class="mainTOC">
           <h3>Table of Contents</h3>
diff --git a/layouts/_default/taxonomy.html b/layouts/_default/taxonomy.html
new file mode 100644
index 0000000..45a713a
--- /dev/null
+++ b/layouts/_default/taxonomy.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html lang="en">
+{{ partial "head.html" . }}
+
+<body>
+{{partial "search.html" .}}
+<div class="singlePage">
+    <!-- Begin actual content -->
+    <header>
+        <h1 id="page-title"><a href="{{ .Site.BaseURL }}">{{ .Site.Data.config.page_title }}</a></h1>
+        <svg tabindex="0" id="search-icon" aria-labelledby="title desc" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19.9 19.7"><title id="title">Search Icon</title><desc id="desc">Icon to open search</desc><g class="search-path" fill="none"><path stroke-linecap="square" d="M18.5 18.3l-5.4-5.4"/><circle cx="8" cy="8" r="7"/></g></svg>
+        <div class="spacer"></div>
+        {{partial "darkmode.html" .}}
+    </header>
+    <article>
+        <h1>All {{.Title}}</h1>
+        <div class="tags">
+            {{ range .Site.Taxonomies.tags.ByCount }}
+            <div class="meta">
+                <h1><a href="{{ .Page.Permalink }}">{{ .Page.Title | humanize }}</a></h1>
+                <p><b>{{ .Count }}</b> notes with this tag {{if gt .Count 2}}(showing first 2 results){{end}}</p>
+            </div>
+            {{ with ($.Site.GetPage (printf "/tags/%s" .Page.Title)) }}
+            {{partial "page-list.html" (first 2 .Pages.ByLastmod.Reverse)}}
+            {{ end }}
+            {{ end }}
+        </div>
+    </article>
+    {{partial "contact.html" .}}
+</div>
+</body>
+
+</html>
diff --git a/layouts/_default/term.html b/layouts/_default/term.html
new file mode 100644
index 0000000..fd01425
--- /dev/null
+++ b/layouts/_default/term.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<html lang="en">
+{{ partial "head.html" . }}
+
+<body>
+{{partial "search.html" .}}
+<div class="singlePage">
+    <!-- Begin actual content -->
+    <header>
+        <h1 id="page-title"><a href="{{ .Site.BaseURL }}">{{ .Site.Data.config.page_title }}</a></h1>
+        <svg tabindex="0" id="search-icon" aria-labelledby="title desc" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 19.9 19.7"><title id="title">Search Icon</title><desc id="desc">Icon to open search</desc><g class="search-path" fill="none"><path stroke-linecap="square" d="M18.5 18.3l-5.4-5.4"/><circle cx="8" cy="8" r="7"/></g></svg>
+        <div class="spacer"></div>
+        {{partial "darkmode.html" .}}
+    </header>
+    <article>
+        <h1>Category: {{.Title | humanize}}</h1>
+        {{partial "page-list.html" .Paginator.Pages}}
+        {{ template "_internal/pagination.html" . }}
+    </article>
+    {{partial "contact.html" .}}
+</div>
+</body>
+
+</html>
diff --git a/layouts/partials/page-list.html b/layouts/partials/page-list.html
new file mode 100644
index 0000000..bdfcd59
--- /dev/null
+++ b/layouts/partials/page-list.html
@@ -0,0 +1,15 @@
+<ul class="section-ul">
+    {{- range . -}}
+    <li class="section-li">
+        <div class="section">
+            <div class="desc">
+                <h3><a href="{{ .Permalink }}">{{- .Title -}}</a></h3>
+                <p>{{- .Summary -}}{{if .Truncated}}...{{end}}</p>
+            </div>
+            <p class="meta">
+                {{ .ReadingTime }} minute read. Last updated {{if ne .Date .Lastmod}}{{ .Lastmod.Format "January 2, 2006" }}{{else}}Unknown{{end}}
+            </p>
+        </div>
+    </li>
+    {{- end -}}
+</ul>
\ No newline at end of file