- {{- if and (site.Params.editURL.enable) (eq site.Params.editURL.where "single") -}}
- {{- $editURL := site.Params.editURL.base | default "" -}}
- {{- with .Params.editURL -}}
- {{/* if `editURL` is set in the front matter */}}
- {{- $editURL = . -}}
- {{- else -}}
- {{- with .File -}}
- {{/* `.FileInfo.Meta.SourceRoot` is a Hugo internal field, e.g. `/path/to/repo/content/en/` */}}
- {{- $sourceDir := replace (strings.TrimPrefix .FileInfo.Meta.BaseDir .FileInfo.Meta.SourceRoot) "\\" "/" -}}
- {{- $sourceDir = strings.TrimPrefix "/content" $sourceDir -}}
- {{- $path := replace .Path "\\" "/" -}}
- {{- $editURL = urls.JoinPath $editURL $sourceDir $path -}}
- {{- end -}}
- {{- end -}}
-
+{{ partial "components/edit-url.html" (dict "source" "single" "context" .) }}
{{- with .Lastmod -}}
{{ $datetime := (time.Format "2006-01-02T15:04:05.000Z" .) }}
{{ $lastUpdated }}
diff --git a/layouts/partials/toc.html b/layouts/partials/toc.html
index 4c25671f..d1733434 100644
--- a/layouts/partials/toc.html
+++ b/layouts/partials/toc.html
@@ -24,22 +24,7 @@
{{/* TOC bottom part */}}
- {{- if and (site.Params.editURL.enable) (eq site.Params.editURL.where "toc") -}}
- {{- $editURL := site.Params.editURL.base | default "" -}}
- {{- with .Params.editURL -}}
- {{/* if `editURL` is set in the front matter */}}
- {{- $editURL = . -}}
- {{- else -}}
- {{- with .File -}}
- {{/* `.FileInfo.Meta.SourceRoot` is a Hugo internal field, e.g. `/path/to/repo/content/en/` */}}
- {{- $sourceDir := replace (strings.TrimPrefix .FileInfo.Meta.BaseDir .FileInfo.Meta.SourceRoot) "\\" "/" -}}
- {{- $sourceDir = strings.TrimPrefix "/content" $sourceDir -}}
- {{- $path := replace .Path "\\" "/" -}}
- {{- $editURL = urls.JoinPath $editURL $sourceDir $path -}}
- {{- end -}}
- {{- end -}}
-
{{ $editThisPage }}
- {{- end -}}
+ {{ partial "components/edit-url.html" (dict "source" "toc" "context" .) }}
{{/* Scroll To Top */}}