mirror of
https://github.com/imfing/hextra.git
synced 2025-05-15 18:28:26 -04:00
29 lines
1.3 KiB
HTML
29 lines
1.3 KiB
HTML
{{- $editThisPage := (T "editThisPage") | default "Edit this page"}}
|
|
|
|
{{- $context := .context -}}
|
|
|
|
{{- $linkClass := "hx-mb-4 hx-block hx-text-xs hx-text-gray-500 ltr:hx-text-right rtl:hx-text-left dark:hx-text-gray-400" -}}
|
|
|
|
{{- if and (site.Params.editURL.enable) (eq site.Params.editURL.location .source) -}}
|
|
{{- $editURL := site.Params.editURL.base | default "" -}}
|
|
|
|
{{- with $context.Params.editURL -}}
|
|
{{/* if `editURL` is set in the front matter */}}
|
|
{{- $editURL = . -}}
|
|
{{- else -}}
|
|
{{- with $context.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 -}}
|
|
|
|
{{- if eq site.Params.editURL.location "toc" -}}
|
|
{{- $linkClass = "hx-text-xs hx-font-medium hx-text-gray-500 hover:hx-text-gray-900 dark:hx-text-gray-400 dark:hover:hx-text-gray-100 contrast-more:hx-text-gray-800 contrast-more:dark:hx-text-gray-50" -}}
|
|
{{- end -}}
|
|
|
|
<a class="{{ $linkClass }}" href="{{ $editURL }}" target="_blank" rel="noreferer">{{ $editThisPage }}</a>
|
|
{{- end -}}
|