mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-18 19:00:24 +00:00
piratify: reintroduce baseURL
for GitHub
This commit is contained in:
parent
2fe2ef2b7e
commit
b54661e705
1 changed files with 7 additions and 6 deletions
|
@ -8,6 +8,8 @@
|
||||||
{{- $writenotice := cond (ne .writenotice nil) .writenotice false }}
|
{{- $writenotice := cond (ne .writenotice nil) .writenotice false }}
|
||||||
{{- $langtrg := "pir" }}
|
{{- $langtrg := "pir" }}
|
||||||
{{- $langsrc := cond (eq $page.Language.Lang $langtrg) (.langsrc | default "en") $page.Language.Lang }}
|
{{- $langsrc := cond (eq $page.Language.Lang $langtrg) (.langsrc | default "en") $page.Language.Lang }}
|
||||||
|
{{- $baseURL := urls.Parse site.BaseURL }}
|
||||||
|
{{- $baseURLpath := $baseURL.Path | default "/" }}
|
||||||
{{- $l := $page.RelPermalink }}
|
{{- $l := $page.RelPermalink }}
|
||||||
{{- $c := "" }}
|
{{- $c := "" }}
|
||||||
{{- $srcPage := "" }}
|
{{- $srcPage := "" }}
|
||||||
|
@ -32,7 +34,6 @@
|
||||||
{{- break }}
|
{{- break }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- $y := $c }}
|
|
||||||
{{- if eq $page.Language.Lang $langtrg }}
|
{{- if eq $page.Language.Lang $langtrg }}
|
||||||
{{- if $writenotice }}
|
{{- if $writenotice }}
|
||||||
{{- partial "shortcodes/notice.html" (dict
|
{{- partial "shortcodes/notice.html" (dict
|
||||||
|
@ -127,13 +128,13 @@
|
||||||
{{- $c = replaceRE $from (printf "${1}%s${2}" $to) $c }}
|
{{- $c = replaceRE $from (printf "${1}%s${2}" $to) $c }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- range $attr := $links }}
|
{{- range $attr := $links }}
|
||||||
{{- $c = replaceRE (printf "\\b(%s)(=\"[^\"]*?\")" $attr) "${1} data-piratify${2}" $c }}
|
{{- $c = replaceRE (printf "\\b(%s)(=\"%s[^\"]*?\")" $attr $baseURLpath) "${1} data-piratify${2}" $c }}
|
||||||
{{- $m := findRESubmatch (printf "%s data-piratify=\"([^\"]*?)\"" $attr) $c }}
|
{{- $m := findRESubmatch (printf "%s data-piratify=\"(%s)([^\"]*?)\"" $attr $baseURLpath) $c }}
|
||||||
{{- range $m }}
|
{{- range $m }}
|
||||||
{{- $r := printf "%s=\"%s\"" $attr (index . 1) }}
|
{{- $r := printf "%s=\"%s\"" $attr (index . 2) }}
|
||||||
{{- $u := urls.Parse (index . 1) }}
|
{{- $u := urls.Parse (index . 2) }}
|
||||||
{{- if and (not $u.IsAbs) $u.Path }}
|
{{- if and (not $u.IsAbs) $u.Path }}
|
||||||
{{- $r = printf "%s=\"/%s%s\"" $attr $langtrg (index . 1) }}
|
{{- $r = printf "%s=\"%s%s/%s\"" $attr $baseURLpath $langtrg (index . 2) }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- $c = replace $c (index . 0) $r }}
|
{{- $c = replace $c (index . 0) $r }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
Loading…
Reference in a new issue