From 41df0128d69b344050ef12f2dcd884e635a3299f Mon Sep 17 00:00:00 2001 From: Serghei Iakovlev Date: Tue, 31 May 2022 09:35:31 +0200 Subject: Add tagging support --- CHANGELOG.md | 12 +- assets/sass/_customize.scss | 136 +++++++++++++++++++++ i18n/en.toml | 3 + i18n/ru.toml | 3 + layouts/_default/list.html | 23 ++++ layouts/_default/list.html.html | 24 ---- layouts/_default/single.html | 4 + layouts/_default/term.html | 26 ++++ layouts/partials/post-meta/date.html | 21 ++-- layouts/partials/post-tags.html | 9 ++ layouts/partials/title.html | 2 + ...e.scss_f300667da4f5b5f84e1a9e0702b2fdde.content | 117 ++++++++++++++++++ 12 files changed, 342 insertions(+), 38 deletions(-) create mode 100644 layouts/_default/list.html delete mode 100644 layouts/_default/list.html.html create mode 100644 layouts/_default/term.html create mode 100644 layouts/partials/post-tags.html diff --git a/CHANGELOG.md b/CHANGELOG.md index 9e491a3..2c9da82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,13 +9,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Provide ability to include custom scripts in the theme. -- Provide ability to specify custom language of a post. +- Provide ability to include custom scripts in the theme +- Provide ability to specify custom language of a post +- Add tagging support ### Changed -- Mior reformatting of posts layout. -- Allow to manually override lastmod date of a post. +- Minor reformatting of posts layout +- Allow manually override lastmod date of a post +- Check that `lastmod` exists and is greater than `date` before printing it ## [v0.2.0](https://github.com/sergeyklay/gohugo-theme-ed/compare/v0.1.0...v0.2.0) @@ -43,7 +45,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fix margin bottom on the nested unordered lists for page's table of contents - Fix default section type for the `params.mainSections` configuration variable -- Fix url to sitemap in robots.txt file +- Fix url to sitemap in `robots.txt` file ## v0.1.0 - 2022-05-27 diff --git a/assets/sass/_customize.scss b/assets/sass/_customize.scss index 79d3aae..5eb978a 100644 --- a/assets/sass/_customize.scss +++ b/assets/sass/_customize.scss @@ -139,3 +139,139 @@ ul.pager li { margin-bottom: 1rem; display: inline-block; } + +.post-tags-wrapper { + position: relative; +} + +.post-tags { + margin: 0; + padding: 0; + position: absolute; + right: 24px; + bottom: -12px; + list-style: none; +} + +.post-tags li, +.post-tags a { + font-family: $heading-font; + float: left; + height: 24px; + line-height: 24px; + position: relative; + font-size: .75em; +} + +.post-tags a { + margin-left: 20px; + padding: 0 10px 0 12px; + background: $link-color; + color: #fff; + text-decoration: none; + -webkit-border-bottom-right-radius:4px; + -moz-border-radius-bottomright:4px; + border-bottom-right-radius:4px; + -webkit-border-top-right-radius:4px; + -moz-border-radius-topright:4px; + border-top-right-radius:4px; +} + +.post-tags a:before { + content: ""; + float: left; + position: absolute; + top: 0; + left: -12px; + width: 0; + height: 0; + border-color: transparent $link-color transparent transparent; + border-style: solid; + border-width: 12px 12px 12px 0; +} + +.post-tags a:after { + content: ""; + position: absolute; + top: 10px; + left: 0; + float: left; + width: 4px; + height: 4px; + background: #fff; + @include border-radius (2px); + @include box-shadow (-1px -1px 2px $text-color); +} + +.post-tags a:hover { + background: $text-light-color; +} + +.post-tags a:hover:before { + border-color: transparent $text-light-color transparent transparent; +} + +/* Themes */ + +/* Red */ +.theme-base-red .post-tags a { + background: #ac4142; +} + +.theme-base-red .post-tags a:before { + border-color: transparent #ac4142 transparent transparent; +} + +/* Orange */ +.theme-base-orange .post-tags a { + background: #d28445; +} + +.theme-base-orange .post-tags a:before { + border-color: transparent #d28445 transparent transparent; +} + +/* Green */ +.theme-base-green .post-tags a { + background: #90a959; +} + +.theme-base-green .post-tags a:before { + border-color: transparent #90a959 transparent transparent; +} + +/* Cyan */ +.theme-base-cyan .post-tags a { + background: #75b5aa; +} + +.theme-base-cyan .post-tags a:before { + border-color: transparent #75b5aa transparent transparent; +} + +/* Blue */ +.theme-base-blue .post-tags a { + background: #6a9fb5; +} + +.theme-base-blue .post-tags a:before { + border-color: transparent #6a9fb5 transparent transparent; +} + +/* Magenta */ +.theme-base-magenta .post-tags a { + background: #aa759f; +} + +.theme-base-magenta .post-tags a:before { + border-color: transparent #aa759f transparent transparent; +} + +/* Brown */ +.theme-base-brown .post-tags a { + background: #8f5536; +} + +.theme-base-brown .post-tags a:before { + border-color: transparent #8f5536 transparent transparent; +} diff --git a/i18n/en.toml b/i18n/en.toml index bc92d51..82cd7fa 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -42,3 +42,6 @@ [all_publications] other = 'All publications' + +[publications_tagged] + other = 'Publications tagged "{{ . }}"' diff --git a/i18n/ru.toml b/i18n/ru.toml index 2598df1..10c815a 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -42,3 +42,6 @@ [all_publications] other = 'Все публикации' + +[publications_tagged] + other = 'Публикации с тегом "{{ . }}"' diff --git a/layouts/_default/list.html b/layouts/_default/list.html new file mode 100644 index 0000000..0dd32b6 --- /dev/null +++ b/layouts/_default/list.html @@ -0,0 +1,23 @@ +{{ define "main" }} + +
+ {{ with .Title }}

