You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by bd...@apache.org on 2023/04/27 09:08:40 UTC
[comdev-site] 01/02: Add tag-based navigation
This is an automated email from the ASF dual-hosted git repository.
bdelacretaz pushed a commit to branch preview/tags
in repository https://gitbox.apache.org/repos/asf/comdev-site.git
commit 9ec638960c4a10cc132fba9f20a03869f1784161
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Thu Apr 27 11:07:53 2023 +0200
Add tag-based navigation
---
hugo.toml | 5 ++++-
layouts/_default/baseof.html | 1 +
layouts/_default/term.html | 11 +++++++++++
layouts/_default/terms.html | 10 ++++++++++
layouts/partials/tags.html | 11 +++++++++++
static/css/main.css | 16 ++++++++++++++++
6 files changed, 53 insertions(+), 1 deletion(-)
diff --git a/hugo.toml b/hugo.toml
index 0fe5949..cdfa76f 100644
--- a/hugo.toml
+++ b/hugo.toml
@@ -11,9 +11,12 @@ enableRobotsTXT = true
disableBrowserError = true
timeout = 3000
-disableKinds = ["taxonomy", "taxonomyTerm"]
ignoreFiles = [ ] # No files to ignore
+# Enable tags but not categories
+[taxonomies]
+tag = "tags"
+
# Highlighting config. See https://help.farbox.com/pygments.html
pygmentsCodeFences = true
pygmentsUseClasses = false
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index ba06e68..84f8917 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -158,6 +158,7 @@
</section>
{{ partial "breadcrumbs.html" . }}
<hr>
+ {{ partial "tags.html" .}}
{{ block "main" . }}{{ end }}
</div>
</main>
diff --git a/layouts/_default/term.html b/layouts/_default/term.html
new file mode 100644
index 0000000..6c5560a
--- /dev/null
+++ b/layouts/_default/term.html
@@ -0,0 +1,11 @@
+{{ define "main" }}
+<h2>Pages having the <em>{{ .Title }}</em> tag</h2>
+<p>See also the <a href="/tags.html">list of tags</a>.</p>
+<ul>
+ {{ range .Data.Pages }}
+ <li>
+ <a href="{{.RelPermalink}}">{{ .Title }}</a>
+ </li>
+ {{ end }}
+ </ul>
+{{ end }}
diff --git a/layouts/_default/terms.html b/layouts/_default/terms.html
new file mode 100644
index 0000000..744185b
--- /dev/null
+++ b/layouts/_default/terms.html
@@ -0,0 +1,10 @@
+{{ define "main" }}
+<h2>All tags</h2>
+<ul>
+ {{ range .Pages }}
+ <li>
+ <a href="{{ .Permalink }}">{{ .Title }}</a>
+ </li>
+ {{ end }}
+</ul>
+{{ end }}
diff --git a/layouts/partials/tags.html b/layouts/partials/tags.html
new file mode 100644
index 0000000..c2364e2
--- /dev/null
+++ b/layouts/partials/tags.html
@@ -0,0 +1,11 @@
+{{ $taxonomy := "tags" }} {{ with .Param $taxonomy }}
+<ul class="tags-list">
+ {{ range $index, $tag := . }}
+ {{ with $.Site.GetPage (printf "/%s/%s" $taxonomy $tag) -}}
+ <li>
+ <a href="{{ .Permalink }}">{{ $tag | urlize }}</a>
+ </li>
+ {{- end -}}
+ {{- end -}}
+</ul>
+{{ end }}
\ No newline at end of file
diff --git a/static/css/main.css b/static/css/main.css
index 87b221d..ac1025c 100644
--- a/static/css/main.css
+++ b/static/css/main.css
@@ -43,4 +43,20 @@ dt:hover > .headerlink, p:hover > .headerlink, td:hover > .headerlink, h1:hover
.published-date {
font-size: 80%;
font-style: italic;
+}
+
+ul.tags-list {
+ padding-left: 0;
+ font-size: 90%;
+ display:flex;
+ list-style-type: none;
+ flex-wrap:wrap;
+}
+
+.tags-list li {
+ margin-right:.5rem;
+ margin-top: 0.25rem;
+ padding-left: 0.25rem;
+ padding-right: 0.25rem;
+ background-color: var(--light);
}
\ No newline at end of file