feat: support latest Hugo to fix Markdown links no longer rendering

This commit is contained in:
George Cushen 2024-11-04 15:43:58 +00:00
commit 4fe544d8c2
3 changed files with 25 additions and 17 deletions

View file

@ -90,7 +90,6 @@ outputFormats:
baseName: backlinks baseName: backlinks
isPlainText: true isPlainText: true
notAlternative: true notAlternative: true
weight: 1
params: params:
locale: locale:
date_format: 'Jan 2, 2006' date_format: 'Jan 2, 2006'

View file

@ -1,2 +1,8 @@
{{- /* Hugo 0.126 requires a `home` layout even if it serves no purpose, otherwise shows warning */ -}} {{- /* Hugo 0.126+ requires a `home` layout file even if it's empty, otherwise shows warning */ -}}
{{- jsonify dict -}} {{- if (eq (getenv "HUGO_BLOX_DEBUG") "true") -}}
{{- range site.Pages -}}{{- $_ := .WordCount -}}{{- end -}}
{{- $backlinks := (.Store.Get "backlinks" | uniq) | default dict -}}
{{- jsonify (dict "indent" " ") $backlinks -}}
{{- else -}}
{{- jsonify dict -}}
{{- end -}}

View file

@ -1,19 +1,22 @@
{{ $show_backlinks := .Params.backlinks | default true }} {{ $show_backlinks := .Params.backlinks | default true }}
{{ if $show_backlinks }} {{ if $show_backlinks }}
{{ $backlinks := site.Home.Store.Get "backlinks" | uniq }} {{ $defer_globals := (dict "page" . )}}
{{ with (where $backlinks "links_to" .RelPermalink) }} {{ with (templates.Defer (dict "data" $defer_globals )) }}
<div class="backlinks"> {{ $backlinks := (site.Home.Store.Get "backlinks" | uniq) | default dict }}
<div class="mb-1 font-semibold tracking-tight"> {{ with (where $backlinks "links_to" .page.RelPermalink) }}
{{ (T "backlinks") | default "Backlinks" }} <div class="backlinks">
<div class="mb-1 font-semibold tracking-tight">
{{ (T "backlinks") | default "Backlinks" }}
</div>
<ul>
{{ range (sort . "page.date" "desc") }}
{{ $page := .page }}
<li>
<a href="{{ $page.relPermalink }}" class="backlink">{{ $page.linkTitle }}</a>
</li>
{{ end }}
</ul>
</div> </div>
<ul> {{ end }}
{{ range (sort . "page.date" "desc") }}
{{ $page := .page }}
<li>
<a href="{{ $page.relPermalink }}" class="backlink">{{ $page.linkTitle }}</a>
</li>
{{ end }}
</ul>
</div>
{{ end }} {{ end }}
{{ end }} {{ end }}