links with titles; comment shortcode; page-level control for some sidebar entries

This commit is contained in:
Helmut Merz 2024-11-09 14:41:48 +01:00
parent 46dec4788f
commit 1b4715b6cc
6 changed files with 15 additions and 13 deletions

View file

@ -1,5 +1,3 @@
{{- if hasPrefix .Destination "https://" -}}
<a href="{{ .Destination }}" target="_blank">{{ .Text }}</a>
{{- else -}}
<a href="{{ .Destination }}">{{ .Text }}</a>
{{- end -}}
<a {{ with .Title }}title="{{ . }}" {{ end -}}
{{ if hasPrefix .Destination "https://" }}target="_blank" {{ end -}}
href="{{ .Destination }}">{{ .Text }}</a>

View file

@ -2,11 +2,11 @@
{{- $showChildren := .Param "showChildArticles" -}}
{{- $children := slice -}}
{{- if $showChildren -}}
{{- $children = .Site.RegularPages.RelatedTo (keyVals "parents" .Params.pageid) -}}
{{- $children = .Site.Pages.RelatedTo (keyVals "parents" .Params.pageid) -}}
{{- end -}}
{{- $mainwidth := or (and .Params.noSidebar "12") "8" -}}
<div class="row">
{{- $mainwidth := or (and .Params.noSidebar "12") "8" -}}
<div class="col-md-{{ $mainwidth }}">
<article class="card mt-3 mb-3"
itemscope itemtype="http://schema.org/BlogPosting">

View file

@ -75,7 +75,7 @@
(dict "related" $related "header" (i18n "parent-articles") "id" "parents") -}}
{{- end -}}
{{- if and (not .Site.Params.hideChildArticles)
{{- if and (not (.Param "hideChildArticles"))
(ne .Site.Params.showChildArticles "cards") -}}
{{- $related := .Site.Pages.RelatedTo (keyVals "parents" .Params.pageid) -}}
{{- partial "card-related"
@ -90,7 +90,7 @@
"header" (i18n "related-articles") "id" "related") -}}
{{- end -}}
{{- if not .Site.Params.hideSiblingArticles -}}
{{- if not (.Param "hideSiblingArticles") -}}
{{- $related := .Site.Pages.RelatedIndices . "parents" -}}
{{- partial "card-related"
(dict "related" $related.ByWeight

View file

@ -0,0 +1 @@
{{- if .Inner -}}{{- end -}}

View file

@ -1,10 +1,12 @@
{{- $pid := or (.Get "pid") (.Get "page") -}}
{{- $this := $.Page -}}
{{- $title := .Get "title" -}}
{{- $summary := .Get "summary" -}}
{{- $prefix := .Get "prefix" | default "#####" -}}
{{- $pages := where .Site.RegularPages "Params.pageid" "eq" $pid -}}
{{- range $pages -}}
{{- if ne $title "none" -}}
### [{{ or $title .Title }}]({{ .Permalink }})
{{ $prefix }} [{{ or $title .Title }}]({{ .Permalink }} "{{ or $summary .Summary }}")
{{- end -}}
{{ .RenderShortcodes }}
{{- end -}}

View file

@ -3,16 +3,17 @@
{{- $this := $.Page -}}
{{- $linkid := or ($this.Scratch.Get "linkid") 1 -}}
{{- $this.Scratch.Set "linkid" (add $linkid 1) -}}
{{- $pages := where .Site.RegularPages "Params.pageid" "eq" $pid -}}
{{- $pages := where .Site.Pages "Params.pageid" "eq" $pid -}}
{{- $fragsep := cond (eq $frag "") "" "#" -}}
{{- $btext := or (.Get "btext") (printf "%d" $linkid) -}}
{{- $btitle := .Get "btitle" -}}
{{- $anchor := printf "link-%d" $linkid -}}
{{- $inner := .Inner -}}
{{- $linkTitle := (.Get "title") -}}
{{- range $pages -}}
{{- $url := printf "%s%s%s" .Permalink $fragsep $frag -}}
{{- $text := or $inner .Title -}}
<a id="{{ $anchor }}"
<a id="{{ $anchor }}"{{ with $linkTitle }} title="{{ . }}"{{ end }}
href="{{ $url }}">{{ $text | markdownify }}</a>
{{- .Scratch.Add "backlinks" (slice (dict "anchor" $anchor "page" $this "btext" $btext "btitle" $btitle)) -}}
{{- end -}}