🎉 Feat: add related content support

This commit is contained in:
Cell
2023-12-20 10:48:22 +08:00
parent caeb3d443e
commit 2cc276e5f5
19 changed files with 92 additions and 6 deletions
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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) | 简体中文说明
+46 -3
View File
@@ -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)
@@ -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
@@ -885,7 +929,7 @@ enableEmoji = true
[module]
[module.hugoVersion]
extended = true
min = "0.110.0"
min = "0.111.0"
# -------------------------------------------------------------------------------------
# Markup related configuration in Hugo
@@ -1000,7 +1044,6 @@ enableEmoji = true
# -------------------------------------------------------------------------------------
[taxonomies]
# series = "series"
category = "categories"
tag = "tags"
collections = "collections"
collection = "collections"
+1
View File
@@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Passwort"
encryptyAgain = ""
relatedContent = "Ähnliche Inhalte"
[single.includedIn]
categories = "enthalten in {{ .Categories }}"
+1
View File
@@ -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 }}"
+1
View File
@@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Contraseña"
encryptyAgain = ""
relatedContent = "Contenido relacionado"
[single.includedIn]
categories = "incluido en {{ .Categories }}"
+1
View File
@@ -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 }}"
+1
View File
@@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Password"
encryptyAgain = ""
relatedContent = "Contenuti correlati"
[single.includedIn]
categories = "incluso in {{ .Categories }}"
+1
View File
@@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Hasło"
encryptyAgain = ""
relatedContent = "Powiązane treści"
[single.includedIn]
categories = "zawarty w {{ .Categories }}"
+1
View File
@@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Contrasinha"
encryptyAgain = ""
relatedContent = "Conteúdo relacionado"
[single.includedIn]
categories = "incluido em {{ .Categories }}"
+1
View File
@@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Parolă"
encryptyAgain = ""
relatedContent = "Conținut înrudit"
[single.includedIn]
categories = "inclus în {{ .Categories }}"
+1
View File
@@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "арготизм"
encryptyAgain = ""
relatedContent = "Связанный контент"
[single.includedIn]
categories = "включен в {{ .Categories }}"
+1
View File
@@ -120,6 +120,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Паролица"
encryptyAgain = ""
relatedContent = "Повезани садржај"
[single.includedIn]
categories = "укључено {{ .Categories }}"
+1
View File
@@ -119,6 +119,7 @@ encryptedAbstract = ""
encryptedMessage = ""
password = "Mật khẩu"
encryptyAgain = ""
relatedContent = "Nội dung liên quan"
[single.includedIn]
categories = "trong {{ .Categories }}"
+1
View File
@@ -118,6 +118,7 @@ encryptedAbstract = "本文已加密,因此其原始内容不可见!"
encryptedMessage = "请输入密码"
password = "密码"
encryptyAgain = "重新加密"
relatedContent = "相关内容"
[single.includedIn]
categories = "收录于 {{ .Categories }}"
+1
View File
@@ -118,6 +118,7 @@ encryptedAbstract = "本文已加密,囙此其原始內容不可見!"
encryptedMessage = "請輸入密碼"
password = "密碼"
encryptyAgain = "重新加密"
relatedContent = "相關內容"
[single.includedIn]
categories = "收錄於 {{ .Categories }}"
+27
View File
@@ -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
View File
@@ -179,6 +179,9 @@
{{- end -}}
</div>
{{- /* Related Content */ -}}
{{- partial "single/related.html" . -}}
{{- /* Reward before Footer */ -}}
{{- $reward := .Scratch.Get "reward" -}}
{{- if eq $reward.position "before" -}}
+1 -1
View File
@@ -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",