blob: 5a87dc6137f10593c2b1de847ffb86153af4ce4c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
{{- $editMap := partial "get-edit-url" . }}
{{- if or .Site.Params.repoEditURL $editMap.repoEditURL }}
<div class="flex md:justify-end my-4">
{{- $contentDir := cond .Site.IsMultiLingual .Site.Params.contentDir "/content/" }}
{{- $filePath := ""}}
{{- if $editMap.fileDir }}
{{- $filePath = strings.TrimPrefix $editMap.fileDir .File.Path }}
{{- else }}
{{- $filePath = path.Join $contentDir .File.Path }}
{{- end }}
{{- $repoEditURL := cond (ne $editMap.repoEditURL "") $editMap.repoEditURL .Site.Params.repoEditURL }}
{{- $path := path.Join $repoEditURL $filePath }}
{{- $path = replace $path "http:/" "http://" 1 }}
{{- $path = replace $path "https:/" "https://" 1 }}
<a href="{{ $path }}" title="Edit this page">
<i class="fas fa-edit mr-1"></i>
<span>{{ i18n "editThisPage" }}</span>
</a>
</div>
{{/* Deprecation warning(v1.0.0) starts */}}
{{- else if .Site.Params.repoURL }}
{{ warnf "Param 'repoURL' in params.yaml is deprecated and will be removed in Eureka v1.0.0. See https://www.wangchucheng.com/en/docs/hugo-eureka/customization/#params-config-file" }}
<div class="flex md:justify-end my-4">
{{- $repoEditURL := path.Join .Site.Params.repoURL "/blob/master/" }}
{{ $contentDir := cond .Site.IsMultiLingual .Site.Params.contentDir "/content/" }}
{{ $path := path.Join $repoEditURL $contentDir .File.Path }}
{{ $path = replace $path "http:/" "http://" 1 }}
{{ $path = replace $path "https:/" "https://" 1 }}
<a href="{{ $path }}" title="Edit this page">
<i class="fas fa-edit mr-1"></i>
<span>{{ i18n "editThisPage" }}</span>
</a>
</div>
{{/* Deprecation warning(v1.0.0) ends */}}
{{- end }}
{{ define "partials/get-edit-url" }}
{{ $repoEditURL := "" }}
{{ $fileDir := "" }}
{{ $bundles := partial "utils/get-bundles" . }}
{{ range $bundles.Reverse }}
{{ if .Params.repoEditURL }}
{{ $repoEditURL = .Params.repoEditURL }}
{{ $fileDir = .File.Dir }}
{{ end }}
{{ end }}
{{ return (dict "repoEditURL" $repoEditURL "fileDir" $fileDir) }}
{{ end }}
|