topbar: edit button supports page editURL param before site one

Signed-off-by: Maxime Soulé <btik-git@scoubidou.com>
This commit is contained in:
Maxime Soulé 2024-01-23 11:50:32 +01:00
parent 13b4513688
commit 7954509934
No known key found for this signature in database
GPG key ID: 724C0124FD0BDACF

View file

@ -4,12 +4,12 @@
{{- with .page }} {{- with .page }}
{{- $format := partial "get-format.hugo" . }} {{- $format := partial "get-format.hugo" . }}
{{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }} {{- $outputFormat := partial "output-format.hugo" (dict "page" . "format" $format) }}
{{- $editURL := .Site.Params.editURL | default "" }} {{- if and (eq $outputFormat "html") (or .Site.Params.editURL .Params.editURL) .File }}
{{- if and (eq $outputFormat "html") $editURL .File }} {{- $href := or .Params.editURL (printf "%s%s%s" .Site.Params.editURL (strings.TrimLeft "/" (replace .File.Dir "\\" "/")) .File.LogicalName) }}
{{- partial "topbar/func/button.html" (dict {{- partial "topbar/func/button.html" (dict
"page" . "page" .
"class" "topbar-button-edit" "class" "topbar-button-edit"
"href" (printf "%s%s%s" $editURL (strings.TrimLeft "/" (replace .File.Dir "\\" "/")) .File.LogicalName) "href" $href
"icon" "pen" "icon" "pen"
"onwidths" $onwidths "onwidths" $onwidths
"onwidthm" $onwidthm "onwidthm" $onwidthm