{{- $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 -}} {{ $editThisPage }} {{- end -}}