Skip to content

Commit

Permalink
🎉 Feat: add related content support
Browse files Browse the repository at this point in the history
  • Loading branch information
Lruihao committed Dec 20, 2023
1 parent caeb3d4 commit 2cc276e
Show file tree
Hide file tree
Showing 19 changed files with 92 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# FixIt Theme | Hugo

[![GitHub release (latest by date)](https://img.shields.io/github/v/release/hugo-fixit/FixIt?style=flat)](https://github.com/hugo-fixit/FixIt/releases)
[![Hugo](https://img.shields.io/badge/Hugo-%5E0.110.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![Hugo](https://img.shields.io/badge/Hugo-%5E0.111.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![License](https://img.shields.io/github/license/hugo-fixit/FixIt?style=flat)](/LICENSE)

👉 English README | [简体中文说明](README.zh-cn.md)
Expand Down
2 changes: 1 addition & 1 deletion README.zh-cn.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# FixIt 主题 | Hugo

[![GitHub release (latest by date)](https://img.shields.io/github/v/release/hugo-fixit/FixIt?style=flat)](https://github.com/hugo-fixit/FixIt/releases)
[![Hugo](https://img.shields.io/badge/Hugo-%5E0.110.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![Hugo](https://img.shields.io/badge/Hugo-%5E0.111.0-ff4088?style=flat&logo=hugo)](https://gohugo.io/)
[![License](https://img.shields.io/github/license/hugo-fixit/FixIt?style=flat)](/LICENSE)

👉 [English README](README.md) | 简体中文说明
Expand Down
49 changes: 46 additions & 3 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,11 @@ enableEmoji = true
name = ""
logoUrl = ""

# FixIt 0.3.0 | NEW Related content config
[params.page.related]
enable = false
count = 5

# FixIt 0.2.5 | NEW TypeIt config
[params.typeit]
# typing speed between each step (measured in milliseconds)
Expand Down Expand Up @@ -877,6 +882,45 @@ enableEmoji = true
# "vConsole", "eruda" supported
type = "vConsole"

# -------------------------------------------------------------------------------------
# Related content Configuration
# See: https://gohugo.io/content-management/related/
# -------------------------------------------------------------------------------------

[related]
includeNewer = false
threshold = 80
toLower = false
[[related.indices]]
applyFilter = false
cardinalityThreshold = 0
name = 'keywords'
pattern = ''
toLower = false
type = 'basic'
weight = 100
[[related.indices]]
applyFilter = false
cardinalityThreshold = 0
name = 'date'
pattern = ''
toLower = false
type = 'basic'
weight = 10
[[related.indices]]
applyFilter = false
cardinalityThreshold = 0
name = 'tags'
pattern = ''
toLower = false
type = 'basic'
weight = 80
[[related.indices]]
applyFilter = false
name = 'fragmentrefs'
type = 'fragments'
weight = 80

# -------------------------------------------------------------------------------------
# Modules Configuration
# See: https://gohugo.io/hugo-modules/configuration/#module-config-imports
Expand All @@ -885,7 +929,7 @@ enableEmoji = true
[module]
[module.hugoVersion]
extended = true
min = "0.110.0"
min = "0.111.0"

# -------------------------------------------------------------------------------------
# Markup related configuration in Hugo
Expand Down Expand Up @@ -1000,7 +1044,6 @@ enableEmoji = true
# -------------------------------------------------------------------------------------

[taxonomies]
# series = "series"
category = "categories"
tag = "tags"
collections = "collections"
collection = "collections"
1 change: 1 addition & 0 deletions i18n/de.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Passwort"
encryptyAgain = ""
relatedContent = "Ähnliche Inhalte"

[single.includedIn]
categories = "enthalten in {{ .Categories }}"
Expand Down
1 change: 1 addition & 0 deletions i18n/en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ encryptedAbstract = "This article has been encrypted, so its raw content is invi
encryptedMessage = "Please enter the password"
password = "Password"
encryptyAgain = "Encrypt again"
relatedContent = "Related Content"

[single.includedIn]
categories = "included in {{ .Categories }}"
Expand Down
1 change: 1 addition & 0 deletions i18n/es.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Contraseña"
encryptyAgain = ""
relatedContent = "Contenido relacionado"

[single.includedIn]
categories = "incluido en {{ .Categories }}"
Expand Down
1 change: 1 addition & 0 deletions i18n/fr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ encryptedAbstract = "Cet article a été chiffré, son contenu n'est donc pas li
encryptedMessage = "Entrer le mot de passe"
password = "Mot de passe"
encryptyAgain = "Chiffrer à nouveau"
relatedContent = "Contenu lié"

[single.includedIn]
categories = "inclus dans {{ .Categories }}"
Expand Down
1 change: 1 addition & 0 deletions i18n/it.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Password"
encryptyAgain = ""
relatedContent = "Contenuti correlati"

[single.includedIn]
categories = "incluso in {{ .Categories }}"
Expand Down
1 change: 1 addition & 0 deletions i18n/pl.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Hasło"
encryptyAgain = ""
relatedContent = "Powiązane treści"

[single.includedIn]
categories = "zawarty w {{ .Categories }}"
Expand Down
1 change: 1 addition & 0 deletions i18n/pt-BR.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Contrasinha"
encryptyAgain = ""
relatedContent = "Conteúdo relacionado"

[single.includedIn]
categories = "incluido em {{ .Categories }}"
Expand Down
1 change: 1 addition & 0 deletions i18n/ro.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Parolă"
encryptyAgain = ""
relatedContent = "Conținut înrudit"

[single.includedIn]
categories = "inclus în {{ .Categories }}"
Expand Down
1 change: 1 addition & 0 deletions i18n/ru.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "арготизм"
encryptyAgain = ""
relatedContent = "Связанный контент"

[single.includedIn]
categories = "включен в {{ .Categories }}"
Expand Down
1 change: 1 addition & 0 deletions i18n/sr.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Паролица"
encryptyAgain = ""
relatedContent = "Повезани садржај"

[single.includedIn]
categories = "укључено {{ .Categories }}"
Expand Down
1 change: 1 addition & 0 deletions i18n/vi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Mật khẩu"
encryptyAgain = ""
relatedContent = "Nội dung liên quan"

[single.includedIn]
categories = "trong {{ .Categories }}"
Expand Down
1 change: 1 addition & 0 deletions i18n/zh-CN.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ encryptedAbstract = "本文已加密,因此其原始内容不可见!"
encryptedMessage = "请输入密码"
password = "密码"
encryptyAgain = "重新加密"
relatedContent = "相关内容"

[single.includedIn]
categories = "收录于 {{ .Categories }}"
Expand Down
1 change: 1 addition & 0 deletions i18n/zh-TW.toml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ encryptedAbstract = "本文已加密,囙此其原始內容不可見!"
encryptedMessage = "請輸入密碼"
password = "密碼"
encryptyAgain = "重新加密"
relatedContent = "相關內容"

[single.includedIn]
categories = "收錄於 {{ .Categories }}"
Expand Down
27 changes: 27 additions & 0 deletions layouts/partials/single/related.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{{- /* Related Content */ -}}
{{- /* https://gohugo.io/content-management/related/ */ -}}
{{- $params := .Scratch.Get "params" -}}

{{- if $params.related.enable -}}
{{- $related := .Site.RegularPages.Related . | first ($params.related.count | default 5) -}}
{{- with $related -}}
<h2 id="see-also">{{ T "single.relatedContent" }}</h2>
<ul>
{{- range $i, $p := . -}}
<li>
<a href="{{ .RelPermalink }}" title="{{ .LinkTitle }}">{{ .LinkTitle }}</a>
{{- with .HeadingsFiltered -}}
<ul>
{{- range . -}}
{{- $link := printf "%s#%s" $p.RelPermalink .ID | safeURL -}}
<li>
<a href="{{ $link }}" title="{{ .Title }}">{{ .Title }}</a>
</li>
{{- end -}}
</ul>
{{- end -}}
</li>
{{- end -}}
</ul>
{{- end -}}
{{- end -}}
3 changes: 3 additions & 0 deletions layouts/posts/single.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ <h1 class="single-title animate__animated animate__flipInX">
{{- end -}}
</div>

{{- /* Related Content */ -}}
{{- partial "single/related.html" . -}}

{{- /* Reward before Footer */ -}}
{{- $reward := .Scratch.Get "reward" -}}
{{- if eq $reward.position "before" -}}
Expand Down
2 changes: 1 addition & 1 deletion theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ licenselink = "https://github.com/hugo-fixit/FixIt/blob/master/LICENSE"
description = "A Clean, Elegant but Advanced Hugo Theme for Hugo."
homepage = "https://github.com/hugo-fixit/FixIt"
demosite = "https://fixit.lruihao.cn"
min_version = "0.110.0"
min_version = "0.111.0"

tags = [
"blog",
Expand Down

0 comments on commit 2cc276e

Please sign in to comment.