Skip to content

Commit

Permalink
✨ Feat: add collection info at post meta
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Dec 6, 2023
1 parent c7a03ea commit 5d16e1a
Show file tree
Hide file tree
Showing 16 changed files with 106 additions and 36 deletions.
6 changes: 5 additions & 1 deletion i18n/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ other = "Teilen auf"
contents= "Inhalt"
repost= ""
publishedOnDate= "veröffentlicht an {{ .Date }}"
includedInCategories= "enthalten in {{ .Categories }}"
views = "Aufrufe"
comments = "Kommentare"
author = "Autor"
Expand All @@ -122,6 +121,11 @@ encryptedMessage = ""
password = "Passwort"
encryptyAgain = ""

[single.includedIn]
categories = "enthalten in {{ .Categories }}"
collections = "enthalten in {{ .Collections }}"
both = "enthalten in {{ .Categories }} und {{ .Collections }}"

[single.wordCount]
one = "Ein Wort"
other = "{{ .Count }} Wörter"
Expand Down
6 changes: 5 additions & 1 deletion i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ other = "Share on"
contents = "Contents"
repost = "Repost"
publishedOnDate = "published on {{ .Date }}"
includedInCategories = "included in {{ .Categories }}"
views = "views"
comments = "comments"
author = "Author"
Expand All @@ -121,6 +120,11 @@ encryptedMessage = "Please enter the password"
password = "Password"
encryptyAgain = "Encrypt again"

[single.includedIn]
categories = "included in {{ .Categories }}"
collections = "included in {{ .Collections }}"
both = "included in {{ .Categories }} and {{ .Collections }}"

[single.wordCount]
one = "One word"
other = "{{ .Count }} words"
Expand Down
6 changes: 5 additions & 1 deletion i18n/es.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ other = "Compartir en"
contents= "Contenido"
repost= ""
publishedOnDate= "publicado el {{ .Date }}"
includedInCategories= "incluido en {{ .Categories }}"
views = "vistas"
comments = "Comentarios"
author = "Autor"
Expand All @@ -122,6 +121,11 @@ encryptedMessage = ""
password = "Contraseña"
encryptyAgain = ""

[single.includedIn]
categories = "incluido en {{ .Categories }}"
collections = "incluido en {{ .Collections }}"
both = "incluido en {{ .Categories }} y {{ .Collections }}"

[single.wordCount]
one = "Una palabra"
other = "{{ .Count }} palabras"
Expand Down
6 changes: 5 additions & 1 deletion i18n/fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ other = "Partager via"
contents= "Contenus"
repost= "Reposter"
publishedOnDate= "publié le {{ .Date }}"
includedInCategories= "inclus dans {{ .Categories }}"
views = "vues"
comments = "commentaires"
author = "Auteur"
Expand All @@ -121,6 +120,11 @@ encryptedMessage = "Entrer le mot de passe"
password = "Mot de passe"
encryptyAgain = "Chiffrer à nouveau"

[single.includedIn]
categories = "inclus dans {{ .Categories }}"
collections = "inclus dans {{ .Collections }}"
both = "inclus dans {{ .Categories }} et {{ .Collections }}"

[single.wordCount]
one = "1 mot"
other = "{{ .Count }} mots"
Expand Down
6 changes: 5 additions & 1 deletion i18n/it.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ other = "Condividi su"
contents= "Contenuti"
repost= ""
publishedOnDate= "pubblicato su {{ .Date }}"
includedInCategories= "incluso in {{ .Categories }}"
views = "visualizzazioni"
comments = "commenti"
author = "Autore"
Expand All @@ -122,6 +121,11 @@ encryptedMessage = ""
password = "Password"
encryptyAgain = ""

[single.includedIn]
categories = "incluso in {{ .Categories }}"
collections = "incluso in {{ .Collections }}"
both = "incluso in {{ .Categories }} e {{ .Collections }}"

[single.wordCount]
one = "Una parola"
other = "{{ .Count }} parole"
Expand Down
6 changes: 5 additions & 1 deletion i18n/pl.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ other = "Udostępnij na"
contents= "Spis treści"
repost= ""
publishedOnDate= "opublikowano {{ .Date }}"
includedInCategories= "zawarty w {{ .Categories }}"
views = "wyświetleń"
comments = "komentarzy"
author = "Autor"
Expand All @@ -122,6 +121,11 @@ encryptedMessage = ""
password = "Hasło"
encryptyAgain = ""

[single.includedIn]
categories = "zawarty w {{ .Categories }}"
collections = "zawarty w {{ .Collections }}"
both = "zawarty w {{ .Categories }} i {{ .Collections }}"

