From 4d295fa7822baa15b51ca98273bba18c98624ec9 Mon Sep 17 00:00:00 2001 From: Fredrik Jonsson Date: Mon, 13 Jan 2025 16:47:13 +0100 Subject: [PATCH] Add repository-links feature. --- README.md | 16 ++++++++++++++++ assets/sass/_zen.scss | 9 +++++++++ i18n/ar.toml | 6 ++++++ i18n/da.toml | 6 ++++++ i18n/de.toml | 6 ++++++ i18n/en.toml | 6 ++++++ i18n/fi.toml | 6 ++++++ i18n/fr.toml | 6 ++++++ i18n/he.toml | 6 ++++++ i18n/id.toml | 6 ++++++ i18n/nb.toml | 6 ++++++ i18n/pt.toml | 6 ++++++ i18n/sr.toml | 6 ++++++ i18n/sv.toml | 6 ++++++ i18n/sw.toml | 6 ++++++ i18n/zh-cn.toml | 6 ++++++ layouts/_default/single.html | 4 ++-- layouts/partials/relatedposts.html | 2 +- layouts/partials/repository-links.html | 14 ++++++++++++++ 19 files changed, 126 insertions(+), 3 deletions(-) create mode 100644 layouts/partials/repository-links.html diff --git a/README.md b/README.md index c963ee0..69010d7 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ Quickstart a new site with the Zen theme by using the [Zen demo repo as a templa * [Content security policy headers](#Content-security-policy-headers) * [Choose between using AlpineJS, jQuery or Umbrella JS](#choose-between-using-alpinejs-jquery-or-umbrella-js) * [Use npm to lint Sass and JavaScript](#use-npm-to-lint-sass-and-javascript) +* [Repository links](#repository-links) * [Math typesetting with KaTeX](#math-typesetting-with-katex) * [Getting help](#getting-help) * [Credits](#credits) @@ -865,6 +866,21 @@ Node.js software you need. To install them run: nmp run lint (project + theme) +## Repository links + +Add view and edit repo links on your post. Activates when you add repository settings, see example for GitHub below. See more in the partial `repository-links.html`. + +```yaml +repository: + branch: "main" + owner: "kalle" + repo: "myhugowebsite" + urlPatternEdit: "https://github.com/%s/%s/edit/%s/%s" + urlPatternView: "https://github.com/%s/%s/blob/%s/%s" +``` + +Copied from example by [jmooring](https://discourse.gohugo.io/t/hugo-v0-112-0-new-template-functions/44512) + ## Math typesetting with KaTeX Download the latest release from . Unpack and place the resulting "katex" directory in the root `static` directory. diff --git a/assets/sass/_zen.scss b/assets/sass/_zen.scss index c41f8b9..b464cad 100644 --- a/assets/sass/_zen.scss +++ b/assets/sass/_zen.scss @@ -97,6 +97,15 @@ article { text-align: end; } +.repository-links { + justify-content: end; + align-items: center; + + svg { + order: 1; + } +} + // Navigation .main-menu { diff --git a/i18n/ar.toml b/i18n/ar.toml index d88b305..cbef073 100644 --- a/i18n/ar.toml +++ b/i18n/ar.toml @@ -52,6 +52,12 @@ other = "محتوى حديث" [string_see_also] other = "See also" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "يجب تفعيل جافاسكريبت في المتصفح لاستخدام هذه الوظيفة." diff --git a/i18n/da.toml b/i18n/da.toml index 1184998..6ce8a54 100644 --- a/i18n/da.toml +++ b/i18n/da.toml @@ -52,6 +52,12 @@ other = "Seneste indhold" [string_see_also] other = "Se også" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "Du skal have Javascript slået til for at bruge denne funktion." diff --git a/i18n/de.toml b/i18n/de.toml index b56cf8f..449948c 100644 --- a/i18n/de.toml +++ b/i18n/de.toml @@ -52,6 +52,12 @@ other = "Aktuelle Inhalte" [string_see_also] other = "Siehe auch" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "Javascript muss aktiviert sein um dieses Kontaktformular zu nutzen." diff --git a/i18n/en.toml b/i18n/en.toml index e674867..7627e30 100644 --- a/i18n/en.toml +++ b/i18n/en.toml @@ -52,6 +52,12 @@ other = "Recent content" [string_see_also] other = "See also" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "You must have Javascript enabled to use this function." diff --git a/i18n/fi.toml b/i18n/fi.toml index 533e6da..4fa703b 100644 --- a/i18n/fi.toml +++ b/i18n/fi.toml @@ -52,6 +52,12 @@ other = "Viimeaikainen sisältö" [string_see_also] other = "Lue myös" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "Javascript-teknologia täytyy olla tuettuna jotta tämä toiminto on käytössä." diff --git a/i18n/fr.toml b/i18n/fr.toml index 8b8934d..77671cb 100644 --- a/i18n/fr.toml +++ b/i18n/fr.toml @@ -52,6 +52,12 @@ other = "Contenu récent" [string_see_also] other = "See also" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "Javascript doit être activé pour utiliser ce formulaire de contact." diff --git a/i18n/he.toml b/i18n/he.toml index 769a544..92ca4b2 100644 --- a/i18n/he.toml +++ b/i18n/he.toml @@ -52,6 +52,12 @@ other = "תוכן מעודכן" [string_see_also] other = "See also" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "javascript פונקציה זו חייבת" diff --git a/i18n/id.toml b/i18n/id.toml index f576feb..f63334b 100644 --- a/i18n/id.toml +++ b/i18n/id.toml @@ -52,6 +52,12 @@ other = "Konten Terkini" [string_see_also] other = "See also" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "Anda harus mengaktifkan Javascript untuk menggunakan fasilitas ini." diff --git a/i18n/nb.toml b/i18n/nb.toml index 378cf62..123ef1f 100644 --- a/i18n/nb.toml +++ b/i18n/nb.toml @@ -52,6 +52,12 @@ other = "Siste innhold" [string_see_also] other = "See also" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "Du må ha skrudd på Javascript for å bruke denne funksjonen." diff --git a/i18n/pt.toml b/i18n/pt.toml index 7b3e6a8..1c21ebe 100644 --- a/i18n/pt.toml +++ b/i18n/pt.toml @@ -53,6 +53,12 @@ other = "Conteúdo recente" [string_see_also] other = "See also" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "Você deve ter o Javascript habilitado para usar este formulário de contato" diff --git a/i18n/sr.toml b/i18n/sr.toml index 3e061f1..41ff50e 100644 --- a/i18n/sr.toml +++ b/i18n/sr.toml @@ -52,6 +52,12 @@ other = "Скорашњи садржај" [string_see_also] other = "Такође погледајте" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "Морате имати омогућен Јаваскрипт да би користили ову функцију." diff --git a/i18n/sv.toml b/i18n/sv.toml index 1273d4d..348f788 100644 --- a/i18n/sv.toml +++ b/i18n/sv.toml @@ -52,6 +52,12 @@ other = "Senaste innehåll" [string_see_also] other = "Se också" +[string_edit] +other = "Redigera" + +[string_view] +other = "Visa" + [js_required] other = "Du behöver ha Javascript aktiverat för att använda denna funktion." diff --git a/i18n/sw.toml b/i18n/sw.toml index 27c7d7b..216fb47 100644 --- a/i18n/sw.toml +++ b/i18n/sw.toml @@ -52,6 +52,12 @@ other = "Maudhui ya hivi majuzi" [string_see_also] other = "Angalia pia" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "Javascript lazima iwezeshwe ili kutumia chaguo hili la kukokotoa." diff --git a/i18n/zh-cn.toml b/i18n/zh-cn.toml index 23eedea..50b2944 100644 --- a/i18n/zh-cn.toml +++ b/i18n/zh-cn.toml @@ -52,6 +52,12 @@ other = "近期文章" [string_see_also] other = "参见" +[string_edit] +other = "Edit" + +[string_view] +other = "View" + [js_required] other = "要使用此功能, 必须先启用 JavaScript" diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 96eb527..392ed94 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -9,9 +9,9 @@ {{ .Content }} -{{ if $.Param "relatedposts" | default false }}{{ partial "relatedposts.html" . }}{{ end -}} - {{ if ne .Lastmod .Date }}{{ partial "dates.html" . }}{{ end -}} +{{ if site.Params.repository | default false }}{{ partial "repository-links.html" . }}{{ end -}} +{{ if $.Param "relatedposts" | default false }}{{ partial "relatedposts.html" . }}{{ end -}} {{ end -}} diff --git a/layouts/partials/relatedposts.html b/layouts/partials/relatedposts.html index 81b9bcc..418ddc9 100644 --- a/layouts/partials/relatedposts.html +++ b/layouts/partials/relatedposts.html @@ -1,4 +1,4 @@ -