Add repository-links feature.
This commit is contained in:
parent
beb5232b70
commit
4d295fa782
19 changed files with 126 additions and 3 deletions
16
README.md
16
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 <https://github.com/KaTeX/KaTeX/releases>. Unpack and place the resulting "katex" directory in the root `static` directory.
|
||||
|
|
|
|||
|
|
@ -97,6 +97,15 @@ article {
|
|||
text-align: end;
|
||||
}
|
||||
|
||||
.repository-links {
|
||||
justify-content: end;
|
||||
align-items: center;
|
||||
|
||||
svg {
|
||||
order: 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Navigation
|
||||
|
||||
.main-menu {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@ other = "محتوى حديث"
|
|||
[string_see_also]
|
||||
other = "See also"
|
||||
|
||||
[string_edit]
|
||||
other = "Edit"
|
||||
|
||||
[string_view]
|
||||
other = "View"
|
||||
|
||||
[js_required]
|
||||
other = "يجب تفعيل جافاسكريبت في المتصفح لاستخدام هذه الوظيفة."
|
||||
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
||||
|
|
|
|||
|
|
@ -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ä."
|
||||
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@ other = "תוכן מעודכן"
|
|||
[string_see_also]
|
||||
other = "See also"
|
||||
|
||||
[string_edit]
|
||||
other = "Edit"
|
||||
|
||||
[string_view]
|
||||
other = "View"
|
||||
|
||||
[js_required]
|
||||
other = "javascript פונקציה זו חייבת"
|
||||
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@ other = "Скорашњи садржај"
|
|||
[string_see_also]
|
||||
other = "Такође погледајте"
|
||||
|
||||
[string_edit]
|
||||
other = "Edit"
|
||||
|
||||
[string_view]
|
||||
other = "View"
|
||||
|
||||
[js_required]
|
||||
other = "Морате имати омогућен Јаваскрипт да би користили ову функцију."
|
||||
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
||||
|
|
|
|||
|
|
@ -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."
|
||||
|
||||
|
|
|
|||
|
|
@ -52,6 +52,12 @@ other = "近期文章"
|
|||
[string_see_also]
|
||||
other = "参见"
|
||||
|
||||
[string_edit]
|
||||
other = "Edit"
|
||||
|
||||
[string_view]
|
||||
other = "View"
|
||||
|
||||
[js_required]
|
||||
other = "要使用此功能, 必须先启用 JavaScript"
|
||||
|
||||
|
|
|
|||
|
|
@ -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 -}}
|
||||
</article>
|
||||
</main>
|
||||
{{ end -}}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<aside class="related layout__related">
|
||||
<aside class="related">
|
||||
{{ $related := site.RegularPages.Related . | first 3 -}}
|
||||
{{ with $related -}}
|
||||
<h2>{{ i18n "string_see_also" }}</h2>
|
||||
|
|
|
|||
14
layouts/partials/repository-links.html
Normal file
14
layouts/partials/repository-links.html
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{{ if .File -}}
|
||||
{{ with site.Params.repository -}}
|
||||
{{ $branch := .branch | default "main" -}}
|
||||
{{ $path := strings.TrimPrefix hugo.WorkingDir .File.Filename -}}
|
||||
{{ $edithref := printf .urlPatternEdit .owner .repo $branch $path | urls.JoinPath -}}
|
||||
{{ $viewhref := printf .urlPatternView .owner .repo $branch $path | urls.JoinPath -}}
|
||||
<div class="repository-links flex-inline meta">
|
||||
<svg width="30" height="30" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 92 92"><defs><clipPath id="a"><path d="M0 .113h91.887V92H0Zm0 0"/></clipPath></defs><g clip-path="url(#a)"><path style="stroke:none;fill-rule:nonzero;fill:#100f0d;fill-opacity:1" d="M90.156 41.965 50.036 1.848a5.913 5.913 0 0 0-8.368 0l-8.332 8.332 10.566 10.566a7.03 7.03 0 0 1 7.23 1.684 7.043 7.043 0 0 1 1.673 7.277l10.183 10.184a7.026 7.026 0 0 1 7.278 1.672 7.04 7.04 0 0 1 0 9.957 7.045 7.045 0 0 1-9.961 0 7.038 7.038 0 0 1-1.532-7.66l-9.5-9.497V59.36a7.04 7.04 0 0 1 1.86 11.29 7.04 7.04 0 0 1-9.957 0 7.04 7.04 0 0 1 0-9.958 7.034 7.034 0 0 1 2.308-1.539V33.926a7.001 7.001 0 0 1-2.308-1.535 7.049 7.049 0 0 1-1.516-7.7L29.242 14.273 1.734 41.777a5.918 5.918 0 0 0 0 8.371L41.855 90.27a5.92 5.92 0 0 0 8.368 0l39.933-39.934a5.925 5.925 0 0 0 0-8.371"/></g></svg>
|
||||
<a href="{{ $viewhref }}" rel="external">{{ i18n "string_view" }}</a>
|
||||
<a href="{{ $edithref }}" rel="external">{{ i18n "string_edit" }}</a>
|
||||
</div>
|
||||
{{ end -}}
|
||||
{{ end -}}
|
||||
|
||||
Loading…
Reference in a new issue