{{ . }}

{{ end }} + + {{/* Render category content if any */}} + {{ with .Content }} +
+ {{ .Content }} +
+ {{ end }} + + {{/* Render posts list */}} +
+ {{ range .Paginator.Pages }} + {{ .Render "teaser" }} + {{ end }} + + {{- partial "pagination.html" . -}} +
+
+ +{{ end }} diff --git a/layouts/_default/list.html.html b/layouts/_default/list.html.html deleted file mode 100644 index fc39714..0000000 --- a/layouts/_default/list.html.html +++ /dev/null @@ -1,24 +0,0 @@ -{{ define "main" }} - -
- {{/* Render category name if any */}} - {{ with .Title }}

{{ . }}

{{ end }} - - {{/* Render category content if any */}} - {{ with .Content }} -
- {{ .Content }} -
- {{ end }} - - {{/* Render posts list */}} -
- {{ range .Paginator.Pages }} - {{ .Render "teaser" }} - {{ end }} - - {{- partial "pagination.html" . -}} -
-
- -{{ end }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 6b2c851..56557e5 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -13,5 +13,9 @@
{{ .Content }}
+ +
+ {{ partial "post-tags.html" . }} +
{{ end }} diff --git a/layouts/_default/term.html b/layouts/_default/term.html new file mode 100644 index 0000000..6ad5d40 --- /dev/null +++ b/layouts/_default/term.html @@ -0,0 +1,26 @@ +{{ define "main" }} + +
+ {{/* TODO: Translate me */}} +

+ {{ with .Title }}{{ i18n "publications_tagged" . }}{{ end }} +

+ + {{/* Render category content if any */}} + {{ with .Content }} +
+ {{ .Content }} +
+ {{ end }} + + {{/* Render posts list */}} +
+ {{ range .Paginator.Pages }} + {{ .Render "teaser" }} + {{ end }} + + {{- partial "pagination.html" . -}} +
+
+ +{{ end }} diff --git a/layouts/partials/post-meta/date.html b/layouts/partials/post-meta/date.html index 04a814a..e5626cf 100644 --- a/layouts/partials/post-meta/date.html +++ b/layouts/partials/post-meta/date.html @@ -1,11 +1,14 @@ -{{ if not .Date.IsZero }} - +{{ $date := .Date | time.Format (site.Params.dateformat | default "January 02, 2006") }} +{{ $lastmod := .Lastmod | time.Format (site.Params.dateformat | default "January 02, 2006") }} + + - {{ if ne .Date .Lastmod }} - - {{ end }} +{{/* Check that lastmod exists and is greater than date + (i.e. the last modified date must be after the publish date) */}} +{{ if and (ne $lastmod $date) (gt .Lastmod .Date) }} + {{ end }} diff --git a/layouts/partials/post-tags.html b/layouts/partials/post-tags.html new file mode 100644 index 0000000..1fa1c96 --- /dev/null +++ b/layouts/partials/post-tags.html @@ -0,0 +1,9 @@ +{{ $tags := .Params.Tags | default slice }} + + diff --git a/layouts/partials/title.html b/layouts/partials/title.html index 76cfb2f..b3754ba 100644 --- a/layouts/partials/title.html +++ b/layouts/partials/title.html @@ -1,5 +1,7 @@ {{- if or .IsHome (eq .Title site.Title) -}} {{- site.Title -}} +{{- else if and (eq .Kind "term") (eq .Data.Singular "tag") -}} + {{- with .Title }}{{ i18n "publications_tagged" . }} - {{ end }}{{ site.Title -}} {{- else -}} {{- with .Title }}{{ . }} - {{ end }}{{ site.Title -}} {{- end -}} diff --git a/resources/_gen/assets/scss/sass/style.scss_f300667da4f5b5f84e1a9e0702b2fdde.content b/resources/_gen/assets/scss/sass/style.scss_f300667da4f5b5f84e1a9e0702b2fdde.content index 30e82bc..856b58b 100644 --- a/resources/_gen/assets/scss/sass/style.scss_f300667da4f5b5f84e1a9e0702b2fdde.content +++ b/resources/_gen/assets/scss/sass/style.scss_f300667da4f5b5f84e1a9e0702b2fdde.content @@ -970,3 +970,120 @@ ul.pager li { .footnotes blockquote + a.footnote-backref { margin-bottom: 1rem; display: inline-block; } + +.post-tags-wrapper { + position: relative; } + +.post-tags { + margin: 0; + padding: 0; + position: absolute; + right: 24px; + bottom: -12px; + list-style: none; } + +.post-tags li, +.post-tags a { + font-family: sans-serif; + float: left; + height: 24px; + line-height: 24px; + position: relative; + font-size: .75em; } + +.post-tags a { + margin-left: 20px; + padding: 0 10px 0 12px; + background: #841212; + color: #fff; + text-decoration: none; + -webkit-border-bottom-right-radius: 4px; + -moz-border-radius-bottomright: 4px; + border-bottom-right-radius: 4px; + -webkit-border-top-right-radius: 4px; + -moz-border-radius-topright: 4px; + border-top-right-radius: 4px; } + +.post-tags a:before { + content: ""; + float: left; + position: absolute; + top: 0; + left: -12px; + width: 0; + height: 0; + border-color: transparent #841212 transparent transparent; + border-style: solid; + border-width: 12px 12px 12px 0; } + +.post-tags a:after { + content: ""; + position: absolute; + top: 10px; + left: 0; + float: left; + width: 4px; + height: 4px; + background: #fff; + -webkit-border-radius: 2px; + -moz-border-radius: 2px; + border-radius: 2px; + -webkit-box-shadow: -1px -1px 2px #454545; + -moz-box-shadow: -1px -1px 2px #454545; + box-shadow: -1px -1px 2px #454545; } + +.post-tags a:hover { + background: #676767; } + +.post-tags a:hover:before { + border-color: transparent #676767 transparent transparent; } + +/* Themes */ +/* Red */ +.theme-base-red .post-tags a { + background: #ac4142; } + +.theme-base-red .post-tags a:before { + border-color: transparent #ac4142 transparent transparent; } + +/* Orange */ +.theme-base-orange .post-tags a { + background: #d28445; } + +.theme-base-orange .post-tags a:before { + border-color: transparent #d28445 transparent transparent; } + +/* Green */ +.theme-base-green .post-tags a { + background: #90a959; } + +.theme-base-green .post-tags a:before { + border-color: transparent #90a959 transparent transparent; } + +/* Cyan */ +.theme-base-cyan .post-tags a { + background: #75b5aa; } + +.theme-base-cyan .post-tags a:before { + border-color: transparent #75b5aa transparent transparent; } + +/* Blue */ +.theme-base-blue .post-tags a { + background: #6a9fb5; } + +.theme-base-blue .post-tags a:before { + border-color: transparent #6a9fb5 transparent transparent; } + +/* Magenta */ +.theme-base-magenta .post-tags a { + background: #aa759f; } + +.theme-base-magenta .post-tags a:before { + border-color: transparent #aa759f transparent transparent; } + +/* Brown */ +.theme-base-brown .post-tags a { + background: #8f5536; } + +.theme-base-brown .post-tags a:before { + border-color: transparent #8f5536 transparent transparent; } -- cgit v1.2.3