Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wangchucheng/hugo-eureka.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'layouts/partials/components')
-rw-r--r--layouts/partials/components/doc-layout.html2
-rw-r--r--layouts/partials/components/post-edit.html59
-rw-r--r--layouts/partials/components/schema.html2
3 files changed, 44 insertions, 19 deletions
diff --git a/layouts/partials/components/doc-layout.html b/layouts/partials/components/doc-layout.html
index 7217030..34b8227 100644
--- a/layouts/partials/components/doc-layout.html
+++ b/layouts/partials/components/doc-layout.html
@@ -31,9 +31,7 @@
{{ partial "components/post-author" . }}
{{ end }}
- {{ if or .Site.Params.repoURL .Site.Params.repoEditURL }}
{{ partial "components/post-edit" . }}
- {{ end }}
{{ partial "components/post-footer" . }}
{{ partial "comment" . }}
diff --git a/layouts/partials/components/post-edit.html b/layouts/partials/components/post-edit.html
index 14c07af..09cbec8 100644
--- a/layouts/partials/components/post-edit.html
+++ b/layouts/partials/components/post-edit.html
@@ -1,24 +1,51 @@
-<div class="flex md:justify-end my-4">
- {{ $repoEditURL := partial "get-edit-url" . }}
+{{- $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/" }}
+ <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 }}
-
+ {{ $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>
+ <i class="fas fa-edit mr-1"></i>
+ <span>{{ i18n "editThisPage" }}</span>
</a>
-</div>
+ </div>
+{{/* Deprecation warning(v1.0.0) ends */}}
+{{- end }}
{{ define "partials/get-edit-url" }}
-{{ with .Site.Params.repoEditURL }}
-{{ $.Scratch.Set "repoEditURL" . }}
-{{ else }}
-{{ $repoEditURL := path.Join .Site.Params.repoURL "/blob/master/"}}
-{{ $.Scratch.Set "repoEditURL" $repoEditURL }}
+{{ $repoEditURL := "" }}
+{{ $fileDir := "" }}
+{{ $bundles := partial "utils/get-bundles" . }}
+{{ range $bundles.Reverse }}
+ {{ if .Params.repoEditURL }}
+ {{ $repoEditURL = .Params.repoEditURL }}
+ {{ $fileDir = .File.Dir }}
+ {{ end }}
{{ end }}
-{{ $repoEditURL := .Scratch.Get "repoEditURL" }}
-{{ .Scratch.Delete "repoEditURL" }}
-{{ return $repoEditURL }}
+{{ return (dict "repoEditURL" $repoEditURL "fileDir" $fileDir) }}
{{ end }} \ No newline at end of file
diff --git a/layouts/partials/components/schema.html b/layouts/partials/components/schema.html
index 001138b..bc3147f 100644
--- a/layouts/partials/components/schema.html
+++ b/layouts/partials/components/schema.html
@@ -1,7 +1,7 @@
<meta name="description"
content="{{ if .Description }}{{ .Description }}{{ else if .Summary }}{{ .Summary }}{{ else if .Site.Params.Description }}{{ .Site.Params.Description }}{{ end }}">
-{{- $bundles := partial "get-bundles" . }}
+{{- $bundles := partial "utils/get-bundles" . }}
{{- if gt (len $bundles) 1 }}
<script type="application/ld+json">
{