From c21914dd492c197b9d42a912a8d08671146fbef1 Mon Sep 17 00:00:00 2001 From: Cell <1024@lruihao.cn> Date: Thu, 24 Apr 2025 17:13:51 +0800 Subject: [PATCH] :sparkles: Feat: add page param `linkToVscode` to show link to view the post in VSCode --- hugo.toml | 2 ++ i18n/de.toml | 1 + i18n/en.toml | 1 + i18n/es.toml | 1 + i18n/fr.toml | 1 + i18n/hi.toml | 1 + i18n/it.toml | 1 + i18n/pl.toml | 1 + i18n/pt-BR.toml | 1 + i18n/ro.toml | 1 + i18n/ru.toml | 1 + i18n/sr.toml | 1 + i18n/vi.toml | 1 + i18n/zh-CN.toml | 1 + i18n/zh-TW.toml | 1 + layouts/partials/init/index.html | 2 +- layouts/partials/single/footer.html | 13 +++++++++---- 17 files changed, 26 insertions(+), 5 deletions(-) diff --git a/hugo.toml b/hugo.toml index 7dad6783..07dd1a9f 100644 --- a/hugo.toml +++ b/hugo.toml @@ -1013,6 +1013,8 @@ enableEmoji = true linkToEdit = true # FixIt 0.3.0 | NEW whether to show link to report issue for the post linkToReport = true + # FixIt 0.3.20 | NEW whether to show link to view the post in VSCode + linkToVscode = true # FixIt 0.3.10 | CHANGED Page style ["narrow", "normal", "wide", ...] pageStyle = "normal" # FixIt 0.2.17 | CHANGED Auto Bookmark Support diff --git a/i18n/de.toml b/i18n/de.toml index e738ff67..54548d85 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -123,6 +123,7 @@ readMarkdown = "Markdown anzeigen" viewSource = "Quelle anzeigen" editThisPage = "Diese Seite bearbeiten" reportIssue = "Problem melden" +openInEditor = "Im Editor öffnen" back = "Zurück" home = "Startseite" readMore = "Mehr lesen" diff --git a/i18n/en.toml b/i18n/en.toml index 6705f2e8..77cef8c9 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -123,6 +123,7 @@ readMarkdown = "Read Markdown" viewSource = "View source" editThisPage = "Edit this page" reportIssue = "Report issue" +openInEditor = "Open in editor" back = "Back" home = "Home" readMore = "Read More" diff --git a/i18n/es.toml b/i18n/es.toml index 3e5075d4..74e15466 100644 --- a/i18n/es.toml +++ b/i18n/es.toml @@ -123,6 +123,7 @@ readMarkdown = "Leer Markdown" viewSource = "Ver fuente" editThisPage = "Editar esta página" reportIssue = "Reportar problema" +openInEditor = "Abrir en el editor" back = "Regresar" home = "Inicio" readMore = "Leer más" diff --git a/i18n/fr.toml b/i18n/fr.toml index 3a31e1c0..020a9a7c 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -123,6 +123,7 @@ readMarkdown = "Ouvrir le Markdown" viewSource = "Voir la source" editThisPage = "Modifier cette page" reportIssue = "Signaler un problème" +openInEditor = "Ouvrir dans l'éditeur" back = "Retour" home = "Accueil" readMore = "En savoir plus" diff --git a/i18n/hi.toml b/i18n/hi.toml index e3ac0b72..07e5ed6f 100644 --- a/i18n/hi.toml +++ b/i18n/hi.toml @@ -124,6 +124,7 @@ readMarkdown = "मार्कडाउन पढ़ें" viewSource = "स्रोत देखें" editThisPage = "इस पृष्ठ को संपादित करें" reportIssue = "समस्या की रिपोर्ट करें" +openInEditor = "संपादक में खोलें" back = "पीछे" home = "घर" readMore = "और पढ़ें" diff --git a/i18n/it.toml b/i18n/it.toml index 0f1317fa..55575547 100644 --- a/i18n/it.toml +++ b/i18n/it.toml @@ -123,6 +123,7 @@ readMarkdown = "Leggi Markdown" viewSource = "Visualizza sorgente" editThisPage = "Modifica questa pagina" reportIssue = "Segnala un problema" +openInEditor = "Apri nell'editor" back = "Indietro" home = "Home" readMore = "Leggi di più" diff --git a/i18n/pl.toml b/i18n/pl.toml index 901096fb..f6f65b8a 100644 --- a/i18n/pl.toml +++ b/i18n/pl.toml @@ -123,6 +123,7 @@ readMarkdown = "Zobacz Markdown" viewSource = "Zobacz źródło" editThisPage = "Edytuj tą stronę" reportIssue = "Zgłoś problem" +openInEditor = "Otwórz w edytorze" back = "Wstecz" home = "Strona główna" readMore = "Czytaj więcej" diff --git a/i18n/pt-BR.toml b/i18n/pt-BR.toml index f11fe794..de65a522 100644 --- a/i18n/pt-BR.toml +++ b/i18n/pt-BR.toml @@ -124,6 +124,7 @@ readMarkdown = "Leia em Markdown" viewSource = "Ver a fonte" editThisPage = "Editar esta página" reportIssue = "Reportar problema" +openInEditor = "Abrir no editor" back = "Voltar" home = "Home" readMore = "Leia mais" diff --git a/i18n/ro.toml b/i18n/ro.toml index 6f7a6e94..e519942e 100644 --- a/i18n/ro.toml +++ b/i18n/ro.toml @@ -123,6 +123,7 @@ readMarkdown = "Citire Markdown" viewSource = "Vezi sursa" editThisPage = "Editați această pagină" reportIssue = "Raportează o problemă" +openInEditor = "Deschide în editor" back = "Înapoi" home = "Acasă" readMore = "Citește mai mult" diff --git a/i18n/ru.toml b/i18n/ru.toml index 718be87b..73e2b21d 100644 --- a/i18n/ru.toml +++ b/i18n/ru.toml @@ -123,6 +123,7 @@ readMarkdown = "Читать Markdown" viewSource = "Просмотреть источник" editThisPage = "Редактировать эту страницу" reportIssue = "Сообщить о проблеме" +openInEditor = "Открыть в редакторе" back = "Назад" home = "Домой" readMore = "Читать больше" diff --git a/i18n/sr.toml b/i18n/sr.toml index 2326468a..a4687a0f 100644 --- a/i18n/sr.toml +++ b/i18n/sr.toml @@ -123,6 +123,7 @@ readMarkdown = "Читај Markdown" viewSource = "Погледај извор" editThisPage = "Уреди ову страницу" reportIssue = "Пријави проблем" +openInEditor = "Отвори у уреднику" back = "Назад" home = "Почетна" readMore = "Прочитај више" diff --git a/i18n/vi.toml b/i18n/vi.toml index c95e307a..b70c834a 100644 --- a/i18n/vi.toml +++ b/i18n/vi.toml @@ -122,6 +122,7 @@ readMarkdown = "Đọc với định dạng Markdown" viewSource = "Xem mã nguồn" editThisPage = "Chỉnh sửa trang này" reportIssue = "Báo cáo lỗi" +openInEditor = "Mở trong trình chỉnh sửa" back = "Quay lại" home = "Trang chủ" readMore = "Đọc thêm" diff --git a/i18n/zh-CN.toml b/i18n/zh-CN.toml index b74cb223..c5f766ca 100644 --- a/i18n/zh-CN.toml +++ b/i18n/zh-CN.toml @@ -121,6 +121,7 @@ readMarkdown = "阅读原始文档" viewSource = "查看源码" editThisPage = "编辑此页" reportIssue = "报告问题" +openInEditor = "在编辑器中打开" back = "返回" home = "主页" readMore = "阅读全文" diff --git a/i18n/zh-TW.toml b/i18n/zh-TW.toml index 5bf010db..d6a00a35 100644 --- a/i18n/zh-TW.toml +++ b/i18n/zh-TW.toml @@ -121,6 +121,7 @@ readMarkdown = "閱讀原始文檔" viewSource = "查看原始碼" editThisPage = "編輯此頁" reportIssue = "報告問題" +openInEditor = "在編輯器中打開" back = "返回" home = "主頁" readMore = "閱讀全文" diff --git a/layouts/partials/init/index.html b/layouts/partials/init/index.html index 1fa5c4ef..e9870e1a 100644 --- a/layouts/partials/init/index.html +++ b/layouts/partials/init/index.html @@ -1,4 +1,4 @@ -{{- .Scratch.Set "version" "v0.3.20-669f8364" -}} +{{- .Scratch.Set "version" "v0.3.20-13604385" -}} {{- .Scratch.Set "this" dict -}} {{- partial "init/detection-env.html" . -}} diff --git a/layouts/partials/single/footer.html b/layouts/partials/single/footer.html index f1d6efb6..d8fc8614 100644 --- a/layouts/partials/single/footer.html +++ b/layouts/partials/single/footer.html @@ -48,27 +48,32 @@ {{- $linkOptions := slice -}} {{- if $params.LinkToMarkdown -}} {{- with .OutputFormats.Get "markdown" -}} - {{- $options := dict "Class" "link-to-markdown" "Destination" .RelPermalink "Title" (T "single.readMarkdown") "Content" (T "single.readMarkdown") "externalIcon" false -}} + {{- $options := dict "Class" "link-to-markdown" "Destination" .RelPermalink "Title" (T "single.readMarkdown") "Content" (T "single.readMarkdown") -}} {{- $linkOptions = $linkOptions | append $options -}} {{- end -}} {{- end -}} {{- if $params.LinkToSource | and $gitRepo -}} {{- $link := replace $blobURL "{path}" $.File.Path -}} {{- $sourceURL = $params.sourceURL | default (add $link "?plain=1") -}} - {{- $options := dict "Class" "link-to-source" "Destination" $sourceURL "Title" (T "single.viewSource") "Content" (T "single.viewSource") "externalIcon" false -}} + {{- $options := dict "Class" "link-to-source" "Destination" $sourceURL "Title" (T "single.viewSource") "Content" (T "single.viewSource") -}} {{- $linkOptions = $linkOptions | append $options -}} {{- end -}} {{- if $params.LinkToEdit | and $gitRepo -}} {{- $link := replace $editURL "{path}" $.File.Path -}} {{- $editURL = $params.editURL | default $link -}} - {{- $options := dict "Class" "link-to-edit" "Destination" $editURL "Title" (T "single.editThisPage") "Content" (T "single.editThisPage") "externalIcon" false -}} + {{- $options := dict "Class" "link-to-edit" "Destination" $editURL "Title" (T "single.editThisPage") "Content" (T "single.editThisPage") -}} {{- $linkOptions = $linkOptions | append $options -}} {{- end -}} {{- if $params.LinkToReport | and $gitRepo -}} {{- $link := replace $reportURL "{title}" ($.Title | urlquery) -}} {{- $link = replace $link "{URL}" $.Permalink -}} {{- $link = replace $link "{sourceURL}" $sourceURL -}} - {{- $options := dict "Class" "link-to-report" "Destination" $link "Title" (T "single.reportIssue") "Content" (T "single.reportIssue") "externalIcon" false -}} + {{- $options := dict "Class" "link-to-report" "Destination" $link "Title" (T "single.reportIssue") "Content" (T "single.reportIssue") -}} + {{- $linkOptions = $linkOptions | append $options -}} + {{- end -}} + {{- if $params.LinkToVscode | and hugo.IsServer -}} + {{- $link := printf "vscode://file/%v" $.File.Filename -}} + {{- $options := dict "Class" "link-to-vscode" "Destination" $link "Title" (T "single.openInEditor") "Content" (T "single.openInEditor") -}} {{- $linkOptions = $linkOptions | append $options -}} {{- end -}} {{- range $linkOptions -}}