mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
theme: edge cases for multilang portable links #377
This commit is contained in:
parent
087c77dff0
commit
1ff5026bec
2 changed files with 14 additions and 13 deletions
|
@ -57,12 +57,14 @@ This document shows you what's new in the latest release. For a detailed list of
|
||||||
|
|
||||||
The following types of linking are supported:
|
The following types of linking are supported:
|
||||||
|
|
||||||
| link | description |
|
| link | description |
|
||||||
| -------------------------------- | ------------------------------- |
|
| ---------------------------------- | ------------------------------------------- |
|
||||||
| `[generator](basics/generator)` | absolute from your project root |
|
| `[generator](en/basics/generator)` | absolute from your project root (multilang) |
|
||||||
| `[generator](/basics/generator)` | absolute from your project root |
|
| `[generator](/en/basics/generator)`| absolute from your project root (multilang) |
|
||||||
| `[generator](./../generator)` | relative from the current page |
|
| `[generator](basics/generator)` | absolute from your current language root |
|
||||||
| `[generator](../generator)` | relative from the current page |
|
| `[generator](/basics/generator)` | absolute from your current language root |
|
||||||
|
| `[generator](./../generator)` | relative from the current page |
|
||||||
|
| `[generator](../generator)` | relative from the current page |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -25,19 +25,18 @@
|
||||||
{{- with $url.Fragment }}
|
{{- with $url.Fragment }}
|
||||||
{{- $fragment = printf "#%s" . }}
|
{{- $fragment = printf "#%s" . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- $path := strings.TrimSuffix ".html" $url.Path }}
|
{{- $path := printf "%s/" (strings.TrimPrefix "/" (strings.TrimSuffix "/" $url.Path)) }}
|
||||||
{{- $path := $url.Path }}
|
{{- with $page.Page.GetPage (strings.TrimSuffix "/" $path | default "/") }}
|
||||||
{{- with $page.Page.GetPage $path }}
|
|
||||||
{{- $url = printf "%s%s" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) $fragment }}
|
{{- $url = printf "%s%s" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) $fragment }}
|
||||||
{{- $found = true }}
|
{{- $found = true }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- /* is it a link into another translation? */}}
|
{{- /* is it a link into another translation? */}}
|
||||||
{{- range $page.Site.Languages }}
|
{{- range $page.Site.Languages }}
|
||||||
{{- $lang := .Lang }}
|
{{- $lang := .Lang }}
|
||||||
{{- $prefix := printf "/%s" $lang }}
|
{{- $prefix := printf "%s/" $lang }}
|
||||||
{{- if strings.HasPrefix $prefix $path }}
|
{{- if strings.HasPrefix $path $prefix }}
|
||||||
{{- $path := strings.TrimPrefix $prefix $path }}
|
{{- $path = strings.TrimPrefix $prefix $path | default "/" }}
|
||||||
{{- with $page.Page.GetPage $path }}
|
{{- with $page.Site.GetPage (strings.TrimSuffix "/" $path | default "/") }}
|
||||||
{{- range .Page.AllTranslations }}
|
{{- range .Page.AllTranslations }}
|
||||||
{{- if eq $lang .Lang }}
|
{{- if eq $lang .Lang }}
|
||||||
{{- $url = printf "%s%s" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) $fragment }}
|
{{- $url = printf "%s%s" (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) $fragment }}
|
||||||
|
|
Loading…
Reference in a new issue