From 9f7bce87a7a10c5ecb507a64a7af705e7770274f Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Thu, 21 Dec 2023 16:24:17 +0800 Subject: [PATCH] :recycle: Refactor: migrate `params.gitRepo` and `params.page.edit` to `params.gitInfo` and add page params: `linkToSource`, `linkToEdit` and `linkToReport` --- docs | 2 +- hugo.toml | 28 ++++++---- i18n/de.toml | 2 + i18n/en.toml | 2 + i18n/es.toml | 2 + i18n/fr.toml | 2 + i18n/it.toml | 2 + i18n/pl.toml | 2 + i18n/pt-BR.toml | 2 + i18n/ro.toml | 2 + i18n/ru.toml | 2 + i18n/sr.toml | 2 + i18n/vi.toml | 2 + i18n/zh-CN.toml | 2 + i18n/zh-TW.toml | 2 + .../partials/init/detection-deprecated.html | 3 + layouts/partials/single/footer.html | 56 +++++++++++++------ 17 files changed, 87 insertions(+), 28 deletions(-) diff --git a/docs b/docs index 95fde1f0..b317055f 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit 95fde1f07d4a67bb93964d7d58ff05d398702343 +Subproject commit b317055f0a7cfa21006256e4deaf967be03b266c diff --git a/hugo.toml b/hugo.toml index b24e1229..b493448c 100644 --- a/hugo.toml +++ b/hugo.toml @@ -95,8 +95,6 @@ enableEmoji = true keywords = ["Hugo", "FixIt"] # site default theme ["light", "dark", "auto"] defaultTheme = "auto" - # public git repo url only then enableGitInfo is true - gitRepo = "" # FixIt 0.1.1 | NEW which hash function used for SRI, when empty, no SRI is used # ["sha256", "sha384", "sha512", "md5"] fingerprint = "" @@ -119,6 +117,17 @@ enableEmoji = true link = "" avatar = "" + # FixIt 0.3.0 | NEW public Git repository information only then enableGitInfo is true + [params.gitInfo] + # e.g. "https://github.com/hugo-fixit/docs" + repo = "" + branch = "main" + # the content directory path relative to the root of the repository + dir = "content" + # the issue template for reporting issue of the posts + # available template params: {title} {URL} {sourceURL} + issueTpl = "title=[BUG]%20{title}&body=|Field|Value|%0A|-|-|%0A|Title|{title}|%0A|URL|{URL}|%0A|Filename|{sourceURL}|" + # FixIt 0.2.0 | NEW App icon config [params.app] # optional site title override for the app when added to an iOS home screen or Android launcher @@ -413,8 +422,14 @@ enableEmoji = true fontawesome = true # license info (HTML format is supported) license = 'CC BY-NC-SA 4.0' - # whether to show link to Raw Markdown content of the content + # whether to show link to Raw Markdown content of the post linkToMarkdown = true + # FixIt 0.3.0 | NEW whether to show link to view source code of the post + linkToSource = true + # FixIt 0.3.0 | NEW whether to show link to edit the post + linkToEdit = true + # FixIt 0.3.0 | NEW whether to show link to report issue for the post + linkToReport = true # FixIt 0.2.4 | NEW whether to show the full text content in RSS rssFullText = false # FixIt 0.2.13 | NEW Page style ["narrow", "normal", "wide", ...] @@ -479,13 +494,6 @@ enableEmoji = true edit = true # the maximum number of lines of displayed code by default maxShownLines = 10 - # FixIt 0.2.14 | NEW Post edit - [params.page.edit] - enable = false - # FixIt 0.2.15 | CHANGED Link for fork & edit - # url = "/edit/branch-name/subdirectory-name" # base on `params.gitRepo` - # url = "https://github.com/user-name/repo-name/edit/branch-name/subdirectory-name" # full url - url = "" # FixIt 0.2.0 | NEW Mapbox GL JS config (https://docs.mapbox.com/mapbox-gl-js) [params.page.mapbox] # access token of Mapbox GL JS diff --git a/i18n/de.toml b/i18n/de.toml index 2fdab24f..0563f8bf 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -111,7 +111,9 @@ comments = "Kommentare" author = "Autor" updatedOnDate = "Aktualisiert am {{ .Date }}" readMarkdown = "Markdown anzeigen" +viewSource = "" editThisPage = "Diese Seite bearbeiten" +reportIssue = "" back = "Zurück" home = "Startseite" readMore = "Mehr lesen" diff --git a/i18n/en.toml b/i18n/en.toml index 4bb8441e..dd85ee71 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -110,7 +110,9 @@ comments = "comments" author = "Author" updatedOnDate = "Updated on {{ .Date }}" readMarkdown = "Read Markdown" +viewSource = "View source" editThisPage = "Edit this page" +reportIssue = "Report issue" back = "Back" home = "Home" readMore = "Read More" diff --git a/i18n/es.toml b/i18n/es.toml index 547a2642..4534485d 100644 --- a/i18n/es.toml +++ b/i18n/es.toml @@ -111,7 +111,9 @@ comments = "Comentarios" author = "Autor" updatedOnDate = "Actualizado el {{ .Date }}" readMarkdown = "Leer Markdown" +viewSource = "" editThisPage = "Editar esta página" +reportIssue = "" back = "Regresar" home = "Inicio" readMore = "Leer más" diff --git a/i18n/fr.toml b/i18n/fr.toml index cea2477e..807e9b4a 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -110,7 +110,9 @@ comments = "commentaires" author = "Auteur" updatedOnDate = "Mis à jour le {{ .Date }}" readMarkdown = "Ouvrir le Markdown" +viewSource = "" editThisPage = "Modifier cette page" +reportIssue = "" back = "Retour" home = "Accueil" readMore = "En savoir plus" diff --git a/i18n/it.toml b/i18n/it.toml index 8b426881..d2f52adc 100644 --- a/i18n/it.toml +++ b/i18n/it.toml @@ -111,7 +111,9 @@ comments = "commenti" author = "Autore" updatedOnDate = "Aggiornato il {{ .Date }}" readMarkdown = "Leggi Markdown" +viewSource = "" editThisPage = "Modifica questa pagina" +reportIssue = "" back = "Indietro" home = "Home" readMore = "Leggi di più" diff --git a/i18n/pl.toml b/i18n/pl.toml index cf96afea..62573c42 100644 --- a/i18n/pl.toml +++ b/i18n/pl.toml @@ -111,7 +111,9 @@ comments = "komentarzy" author = "Autor" updatedOnDate = "Zaktualizowano {{ .Date }}" readMarkdown = "Zobacz Markdown" +viewSource = "" editThisPage = "Edytuj tą stronę" +reportIssue = "" back = "Wstecz" home = "Strona główna" readMore = "Czytaj więcej" diff --git a/i18n/pt-BR.toml b/i18n/pt-BR.toml index dc169664..fc0357f4 100644 --- a/i18n/pt-BR.toml +++ b/i18n/pt-BR.toml @@ -111,7 +111,9 @@ comments = "comentários" author = "Autor" updatedOnDate = "Atualizado em {{ .Date }}" readMarkdown = "Leia em Markdown" +viewSource = "" editThisPage = "Editar esta página" +reportIssue = "" back = "Voltar" home = "Home" readMore = "Leia mais" diff --git a/i18n/ro.toml b/i18n/ro.toml index 130c4387..9a94d078 100644 --- a/i18n/ro.toml +++ b/i18n/ro.toml @@ -111,7 +111,9 @@ comments = "comentarii" author = "Autor" updatedOnDate = "Actualizat la {{ .Date }}" readMarkdown = "Citire Markdown" +viewSource = "" editThisPage = "Editați această pagină" +reportIssue = "" back = "Înapoi" home = "Acasă" readMore = "Citește mai mult" diff --git a/i18n/ru.toml b/i18n/ru.toml index 8624cfa1..37525256 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -111,7 +111,9 @@ comments = "комментариев" author = "Автор" updatedOnDate = "Oбновлена {{ .Date }}" readMarkdown = "Читать Markdown" +viewSource = "" editThisPage = "Редактировать эту страницу" +reportIssue = "" back = "Назад" home = "Домой" readMore = "Читать больше" diff --git a/i18n/sr.toml b/i18n/sr.toml index 8c1ceca7..0437b517 100644 --- a/i18n/sr.toml +++ b/i18n/sr.toml @@ -111,7 +111,9 @@ comments = "коментари" author = "Аутор" updatedOnDate = "Ажурирано {{ .Date }}" readMarkdown = "Читај Markdown" +viewSource = "" editThisPage = "Уреди ову страницу" +reportIssue = "" back = "Назад" home = "Почетна" readMore = "Прочитај више" diff --git a/i18n/vi.toml b/i18n/vi.toml index 669855a9..24954c2f 100644 --- a/i18n/vi.toml +++ b/i18n/vi.toml @@ -110,7 +110,9 @@ comments = "bình luận" author = "Tác giả" updatedOnDate = "Cập nhật ngày {{ .Date }}" readMarkdown = "Đọc với định dạng Markdown" +viewSource = "" editThisPage = "Chỉnh sửa trang này" +reportIssue = "" back = "Quay lại" home = "Trang chủ" readMore = "Đọc thêm" diff --git a/i18n/zh-CN.toml b/i18n/zh-CN.toml index e3427e81..11c184c3 100644 --- a/i18n/zh-CN.toml +++ b/i18n/zh-CN.toml @@ -109,7 +109,9 @@ comments = "条评论" author = "作者" updatedOnDate = "更新于 {{ .Date }}" readMarkdown = "阅读原始文档" +viewSource = "查看源码" editThisPage = "编辑此页" +reportIssue = "报告问题" back = "返回" home = "主页" readMore = "阅读全文" diff --git a/i18n/zh-TW.toml b/i18n/zh-TW.toml index 501c36f9..e5325233 100644 --- a/i18n/zh-TW.toml +++ b/i18n/zh-TW.toml @@ -109,7 +109,9 @@ comments = "條評論" author = "作者" updatedOnDate = "更新於 {{ .Date }}" readMarkdown = "閱讀原始文檔" +viewSource = "查看原始碼" editThisPage = "編輯此頁" +reportIssue = "報告問題" back = "返回" home = "主頁" readMore = "閱讀全文" diff --git a/layouts/partials/init/detection-deprecated.html b/layouts/partials/init/detection-deprecated.html index 024a0ef5..cb24098c 100644 --- a/layouts/partials/init/detection-deprecated.html +++ b/layouts/partials/init/detection-deprecated.html @@ -16,6 +16,9 @@ {{- $warns = $warns | append "The parameter `footer.siteTime` has changed to a Map since v0.2.17. Please correct the format!" -}} {{- end -}} {{- end -}} +{{- with .Site.Params.gitRepo | or .Site.Params.page.edit -}} + {{- $warns = $warns | append "The parameter `params.gitRepo` and `params.page.edit` is deprecated since v0.3.0, use `params.gitInfo` instead." -}} +{{- end -}} {{- if len $warns -}} {{- warnf "Deprecated parameter detection until %v\n - %v\n\n" (.Scratch.Get "version") (delimit $warns "\n - ") -}} diff --git a/layouts/partials/single/footer.html b/layouts/partials/single/footer.html index b41558ce..9d0060f8 100644 --- a/layouts/partials/single/footer.html +++ b/layouts/partials/single/footer.html @@ -1,5 +1,19 @@ {{- $params := .Scratch.Get "params" -}} -{{- $gitRepo := (strings.TrimSuffix "/" .Site.Params.gitRepo) -}} + +{{- /* Git info */ -}} +{{- $gitRepo := "" -}} +{{- $blobURL := "" -}} +{{- $sourceURL := "" -}} +{{- $editURL := "" -}} +{{- $reportURL := "" -}} +{{- with .Site.Params.gitInfo -}} + {{- if .Repo -}} + {{- $gitRepo = strings.TrimSuffix "/" .Repo -}} + {{- $blobURL = printf "%v/blob/%v/%v/{path}" $gitRepo .Branch .Dir -}} + {{- $editURL = printf "%v/edit/%v/%v/{path}" $gitRepo .Branch .Dir -}} + {{- $reportURL = printf "%v/issues/new?%v" $gitRepo .IssueTpl -}} + {{- end -}} +{{- end -}}
@@ -27,25 +41,33 @@