summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReorx <novoreorx@gmail.com>2022-09-08 23:17:43 +0800
committerReorx <novoreorx@gmail.com>2022-09-08 23:36:35 +0800
commit886aafac1f1fbdee64537938fa906c3dacb516eb (patch)
tree8373af942cf1f6ef4d60f13e43c434d4bd230bc5
parentae58c91ac49e822fd2cf8c5aa1b36cea0f8470ee (diff)
inline_links partial
finally find a way to determine whether a section/term page has archives or not by conquering hugo's faultiness of .RelPermalink
-rw-r--r--assets/css/common/main.css8
-rw-r--r--exampleSite/content/docs/archives.md5
-rw-r--r--layouts/_default/list.html15
-rw-r--r--layouts/newsletter/section.html9
-rw-r--r--layouts/partials/inline_links.html11
5 files changed, 31 insertions, 17 deletions
diff --git a/assets/css/common/main.css b/assets/css/common/main.css
index 893081f..8c21290 100644
--- a/assets/css/common/main.css
+++ b/assets/css/common/main.css
@@ -100,6 +100,12 @@ mark {
box-shadow: var(--link-hover-underline-shadow);
}
+.inline-links span:not(:last-of-type):after {
+ content: "·";
+ margin-inline-start: .5em;
+ margin-inline-end: .5em;
+}
+
/* for post page */
.main.post {
@@ -108,6 +114,8 @@ mark {
.page-header h1 {
font-size: 40px;
+ margin-bottom: var(--content-gap);
+ text-transform: capitalize;
}
.pagination {
diff --git a/exampleSite/content/docs/archives.md b/exampleSite/content/docs/archives.md
new file mode 100644
index 0000000..8ebc9d2
--- /dev/null
+++ b/exampleSite/content/docs/archives.md
@@ -0,0 +1,5 @@
+---
+title: "Docs Archives"
+layout: archives
+hidden: true
+---
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
index 654297b..7dce17b 100644
--- a/layouts/_default/list.html
+++ b/layouts/_default/list.html
@@ -7,20 +7,17 @@
{{- if not .IsHome | and .Title }}
<header class="page-header">
{{- partial "breadcrumbs.html" . }}
- <h1>{{ .Title }}</h1>
+ <h1>
+ {{/* see: https://gohugo.io/variables/taxonomy/#taxonomy-terms-page-variables */}}
+ {{- if eq .Kind "term" -}}{{- .Data.Singular }}: {{ end -}}
+ {{ .Title -}}
+ </h1>
{{- if .Description }}
<div class="post-description">
{{ .Description | markdownify }}
</div>
{{- end }}
- <div class="inline-links">
- {{- with .Param "archivesSlug" }}
- <a href="{{ $.RelPermalink }}{{ . }}/">Archives</a>
- {{- end }}
- {{ with .OutputFormats.Get "rss" -}}
- • <a href="{{ .Permalink }}" target="_blank">RSS</a>
- {{ end -}}
- </div>
+ {{- partial "inline_links.html" . -}}
</header>
{{- end }}
diff --git a/layouts/newsletter/section.html b/layouts/newsletter/section.html
index 04c3eed..7814708 100644
--- a/layouts/newsletter/section.html
+++ b/layouts/newsletter/section.html
@@ -37,14 +37,7 @@
{{ end }}
<h2>相关链接</h2>
- <div class="inline-links">
- {{- with .Param "archivesSlug" }}
- <a href="{{ $.RelPermalink }}{{ . }}/">Archives</a>
- {{- end }}
- {{ with .OutputFormats.Get "rss" -}}
- • <a href="{{ .Permalink }}" target="_blank">RSS</a>
- {{ end -}}
- </div>
+ {{- partial "inline_links.html" . -}}
</div>
{{ end }}
diff --git a/layouts/partials/inline_links.html b/layouts/partials/inline_links.html
new file mode 100644
index 0000000..72e4af2
--- /dev/null
+++ b/layouts/partials/inline_links.html
@@ -0,0 +1,11 @@
+<div class="inline-links">
+ {{/* use `.GetPage "archives"` causes term page to get the root archives */}}
+ {{/* trim relURL prefix because .RelPermalink includes the path of base url */}}
+ {{ $archivesPath := printf "/%sarchives" (strings.TrimPrefix (relURL "") .RelPermalink) }}
+ {{- with .GetPage $archivesPath -}}
+ <span><a href="{{ .RelPermalink }}">Archives</a></span>
+ {{- end -}}
+ {{- with .OutputFormats.Get "rss" -}}
+ <span><a href="{{ .Permalink }}" target="_blank">RSS</a></span>
+ {{- end -}}
+</div>