mirror of
https://github.com/imfing/hextra.git
synced 2025-05-15 14:18:27 -04:00
Merge 712e670f9d14a409e4b50b7303403f92bb576bfb into e83c11f31a00c1088cd49e8eaea10b60384921c4
This commit is contained in:
commit
931ae6e6ed
@ -142,6 +142,7 @@ params:
|
|||||||
|
|
||||||
editURL:
|
editURL:
|
||||||
enable: true
|
enable: true
|
||||||
|
location: "toc" # single | toc
|
||||||
base: "https://github.com/imfing/hextra/edit/main/exampleSite/content"
|
base: "https://github.com/imfing/hextra/edit/main/exampleSite/content"
|
||||||
|
|
||||||
blog:
|
blog:
|
||||||
|
28
layouts/partials/components/edit-url.html
Normal file
28
layouts/partials/components/edit-url.html
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{{- $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 -}}
|
||||||
|
|
||||||
|
<a class="{{ $linkClass }}" href="{{ $editURL }}" target="_blank" rel="noreferer">{{ $editThisPage }}</a>
|
||||||
|
{{- end -}}
|
@ -1,9 +1,12 @@
|
|||||||
{{- $lastUpdated := (T "lastUpdated") | default "Last updated on" -}}
|
{{- $lastUpdated := (T "lastUpdated") | default "Last updated on" -}}
|
||||||
|
|
||||||
{{- if site.Params.displayUpdatedDate -}}
|
{{- if site.Params.displayUpdatedDate -}}
|
||||||
|
<div class="hx-mt-12 hx-mb-8 hx-block hx-text-xs hx-text-gray-500 ltr:hx-text-right rtl:hx-text-left dark:hx-text-gray-400">
|
||||||
|
{{ partial "components/edit-url.html" (dict "source" "single" "context" .) }}
|
||||||
{{- with .Lastmod -}}
|
{{- with .Lastmod -}}
|
||||||
{{ $datetime := (time.Format "2006-01-02T15:04:05.000Z" .) }}
|
{{ $datetime := (time.Format "2006-01-02T15:04:05.000Z" .) }}
|
||||||
<div class="hx-mt-12 hx-mb-8 hx-block hx-text-xs hx-text-gray-500 ltr:hx-text-right rtl:hx-text-left dark:hx-text-gray-400">{{ $lastUpdated }} <time datetime="{{ $datetime }}">{{ partial "utils/format-date" . }}</time></div>
|
<div class="hx-mt-4">{{ $lastUpdated }} <time datetime="{{ $datetime }}">{{ partial "utils/format-date" . }}</time></div>
|
||||||
|
</div>
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
<div class="hx-mt-16"></div>
|
<div class="hx-mt-16"></div>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
@ -24,22 +24,7 @@
|
|||||||
|
|
||||||
{{/* TOC bottom part */}}
|
{{/* TOC bottom part */}}
|
||||||
<div class="{{ $borderClass }} hx-sticky hx-bottom-0 hx-flex hx-flex-col hx-items-start hx-gap-2 hx-pb-8 dark:hx-border-neutral-800 contrast-more:hx-border-t contrast-more:hx-border-neutral-400 contrast-more:hx-shadow-none contrast-more:dark:hx-border-neutral-400">
|
<div class="{{ $borderClass }} hx-sticky hx-bottom-0 hx-flex hx-flex-col hx-items-start hx-gap-2 hx-pb-8 dark:hx-border-neutral-800 contrast-more:hx-border-t contrast-more:hx-border-neutral-400 contrast-more:hx-shadow-none contrast-more:dark:hx-border-neutral-400">
|
||||||
{{- if site.Params.editURL.enable -}}
|
{{ partial "components/edit-url.html" (dict "source" "toc" "context" .) }}
|
||||||
{{- $editURL := site.Params.editURL.base | default "" -}}
|
|
||||||
{{- with .Params.editURL -}}
|
|
||||||
{{/* if `editURL` is set in the front matter */}}
|
|
||||||
{{- $editURL = . -}}
|
|
||||||
{{- else -}}
|
|
||||||
{{- with .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 -}}
|
|
||||||
<a class="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" href="{{ $editURL }}" target="_blank" rel="noreferer">{{ $editThisPage }}</a>
|
|
||||||
{{- end -}}
|
|
||||||
{{/* Scroll To Top */}}
|
{{/* Scroll To Top */}}
|
||||||
<button aria-hidden="true" id="backToTop" onClick="scrollUp();" class="hx-transition-all hx-duration-75 hx-opacity-0 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">
|
<button aria-hidden="true" id="backToTop" onClick="scrollUp();" class="hx-transition-all hx-duration-75 hx-opacity-0 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">
|
||||||
<span>
|
<span>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user