[single.wordCount]
one = "Jedno słowo"
other = "{{ .Count }} słów"
Expand Down
6 changes: 5 additions & 1 deletion i18n/pt-BR.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ other = "Compartilhe em"
contents= "Conteúdos"
repost= ""
publishedOnDate= "publicado em {{ .Date }}"
includedInCategories= "incluido em {{ .Categories }}"
views = "visualizações"
comments = "comentários"
author = "Autor"
Expand All @@ -122,6 +121,11 @@ encryptedMessage = ""
password = "Contrasinha"
encryptyAgain = ""

[single.includedIn]
categories = "incluido em {{ .Categories }}"
collections = "incluido em {{ .Collections }}"
both = "incluido em {{ .Categories }} e {{ .Collections }}"

[single.wordCount]
one = "Uma palavra"
other = "{{ .Count }} palavras"
Expand Down
6 changes: 5 additions & 1 deletion i18n/ro.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ other = "Distribuie pe"
contents= "Cuprins"
repost= ""
publishedOnDate= "publicat la {{ .Date }}"
includedInCategories= "inclus în {{ .Categories }}"
views = "vizualizări"
comments = "comentarii"
author = "Autor"
Expand All @@ -122,6 +121,11 @@ encryptedMessage = ""
password = "Parolă"
encryptyAgain = ""

[single.includedIn]
categories = "inclus în {{ .Categories }}"
collections = "inclus în {{ .Collections }}"
both = "inclus în {{ .Categories }} și {{ .Collections }}"

[single.wordCount]
one = "Un cuvânt"
other = "{{ .Count }} cuvinte"
Expand Down
6 changes: 5 additions & 1 deletion i18n/ru.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ other = "Поделиться в"
contents= "Содержание"
repost= ""
publishedOnDate= "Опубликовано {{ .Date }}"
includedInCategories= "включен в {{ .Categories }}"
views = "просмотров"
comments = "комментариев"
author = "Автор"
Expand All @@ -122,6 +121,11 @@ encryptedMessage = ""
password = "арготизм"
encryptyAgain = ""

[single.includedIn]
categories = "включен в {{ .Categories }}"
collections = "включен в {{ .Collections }}"
both = "включен в {{ .Categories }} и {{ .Collections }}"

[single.wordCount]
one = "Одно слово"
other = "{{ .Count }} слов"
Expand Down
6 changes: 5 additions & 1 deletion i18n/sr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ other = "Подели на"
contents= "Садржаји"
repost= ""
publishedOnDate= "објављено {{ .Date }}"
includedInCategories= "укључено {{ .Categories }}"
views = "прегледа"
comments = "коментари"
author = "Аутор"
Expand All @@ -122,6 +121,11 @@ encryptedMessage = ""
password = "Паролица"
encryptyAgain = ""

[single.includedIn]
categories = "укључено {{ .Categories }}"
collections = "укључено {{ .Collections }}"
both = "укључено {{ .Categories }} и {{ .Collections }}"

[single.wordCount]
one = "Једна реч"
other = "{{ .Count }} речи"
Expand Down
6 changes: 5 additions & 1 deletion i18n/vi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ other = "Chia sẻ trên"
contents= "Nội dung"
repost= ""
publishedOnDate= "đăng ngày {{ .Date }}"
includedInCategories= "trong {{ .Categories }}"
views = "lượt xem"
comments = "bình luận"
author = "Tác giả"
Expand All @@ -121,6 +120,11 @@ encryptedMessage = ""
password = "Mật khẩu"
encryptyAgain = ""

[single.includedIn]
categories = "trong {{ .Categories }}"
collections = "trong {{ .Collections }}"
both = "trong {{ .Categories }} và {{ .Collections }}"

[single.wordCount]
one = "One word"
other = "{{ .Count }} từ"
Expand Down
6 changes: 5 additions & 1 deletion i18n/zh-CN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ other = "分享到"
contents= "目录"
repost= "转载"
publishedOnDate= "发布于 {{ .Date }}"
includedInCategories= "收录于 {{ .Categories }}"
views = "次阅读"
comments = "条评论"
author = "作者"
Expand All @@ -120,6 +119,11 @@ encryptedMessage = "请输入密码"
password = "密码"
encryptyAgain = "重新加密"

[single.includedIn]
categories = "收录于 {{ .Categories }}"
collections = "收录于 {{ .Collections }}"
both = "收录于 {{ .Categories }} 和 {{ .Collections }}"

[single.wordCount]
other = "{{ .Count }} 字"

Expand Down
6 changes: 5 additions & 1 deletion i18n/zh-TW.toml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ other = "分享到"
contents= "目錄"
repost= "轉貼"
publishedOnDate= "發佈於 {{ .Date }}"
includedInCategories= "收錄於 {{ .Categories }}"
views = "次閱讀"
comments = "條評論"
author = "作者"
Expand All @@ -120,6 +119,11 @@ encryptedMessage = "請輸入密碼"
password = "密碼"
encryptyAgain = "重新加密"

