Feat: add page param linkToVscode to show link to view the post in VSCode

This commit is contained in:
Cell
2025-04-24 17:13:51 +08:00
parent 1360438540
commit c21914dd49
17 changed files with 26 additions and 5 deletions
+2
View File
@@ -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
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -124,6 +124,7 @@ readMarkdown = "मार्कडाउन पढ़ें"
viewSource = "स्रोत देखें"
editThisPage = "इस पृष्ठ को संपादित करें"
reportIssue = "समस्या की रिपोर्ट करें"
openInEditor = "संपादक में खोलें"
back = "पीछे"
home = "घर"
readMore = "और पढ़ें"
+1
View File
@@ -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ù"
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -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"
+1
View File
@@ -123,6 +123,7 @@ readMarkdown = "Читать Markdown"
viewSource = "Просмотреть источник"
editThisPage = "Редактировать эту страницу"
reportIssue = "Сообщить о проблеме"
openInEditor = "Открыть в редакторе"
back = "Назад"
home = "Домой"
readMore = "Читать больше"
+1
View File
@@ -123,6 +123,7 @@ readMarkdown = "Читај Markdown"
viewSource = "Погледај извор"
editThisPage = "Уреди ову страницу"
reportIssue = "Пријави проблем"
openInEditor = "Отвори у уреднику"
back = "Назад"
home = "Почетна"
readMore = "Прочитај више"
+1
View File
@@ -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"
+1
View File
@@ -121,6 +121,7 @@ readMarkdown = "阅读原始文档"
viewSource = "查看源码"
editThisPage = "编辑此页"
reportIssue = "报告问题"
openInEditor = "在编辑器中打开"
back = "返回"
home = "主页"
readMore = "阅读全文"
+1
View File
@@ -121,6 +121,7 @@ readMarkdown = "閱讀原始文檔"
viewSource = "查看原始碼"
editThisPage = "編輯此頁"
reportIssue = "報告問題"
openInEditor = "在編輯器中打開"
back = "返回"
home = "主頁"
readMore = "閱讀全文"
+1 -1
View File
@@ -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" . -}}
+9 -4
View File
@@ -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 -}}