Skip to content

Commit 00f6db1

Browse files
committed
Fixes after review
- `where` > `location` - Edit link > in a partial
1 parent 3166be3 commit 00f6db1

File tree

4 files changed

+22
-35
lines changed

4 files changed

+22
-35
lines changed

exampleSite/hugo.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ params:
133133

134134
editURL:
135135
enable: true
136-
where: "toc" # single | toc
136+
location: "toc" # single | toc
137137
base: "https://github.com/imfing/hextra/edit/main/exampleSite/content"
138138

139139
blog:
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{{- $editThisPage := (T "editThisPage") | default "Edit this page"}}
2+
3+
<div class="mt-12 mb-8 block text-xs text-gray-500 ltr:text-right rtl:text-left dark:text-gray-400">
4+
{{- if and (site.Params.editURL.enable) (eq site.Params.editURL.location .source) -}}
5+
{{- $editURL := site.Params.editURL.base | default "" -}}
6+
{{- with .Params.editURL -}}
7+
{{/* if `editURL` is set in the front matter */}}
8+
{{- $editURL = . -}}
9+
{{- else -}}
10+
{{- with .File -}}
11+
{{/* `.FileInfo.Meta.SourceRoot` is a Hugo internal field, e.g. `/path/to/repo/content/en/` */}}
12+
{{- $sourceDir := replace (strings.TrimPrefix .FileInfo.Meta.BaseDir .FileInfo.Meta.SourceRoot) "\\" "/" -}}
13+
{{- $sourceDir = strings.TrimPrefix "/content" $sourceDir -}}
14+
{{- $path := replace .Path "\\" "/" -}}
15+
{{- $editURL = urls.JoinPath $editURL $sourceDir $path -}}
16+
{{- end -}}
17+
{{- end -}}
18+
<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>
19+
{{- end -}}

layouts/partials/components/last-updated.html

+1-17
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,7 @@
22
{{- $editThisPage := (T "editThisPage") | default "Edit this page"}}
33

44
{{- 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 -}}
5+
{{ partial "components/edit-url.html" (dict "source" "single") }}
226
{{- with .Lastmod -}}
237
{{ $datetime := (time.Format "2006-01-02T15:04:05.000Z" .) }}
248
{{ $lastUpdated }} <time datetime="{{ $datetime }}">{{ partial "utils/format-date" . }}</time></div>

layouts/partials/toc.html

+1-17
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,7 @@
2323
{{- end -}}
2424

2525
{{/* TOC bottom part */}}
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 and (site.Params.editURL.enable) (eq site.Params.editURL.where "toc") -}}
28-
{{- $editURL := site.Params.editURL.base | default "" -}}
29-
{{- with .Params.editURL -}}
30-
{{/* if `editURL` is set in the front matter */}}
31-
{{- $editURL = . -}}
32-
{{- else -}}
33-
{{- with .File -}}
34-
{{/* `.FileInfo.Meta.SourceRoot` is a Hugo internal field, e.g. `/path/to/repo/content/en/` */}}
35-
{{- $sourceDir := replace (strings.TrimPrefix .FileInfo.Meta.BaseDir .FileInfo.Meta.SourceRoot) "\\" "/" -}}
36-
{{- $sourceDir = strings.TrimPrefix "/content" $sourceDir -}}
37-
{{- $path := replace .Path "\\" "/" -}}
38-
{{- $editURL = urls.JoinPath $editURL $sourceDir $path -}}
39-
{{- end -}}
40-
{{- end -}}
41-
<a class="text-xs font-medium text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100 contrast-more:text-gray-800 contrast-more:dark:text-gray-50" href="{{ $editURL }}" target="_blank" rel="noreferer">{{ $editThisPage }}</a>
42-
{{- end -}}
26+
{{ partial "components/edit-url.html" (dict "source" "toc") }}
4327
{{/* Scroll To Top */}}
4428
<button aria-hidden="true" id="backToTop" onClick="scrollUp();" class="transition-all transition duration-75 opacity-0 text-xs font-medium text-gray-500 hover:text-gray-900 dark:text-gray-400 dark:hover:text-gray-100 contrast-more:text-gray-800 contrast-more:dark:text-gray-50">
4529
<span>

0 commit comments

Comments
 (0)