Avoid passing in .Site-variables to geturl.html
Signed-off-by: Danila Fedorin <danila.fedorin@gmail.com>
This commit is contained in:
parent
97e965feec
commit
ec7b58c8ec
|
@ -1,9 +1,11 @@
|
||||||
|
{{- $siteSourceUrl := site.Params.siteSourceUrl -}}
|
||||||
|
{{- $submoduleLinks := site.Data.submodules -}}
|
||||||
{{- $scratch := .scratch -}}
|
{{- $scratch := .scratch -}}
|
||||||
{{- $scratch.Set "bestLength" -1 -}}
|
{{- $scratch.Set "bestLength" -1 -}}
|
||||||
{{- $scratch.Set "bestUrl" (printf "%s/code/%s" .siteSourceUrl .path) -}}
|
{{- $scratch.Set "bestUrl" (printf "%s/code/%s" $siteSourceUrl .path) -}}
|
||||||
{{- $scratch.Set "bestPath" "" -}}
|
{{- $scratch.Set "bestPath" "" -}}
|
||||||
{{- $filePath := .path -}}
|
{{- $filePath := .path -}}
|
||||||
{{- range $path, $url := .submoduleLinks -}}
|
{{- range $path, $url := $submoduleLinks -}}
|
||||||
{{- $bestLength := $scratch.Get "bestLength" -}}
|
{{- $bestLength := $scratch.Get "bestLength" -}}
|
||||||
{{- if and (le $bestLength (len $path)) (hasPrefix $filePath $path) -}}
|
{{- if and (le $bestLength (len $path)) (hasPrefix $filePath $path) -}}
|
||||||
{{- $scratch.Set "bestLength" (len $path) -}}
|
{{- $scratch.Set "bestLength" (len $path) -}}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
|
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1)) }}
|
||||||
{{- $groupconfig := dict
|
{{- $groupconfig := dict
|
||||||
"url" (.Scratch.Get "bestUrl")
|
"url" (.Scratch.Get "bestUrl")
|
||||||
"basePath" (.Scratch.Get "bestPath")
|
"basePath" (.Scratch.Get "bestPath")
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
{{- .Scratch.Set "hidden" (.Get 5) -}}
|
{{- .Scratch.Set "hidden" (.Get 5) -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
{{- partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) -}}
|
{{- partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 1)) -}}
|
||||||
{{- partial "linerangestr.html" (dict "scratch" .Scratch "from" (.Get 2) "to" (.Get 3)) -}}
|
{{- partial "linerangestr.html" (dict "scratch" .Scratch "from" (.Get 2) "to" (.Get 3)) -}}
|
||||||
|
|
||||||
{{- with (.Scratch.Get "hidden") -}}
|
{{- with (.Scratch.Get "hidden") -}}
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 0) "siteSourceUrl" .Site.Params.siteSourceUrl "submoduleLinks" .Site.Data.submodules) }}
|
{{ partial "geturl.html" (dict "scratch" .Scratch "path" (.Get 0)) }}
|
||||||
{{- .Scratch.Get "bestUrl" -}}
|
{{- .Scratch.Get "bestUrl" -}}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user