mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-18 10:50:24 +00:00
piratify: make it work with Hugo 0.123 #778
This commit is contained in:
parent
e516a1bdd1
commit
3333a4133d
2 changed files with 17 additions and 8 deletions
|
@ -7,7 +7,7 @@ A theme for [Hugo](https://gohugo.io/) designed for documentation.
|
|||
|
||||
[★ What's new in the latest release ★](basics/migration)
|
||||
|
||||
![Image of the Relearn theme in light and dark mode on phone, tablet and desktop](images/hero.png?width=100%&height=100%)
|
||||
![Image of the Relearn theme in light and dark mode on phone, tablet and desktop](/images/hero.png?width=100%&height=100%)
|
||||
|
||||
## Motivation
|
||||
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
{{- $writenotice := cond (ne .writenotice nil) .writenotice false }}
|
||||
{{- $langtrg := "pir" }}
|
||||
{{- $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 }}
|
||||
{{- $c := "" }}
|
||||
{{- $srcPage := "" }}
|
||||
|
@ -34,6 +32,7 @@
|
|||
{{- break }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $y := $c }}
|
||||
{{- if eq $page.Language.Lang $langtrg }}
|
||||
{{- if $writenotice }}
|
||||
{{- partial "shortcodes/notice.html" (dict
|
||||
|
@ -111,7 +110,9 @@
|
|||
"(\\w)(?:[aeiou])mizes([\\s\\n<.,;?!:])" "'mizes"
|
||||
"(\\w)(?:[aeiou])nize([\\s\\n<.,;?!:])" "'nize"
|
||||
"(\\w)(?:[aeiou])nizes([\\s\\n<.,;?!:])" "'nizes"
|
||||
(printf "(href)=\"%s([^\"]*?\")" $baseURLpath) (printf "=\"%s%s/" $baseURLpath $langtrg)
|
||||
-}}
|
||||
{{- $links := slice
|
||||
"href"
|
||||
-}}
|
||||
{{- $fix := dict
|
||||
"warn'n" "warning"
|
||||
|
@ -125,13 +126,21 @@
|
|||
{{- range $from, $to := $specials }}
|
||||
{{- $c = replaceRE $from (printf "${1}%s${2}" $to) $c }}
|
||||
{{- end }}
|
||||
{{- range $attr := $links }}
|
||||
{{- $c = replaceRE (printf "\\b(%s)(=\"[^\"]*?\")" $attr) "${1} data-piratify${2}" $c }}
|
||||
{{- $m := findRESubmatch (printf "%s data-piratify=\"([^\"]*?)\"" $attr) $c }}
|
||||
{{- range $m }}
|
||||
{{- $r := printf "%s=\"%s\"" $attr (index . 1) }}
|
||||
{{- $u := urls.Parse (index . 1) }}
|
||||
{{- if and (not $u.IsAbs) $u.Path }}
|
||||
{{- $r = printf "%s=\"/%s%s\"" $attr $langtrg (index . 1) }}
|
||||
{{- end }}
|
||||
{{- $c = replace $c (index . 0) $r }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- range $from, $to := $fix }}
|
||||
{{- $c = replace $c $from $to }}
|
||||
{{- end }}
|
||||
{{- if (int (len $l)) }}
|
||||
{{- $c = replaceRE "(src|href)=\"(images/[^\"]*?\")" (printf "${1}=\"%s${2}" $l) $c }}
|
||||
{{- end }}
|
||||
{{- $c = replaceRE (printf "(src|href)=\"([^\"]*?)/%s/([^\"]*?.files/[^\"]*?\")" $langtrg) "${1}=\"${2}/${3}" $c }}
|
||||
{{- if $srcPage }}
|
||||
{{- range $page.Site.Params.relearn.dependencies }}
|
||||
{{- $has := printf "has%s" .name }}
|
||||
|
|
Loading…
Reference in a new issue