From 1b4715b6ccd1ce31f237463006d9d7270d0e36f6 Mon Sep 17 00:00:00 2001 From: Helmut Merz Date: Sat, 9 Nov 2024 14:41:48 +0100 Subject: [PATCH] links with titles; comment shortcode; page-level control for some sidebar entries --- layouts/_default/_markup/render-link.html | 8 +++----- layouts/_default/single.html | 4 ++-- layouts/partials/sidebar.html | 6 +++--- layouts/shortcodes/comment.html | 1 + layouts/shortcodes/embed.md | 4 +++- layouts/shortcodes/ilink.html | 5 +++-- 6 files changed, 15 insertions(+), 13 deletions(-) create mode 100644 layouts/shortcodes/comment.html diff --git a/layouts/_default/_markup/render-link.html b/layouts/_default/_markup/render-link.html index ffcfddf..8dda640 100644 --- a/layouts/_default/_markup/render-link.html +++ b/layouts/_default/_markup/render-link.html @@ -1,5 +1,3 @@ -{{- if hasPrefix .Destination "https://" -}} - {{ .Text }} -{{- else -}} - {{ .Text }} -{{- end -}} + {{ .Text }} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 775d026..6a4efba 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -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" -}}
- {{- $mainwidth := or (and .Params.noSidebar "12") "8" -}}
diff --git a/layouts/partials/sidebar.html b/layouts/partials/sidebar.html index d32d766..eb0bd75 100644 --- a/layouts/partials/sidebar.html +++ b/layouts/partials/sidebar.html @@ -75,8 +75,8 @@ (dict "related" $related "header" (i18n "parent-articles") "id" "parents") -}} {{- end -}} - {{- if and (not .Site.Params.hideChildArticles) - (ne .Site.Params.showChildArticles "cards") -}} + {{- if and (not (.Param "hideChildArticles")) + (ne .Site.Params.showChildArticles "cards") -}} {{- $related := .Site.Pages.RelatedTo (keyVals "parents" .Params.pageid) -}} {{- partial "card-related" (dict "related" $related.ByWeight @@ -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 diff --git a/layouts/shortcodes/comment.html b/layouts/shortcodes/comment.html new file mode 100644 index 0000000..a211cd6 --- /dev/null +++ b/layouts/shortcodes/comment.html @@ -0,0 +1 @@ +{{- if .Inner -}}{{- end -}} diff --git a/layouts/shortcodes/embed.md b/layouts/shortcodes/embed.md index f9e63f1..28656ef 100644 --- a/layouts/shortcodes/embed.md +++ b/layouts/shortcodes/embed.md @@ -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 -}} diff --git a/layouts/shortcodes/ilink.html b/layouts/shortcodes/ilink.html index aa35bc5..bf31ad1 100644 --- a/layouts/shortcodes/ilink.html +++ b/layouts/shortcodes/ilink.html @@ -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 -}} - {{ $text | markdownify }} {{- .Scratch.Add "backlinks" (slice (dict "anchor" $anchor "page" $this "btext" $btext "btitle" $btitle)) -}} {{- end -}}