[single.includedIn]
categories = "收錄於 {{ .Categories }}"
collections = "收錄於 {{ .Collections }}"
both = "收錄於 {{ .Categories }} 和 {{ .Collections }}"

[single.wordCount]
other = "{{ .Count }} 字"

Expand Down
11 changes: 1 addition & 10 deletions layouts/_default/summary.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,7 @@ <h1 class="single-title" itemprop="name headline">
</span>
{{- end -}}

{{- $categories := slice -}}
{{- range .Params.categories -}}
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
{{- $categories = $categories | append (printf `<a href="%v">%v %v</a>` (partial "function/escapeurl.html" $category.RelPermalink) (dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html") $category.Title) -}}
{{- end -}}
{{- with delimit $categories "&ensp;" -}}
&nbsp;<span class="post-category">
{{- dict "Categories" . | T "single.includedInCategories" | safeHTML -}}
</span>
{{- end -}}
{{- partial "single/post-included-in.html" . -}}
</div>

{{- /* Summary content */ -}}
Expand Down
37 changes: 37 additions & 0 deletions layouts/partials/single/post-included-in.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- $categories := slice -}}
{{- range .Params.categories -}}
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
{{- $categories = $categories | append (
printf `<a href="%v" class="post-category" title="%v">%v %v</a>`
(partial "function/escapeurl.html" $category.RelPermalink)
(printf "%v - %v" (T "category") $category.Title)
(dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html")
$category.Title
) -}}
{{- end -}}
{{- $categoriesStr := delimit $categories "&ensp;" -}}

{{- $collections := slice -}}
{{- range .Params.collections -}}
{{- $collection := partialCached "function/path.html" . . | printf "/collections/%v" | $.Site.GetPage -}}
{{- $collections = $collections | append (
printf `<a href="%v" class="post-collection" title="%v">%v %v</a>`
(partial "function/escapeurl.html" $collection.RelPermalink)
(printf "%v - %v" (T "collection") $collection.Title)
(dict "Class" "fa-solid fa-layer-group fa-fw" | partial "plugin/icon.html")
$collection.Title
) -}}
{{- end -}}
{{- $collectionStr := delimit $collections "&ensp;" -}}

{{- if .Params.categories | or .Params.collections -}}
<span class="post-included-in">
{{- if not .Params.collections -}}
&nbsp;{{- dict "Categories" $categoriesStr | T "single.includedIn.categories" | safeHTML -}}
{{- else if not .Params.categories -}}
&nbsp;{{- dict "Collections" $collectionStr | T "single.includedIn.collections" | safeHTML -}}
{{- else -}}
&nbsp;{{- dict "Categories" $categoriesStr "Collections" $collectionStr | T "single.includedIn.both" | safeHTML -}}
{{- end -}}
</span>
{{- end -}}
16 changes: 3 additions & 13 deletions layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{- $params := .Scratch.Get "params" -}}
{{- $toc := .Scratch.Get "toc" -}}

<aside class="toc" id="toc-auto">
<aside class="toc" id="toc-auto" aria-label="{{ T "single.contents" }}">
{{- /* Auto TOC */ -}}
{{- $tocEmpty := eq .TableOfContents `<nav id="TableOfContents"></nav>` -}}
{{- if (ne $toc.enable false) | and (ne $tocEmpty true) -}}
Expand All @@ -16,7 +16,7 @@ <h2 class="toc-title{{ with $params.password }} d-none{{ end }}">
{{- end -}}
</aside>

<aside class="aside-custom">
<aside class="aside-custom" aria-label="Custom Aside">
<!-- put aside for later use -->
{{- partial (.Scratch.Get "customFilePath").aside . -}}
</aside>
Expand Down Expand Up @@ -48,17 +48,7 @@ <h1 class="single-title animate__animated animate__flipInX">
<div class="post-meta">
<div class="post-meta-line">
{{- partial "single/post-author.html" . -}}

{{- $categories := slice -}}
{{- range .Params.categories -}}
{{- $category := partialCached "function/path.html" . . | printf "/categories/%v" | $.Site.GetPage -}}
{{- $categories = $categories | append (printf `<a href="%v">%v %v</a>` (partial "function/escapeurl.html" $category.RelPermalink) (dict "Class" "fa-regular fa-folder fa-fw" | partial "plugin/icon.html") $category.Title) -}}
{{- end -}}
{{- with delimit $categories "&ensp;" }}
<span class="post-category">
{{- dict "Categories" . | T "single.includedInCategories" | safeHTML -}}
</span>
{{- end -}}
{{- partial "single/post-included-in.html" . -}}
</div>
<div class="post-meta-line">
{{- with .PublishDate | dateFormat (.Site.Params.dateformat | default "2006-01-02") -}}
Expand Down

0 comments on commit 5d16e1a

Please sign in to comment.