diff --git a/CHANGELOG.md b/CHANGELOG.md index a69dce59..68c39a6a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file. - :sparkles: Feat: add total word count feature in section and remove from footer ([#124](https://github.com/Lruihao/FixIt/issues/124)) - :sparkles: Feat: enhance auto toc feature ([#104](https://github.com/Lruihao/FixIt/issues/104) [#136](https://github.com/Lruihao/FixIt/issues/136)) - :sparkles: Feat(SEO): add options to make output baidu_urls.txt file ([#138](https://github.com/Lruihao/FixIt/issues/138)) +- :sparkles: Feat: add repost feature ([#156](https://github.com/Lruihao/FixIt/issues/156)) - :bug: Fix: unable to show search bar of header at mobile mode ([#143](https://github.com/Lruihao/FixIt/issues/143)) - :bug: Fix: Giscus comments invalid config `inputPosition` - :bug: Fix: busuanzi logic error diff --git a/archetypes/post-bundle/index.md b/archetypes/post-bundle/index.md index 6ee3cdf1..5556e1f3 100644 --- a/archetypes/post-bundle/index.md +++ b/archetypes/post-bundle/index.md @@ -35,6 +35,10 @@ lightgallery: false seo: images: [] +repost: + enable: true + url: "" + # See details front matter: /theme-documentation-content/#front-matter --- diff --git a/archetypes/posts.md b/archetypes/posts.md index be607000..e31fe26e 100644 --- a/archetypes/posts.md +++ b/archetypes/posts.md @@ -35,6 +35,10 @@ lightgallery: false seo: images: [] +repost: + enable: true + url: "" + # See details front matter: /theme-documentation-content/#front-matter --- diff --git a/assets/css/_page/_single.scss b/assets/css/_page/_single.scss index e27efb8d..41537b4e 100644 --- a/assets/css/_page/_single.scss +++ b/assets/css/_page/_single.scss @@ -8,6 +8,13 @@ font-size: 1.6rem; font-weight: bold; line-height: 140%; + + .icon-repost { + color: var(--#{$prefix}success); + display: inline-block; + width: max-content; + margin-right: 0.25rem; + } } .single-subtitle { diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 2e009853..540b9b1f 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -700,6 +700,11 @@ enableEmoji = true # Gravatar is force-used as the author's avatar since v0.2.14 # 强制使用 Gravatar 作为作者头像 since v0.2.14 gravatarForce = true + # Repost config since v0.2.15 + # 转载配置 since v0.2.15 + [params.page.repost] + enable = false + url = "" # Table of the contents config # 目录配置 [params.page.toc] diff --git a/exampleSite/content/posts/basic-markdown-syntax/index.en.md b/exampleSite/content/posts/basic-markdown-syntax/index.en.md index b995214e..2f900b8f 100644 --- a/exampleSite/content/posts/basic-markdown-syntax/index.en.md +++ b/exampleSite/content/posts/basic-markdown-syntax/index.en.md @@ -3,8 +3,6 @@ title: "Basic Markdown Syntax" date: 2019-12-01T21:57:40+08:00 lastmod: 2022-03-01T22:30:40+08:00 draft: false -author: "Dillon" -authorLink: "https://dillonzq.com" description: "This article shows the basic Markdown syntax and format." resources: - name: "featured-image" @@ -14,6 +12,10 @@ tags: ["Markdown", "HTML"] categories: ["Markdown"] lightgallery: true + +repost: + enable: true + url: "https://hugoloveit.com/basic-markdown-syntax/" --- This article offers a sample of basic Markdown syntax that can be used in Hugo content files. diff --git a/exampleSite/content/posts/basic-markdown-syntax/index.zh-cn.md b/exampleSite/content/posts/basic-markdown-syntax/index.zh-cn.md index bbeba51b..885ab2a1 100644 --- a/exampleSite/content/posts/basic-markdown-syntax/index.zh-cn.md +++ b/exampleSite/content/posts/basic-markdown-syntax/index.zh-cn.md @@ -3,8 +3,6 @@ title: "Markdown 基本语法" date: 2019-12-01T21:57:40+08:00 lastmod: 2022-01-20T17:44:40+08:00 draft: false -author: "Dillon" -authorLink: "https://dillonzq.com" description: "这篇文章展示了基本的 Markdown 语法和格式。" resources: - name: "featured-image" @@ -14,6 +12,10 @@ tags: ["Markdown", "HTML"] categories: ["Markdown"] lightgallery: true + +repost: + enable: true + url: "https://hugoloveit.com/zh-cn/basic-markdown-syntax/" --- 这篇文章提供了可以在 Hugo 的文章中使用的基本 Markdown 语法示例。 diff --git a/exampleSite/content/posts/pwa-support/index.en.md b/exampleSite/content/posts/pwa-support/index.en.md index d3ec2f75..a3435a47 100644 --- a/exampleSite/content/posts/pwa-support/index.en.md +++ b/exampleSite/content/posts/pwa-support/index.en.md @@ -3,8 +3,6 @@ weight: 5 title: "Theme Documentation - PWA Support" date: 2022-01-26T09:32:56+08:00 draft: false -author: "Lruihao" -authorLink: "https://lruihao.cn" description: "Guide to setup PWA in FixIt." tags: ["PWA"] @@ -23,6 +21,10 @@ menu: title: "Guide to setup PWA in FixIt." parent: "documentation" pre: "" + +repost: + enable: true + url: "https://hugodoit.com/pwa-support/" --- Find out how to turn your FixIt site into a Progressive Web App. diff --git a/exampleSite/content/posts/pwa-support/index.zh-cn.md b/exampleSite/content/posts/pwa-support/index.zh-cn.md index ebe672b4..4f95d331 100644 --- a/exampleSite/content/posts/pwa-support/index.zh-cn.md +++ b/exampleSite/content/posts/pwa-support/index.zh-cn.md @@ -3,8 +3,6 @@ weight: 5 title: "主题文档 - PWA 支持" date: 2022-01-26T11:10:56+08:00 draft: false -author: "Lruihao" -authorLink: "https://lruihao.cn" description: "在 FixIt 中设置 PWA 的指南。" tags: ["PWA"] @@ -22,6 +20,10 @@ menu: title: "在 FixIt 中设置 PWA 的指南。" parent: "documentation" pre: "" + +repost: + enable: true + url: "https://hugodoit.com/zh-cn/pwa-support/" --- 了解如何在 FixIt 主题中配置渐进式网络应用程序 (PWA)。 diff --git a/exampleSite/content/posts/theme-documentation-basics/index.en.md b/exampleSite/content/posts/theme-documentation-basics/index.en.md index ae33c675..d65b1d1c 100644 --- a/exampleSite/content/posts/theme-documentation-basics/index.en.md +++ b/exampleSite/content/posts/theme-documentation-basics/index.en.md @@ -473,6 +473,10 @@ Please open the code block below to view the complete sample configuration :(fa- pageStyle = "normal" # {{< version 0.2.14 >}} Gravatar is force-used as the author's avatar gravatarForce = false + # {{< version 0.2.15 >}} Repost config + [params.page.repost] + enable = false + url = "" # {{< version 0.2.0 >}} Table of the contents config [params.page.toc] # whether to enable the table of the contents diff --git a/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md b/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md index 2b209846..c4be0afa 100644 --- a/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md +++ b/exampleSite/content/posts/theme-documentation-basics/index.zh-cn.md @@ -475,6 +475,10 @@ hugo pageStyle = "normal" # {{< version 0.2.14 >}} 强制使用 Gravatar 作为作者头像 gravatarForce = true + # {{< version 0.2.15 >}} 转载配置 + [params.page.repost] + enable = false + url = "" # {{< version 0.2.0 >}} 目录配置 [params.page.toc] # 是否使用目录 diff --git a/exampleSite/content/posts/theme-documentation-content/index.en.md b/exampleSite/content/posts/theme-documentation-content/index.en.md index 5853f931..f4c3bf13 100644 --- a/exampleSite/content/posts/theme-documentation-content/index.en.md +++ b/exampleSite/content/posts/theme-documentation-content/index.en.md @@ -118,6 +118,8 @@ It is necessary only if the front matters and the `page` part in your [site conf * **password**: {{< version 0.2.15 >}} password of encrypted page content, see [Theme Documentation - Content Encryption](../theme-documentation-content-encryption/) * **message**: {{< version 0.2.15 >}} encryption prompt, see [Theme Documentation - Content Encryption](../theme-documentation-content-encryption/) +* **repost**: {{< version 0.2.15 >}} the same as the `params.page.repost` part in the [site configuration](../theme-documentation-basics#site-configuration). + {{< admonition tip >}} {{< version 0.2.10 >}} diff --git a/exampleSite/content/posts/theme-documentation-content/index.zh-cn.md b/exampleSite/content/posts/theme-documentation-content/index.zh-cn.md index 0198c3d4..90e90376 100644 --- a/exampleSite/content/posts/theme-documentation-content/index.zh-cn.md +++ b/exampleSite/content/posts/theme-documentation-content/index.zh-cn.md @@ -116,6 +116,8 @@ menu: * **password**: {{< version 0.2.15 >}} 加密页面内容的密码,详见 [主题文档 - 内容加密](../theme-documentation-content-encryption/) * **message**: {{< version 0.2.15 >}} 加密提示信息,详见 [主题文档 - 内容加密](../theme-documentation-content-encryption/) +* **repost**: {{< version 0.2.15 >}} 和 [网站配置](../theme-documentation-basics#site-configuration) 中的 `params.page.repost` 部分相同 + {{< admonition tip >}} {{< version 0.2.10 >}} diff --git a/i18n/de.toml b/i18n/de.toml index 20dcc243..a520f725 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -145,6 +145,8 @@ other = "Teilen auf" # === posts/single.html === [contents] other = "Inhalt" +[repost] +other = "" # waitting for translation [publishedOnDate] other = "veröffentlicht auf {{ .Date }}" diff --git a/i18n/en.toml b/i18n/en.toml index cc229de4..753dea8e 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -142,6 +142,9 @@ other = "Share on" [contents] other = "Contents" +[repost] +other = "Repost" + [publishedOnDate] other = "published on {{ .Date }}" diff --git a/i18n/es.toml b/i18n/es.toml index 6c47b503..7160c4de 100644 --- a/i18n/es.toml +++ b/i18n/es.toml @@ -145,6 +145,8 @@ other = "Compartir en" # === posts/single.html === [contents] other = "Contenido" +[repost] +other = "" # waitting for translation [publishedOnDate] other = "publicado el {{ .Date }}" diff --git a/i18n/fr.toml b/i18n/fr.toml index fd66d542..70b3bc58 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -145,6 +145,8 @@ other = "Partager sur" # === posts/single.html === [contents] other = "Contenu" +[repost] +other = "" # waitting for translation [publishedOnDate] other = "publié le {{ .Date }}" diff --git a/i18n/it.toml b/i18n/it.toml index bf721d6a..10f82afe 100644 --- a/i18n/it.toml +++ b/i18n/it.toml @@ -145,6 +145,8 @@ other = "Condividi su" # === posts/single.html === [contents] other = "Contenuti" +[repost] +other = "" # waitting for translation [publishedOnDate] other = "pubblicato su {{ .Date }}" diff --git a/i18n/pl.toml b/i18n/pl.toml index 9fe664c5..69879f7e 100644 --- a/i18n/pl.toml +++ b/i18n/pl.toml @@ -142,6 +142,8 @@ other = "Udostępnij na" # === posts/single.html === [contents] other = "Spis treści" +[repost] +other = "" # waitting for translation [publishedOnDate] other = "opublikowano {{ .Date }}" diff --git a/i18n/pt-BR.toml b/i18n/pt-BR.toml index a7f47f1e..da828cc4 100644 --- a/i18n/pt-BR.toml +++ b/i18n/pt-BR.toml @@ -145,6 +145,8 @@ other = "Compartilhe em" # === posts/single.html === [contents] other = "Conteúdos" +[repost] +other = "" # waitting for translation [publishedOnDate] other = "publicado em {{ .Date }}" diff --git a/i18n/ro.toml b/i18n/ro.toml index 0d8b5d11..1f346c5e 100644 --- a/i18n/ro.toml +++ b/i18n/ro.toml @@ -145,6 +145,8 @@ other = "Distribuie pe" # === posts/single.html === [contents] other = "Cuprins" +[repost] +other = "" # waitting for translation [publishedOnDate] other = "publicat la {{ .Date }}" diff --git a/i18n/ru.toml b/i18n/ru.toml index d5dcc491..d75b4d9f 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -145,6 +145,8 @@ other = "Поделиться в" # === posts/single.html === [contents] other = "Содержание" +[repost] +other = "" # waitting for translation [publishedOnDate] other = "Опубликовано {{ .Date }}" diff --git a/i18n/sr.toml b/i18n/sr.toml index 0851fdf9..2b2a7f89 100644 --- a/i18n/sr.toml +++ b/i18n/sr.toml @@ -142,6 +142,8 @@ other = "Подели на" # === posts/single.html === [contents] other = "Садржаји" +[repost] +other = "" # waitting for translation [publishedOnDate] other = "објављено {{ .Date }}" diff --git a/i18n/vi.toml b/i18n/vi.toml index ef56356e..e7a4c6aa 100644 --- a/i18n/vi.toml +++ b/i18n/vi.toml @@ -144,6 +144,8 @@ other = "Chia sẻ trên" # === posts/single.html === [contents] other = "Nội dung" +[repost] +other = "" # waitting for translation [publishedOnDate] other = "đăng ngày {{ .Date }}" diff --git a/i18n/zh-CN.toml b/i18n/zh-CN.toml index 5a66af6d..cf772403 100644 --- a/i18n/zh-CN.toml +++ b/i18n/zh-CN.toml @@ -148,6 +148,9 @@ other = "分享到" [contents] other = "目录" +[repost] +other = "转载" + [publishedOnDate] other = "发布于 {{ .Date }}" diff --git a/i18n/zh-TW.toml b/i18n/zh-TW.toml index 8e9c24d7..4d7156fc 100644 --- a/i18n/zh-TW.toml +++ b/i18n/zh-TW.toml @@ -148,6 +148,9 @@ other = "分享到" [contents] other = "目錄" +[repost] +other = "轉貼" + [publishedOnDate] other = "發佈於 {{ .Date }}" diff --git a/layouts/_default/section.html b/layouts/_default/section.html index 6396fac7..d4b0cd6e 100644 --- a/layouts/_default/section.html +++ b/layouts/_default/section.html @@ -41,9 +41,7 @@

{{ .Key }}

{{- range .Pages -}}
- - {{- .Title -}} - + {{- .Title -}} {{- $.Site.Params.section.dateFormat | default "01-02" | .Date.Format -}} diff --git a/layouts/_default/summary.html b/layouts/_default/summary.html index 7437de76..3c43c357 100644 --- a/layouts/_default/summary.html +++ b/layouts/_default/summary.html @@ -19,6 +19,14 @@ {{- /* Title */ -}}

+ {{ $repost := $params.repost | default dict }} + {{- with $repost -}} + {{- if eq .Enable true -}} + {{- $icon := dict "Class" "fa-solid fa-share fa-fw" -}} + {{- $title := cond (hasPrefix .Url "http") (printf "%v -> %v" (T "repost") .Url ) (T "repost") -}} + {{- $icon | partial "plugin/icon.html" -}} + {{- end -}} + {{- end -}} {{ .Title }}

diff --git a/layouts/posts/single.html b/layouts/posts/single.html index 84130e00..a02d5f82 100644 --- a/layouts/posts/single.html +++ b/layouts/posts/single.html @@ -20,7 +20,21 @@
{{- /* Title */ -}} -

{{ .Title }}

+

+ {{ $repost := $params.repost | default dict }} + {{- with $repost -}} + {{- if eq .Enable true -}} + {{- $icon := dict "Class" "fa-solid fa-share fa-fw" -}} + {{- $title := cond (hasPrefix .Url "http") (printf "%v -> %v" (T "repost") .Url ) (T "repost") -}} + {{- if hasPrefix .Url "http" -}} + {{ dict "Destination" .Url "Icon" $icon "Class" "icon-repost" "Title" $title | partial "plugin/link.html" -}} + {{- else -}} + {{- $icon | partial "plugin/icon.html" -}} + {{- end -}} + {{- end -}} + {{- end -}} + {{- .Title -}} +

{{- /* Subtitle */ -}} {{- with $params.subtitle -}}

{{ . }}

{{- end -}}