File tree 3 files changed +21
-2
lines changed
3 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -133,6 +133,7 @@ params:
133
133
134
134
editURL :
135
135
enable : true
136
+ where : " single" # single | toc
136
137
base : " https://github.com/imfing/hextra/edit/main/exampleSite/content"
137
138
138
139
blog :
Original file line number Diff line number Diff line change 1
1
{{- $lastUpdated := (T "lastUpdated") | default "Last updated on" -}}
2
+ {{- $editThisPage := (T "editThisPage") | default "Edit this page"}}
2
3
3
4
{{- if site.Params.displayUpdatedDate -}}
5
+ < div class ="mt-12 mb-8 block text-xs text-gray-500 ltr:text-right rtl:text-left dark:text-gray-400 ">
6
+ {{- if and (site.Params.editURL.enable) (eq site.Params.editURL.where "single") -}}
7
+ {{- $editURL := site.Params.editURL.base | default "" -}}
8
+ {{- with .Params.editURL -}}
9
+ {{/* if `editURL` is set in the front matter */}}
10
+ {{- $editURL = . -}}
11
+ {{- else -}}
12
+ {{- with .File -}}
13
+ {{/* `.FileInfo.Meta.SourceRoot` is a Hugo internal field, e.g. `/path/to/repo/content/en/` */}}
14
+ {{- $sourceDir := replace (strings.TrimPrefix .FileInfo.Meta.BaseDir .FileInfo.Meta.SourceRoot) "\\" "/" -}}
15
+ {{- $sourceDir = strings.TrimPrefix "/content" $sourceDir -}}
16
+ {{- $path := replace .Path "\\" "/" -}}
17
+ {{- $editURL = urls.JoinPath $editURL $sourceDir $path -}}
18
+ {{- end -}}
19
+ {{- end -}}
20
+ < a class ="mb-4 block text-xs text-gray-500 ltr:text-right rtl:text-left dark:text-gray-400 " href ="{{ $editURL }} " target ="_blank " rel ="noreferer "> {{ $editThisPage }}</ a >
21
+ {{- end -}}
4
22
{{- with .Lastmod -}}
5
23
{{ $datetime := (time.Format "2006-01-02T15:04:05.000Z" .) }}
6
- < div class =" mt-12 mb-8 block text-xs text-gray-500 ltr:text-right rtl:text-left dark:text-gray-400 " > {{ $lastUpdated }} < time datetime ="{{ $datetime }} "> {{ partial "utils/format-date" . }}</ time > </ div >
24
+ {{ $lastUpdated }} < time datetime ="{{ $datetime }} "> {{ partial "utils/format-date" . }}</ time > </ div >
7
25
{{- else -}}
8
26
< div class ="mt-16 "> </ div >
9
27
{{- end -}}
Original file line number Diff line number Diff line change 24
24
25
25
{{/* TOC bottom part */}}
26
26
< div class ="{{ $borderClass }} sticky bottom-0 flex flex-col items-start gap-2 pb-8 dark:border-neutral-800 contrast-more:border-t contrast-more:border-neutral-400 contrast-more:shadow-none contrast-more:dark:border-neutral-400 ">
27
- {{- if site.Params.editURL.enable -}}
27
+ {{- if and ( site.Params.editURL.enable) (eq site.Params.editURL.where "toc") -}}
28
28
{{- $editURL := site.Params.editURL.base | default "" -}}
29
29
{{- with .Params.editURL -}}
30
30
{{/* if `editURL` is set in the front matter */}}
You can’t perform that action at this time.
0 commit comments