diff --git a/exampleSite/content/_index.md b/exampleSite/content/_index.md index 437c4af8..ee57837a 100644 --- a/exampleSite/content/_index.md +++ b/exampleSite/content/_index.md @@ -56,7 +56,7 @@ disable_sections = true {{< paige/image alt="Landscape" breakpoints=true class="mt-3 object-fit-cover rounded-4 shadow" fetchpriority="high" height="20rem" loading="eager" process="webp" src="https://images.unsplash.com/photo-1490604001847-b712b0c2f967?w=1296" width="100%" >}} -

An advanced Hugo theme

+

An advanced Hugo theme

diff --git a/layouts/_default/list.atom.xml b/layouts/_default/list.atom.xml index 86fa5569..2e4ea50a 100644 --- a/layouts/_default/list.atom.xml +++ b/layouts/_default/list.atom.xml @@ -107,7 +107,7 @@ {{ range $subpage := $subpages }} {{ if not (.Param "paige.exclude_feeds") }} - {{ $content := partial "paige/func-minify.html" (dict "content" .Content) }} + {{ $content := partial "paige/func-content.html" $subpage }} {{ $external := and .Params.link (not (.Param "paige.feeds.disable_link")) | not | not }} {{ $id := printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.PublishDate.Format "2006-01-02") .RelPermalink }} {{ $lastmod := .Lastmod.Format $date }} @@ -117,6 +117,8 @@ {{ $link := cond $external .Params.link .Permalink }} + {{ $content = partial "paige/func-minify.html" (dict "content" $content) }} + {{ if and $content $external }} {{ $text := or (.Param "paige.feeds.page_link" | markdownify) "⏎" }} diff --git a/layouts/_default/list.rss.xml b/layouts/_default/list.rss.xml index 88178d0c..ee81a6d6 100644 --- a/layouts/_default/list.rss.xml +++ b/layouts/_default/list.rss.xml @@ -97,7 +97,7 @@ {{ $author := "" }} {{ $authors := partial "paige/func-authors.html" . }} - {{ $description := partial "paige/func-minify.html" (dict "content" .Content) }} + {{ $description := partial "paige/func-content.html" $subpage }} {{ $external := and .Params.link (not (.Param "paige.feeds.disable_link")) | not | not }} {{ $guid := printf "tag:%s,%s:%s" (urls.Parse site.BaseURL).Host (.PublishDate.Format "2006-01-02") (cond (.Params.id | not) .RelPermalink .Params.id) }} {{ $published := .PublishDate.Format $date }} @@ -105,6 +105,8 @@ {{ $link := cond $external .Params.link .Permalink }} + {{ $description = partial "paige/func-minify.html" (dict "content" $description) }} + {{ with $authors }} {{ $primary := index . 0 }} diff --git a/layouts/partials/paige/func-content.html b/layouts/partials/paige/func-content.html new file mode 100644 index 00000000..f70c0769 --- /dev/null +++ b/layouts/partials/paige/func-content.html @@ -0,0 +1,31 @@ +{{ $page := . }} + +{{ $result := $page.Content }} + +{{ $matches := findRESubmatch "]" $result }} + +{{ with $matches }} + {{ $max := 0 }} + + {{ range . }} + {{ $level := index . 1 | int }} + + {{ if gt $level $max }} + {{ $max = $level }} + {{ end }} + {{ end }} + + {{ if and $max (lt $max 6) }} + {{ $shift := sub 6 $max }} + + {{ range seq $max | collections.Reverse }} + {{ $old := . }} + {{ $new := add $old $shift }} + + {{ $result = replaceRE (printf "])" $old) (printf "" $old) (printf "" $new) $result }} + {{ end }} + {{ end }} +{{ end }} + +{{ return $result }} diff --git a/layouts/partials/paige/page.html b/layouts/partials/paige/page.html index 92efd54e..53ff6e32 100644 --- a/layouts/partials/paige/page.html +++ b/layouts/partials/paige/page.html @@ -1,7 +1,7 @@ {{ $page := . }} {{ $class := slice }} -{{ $content := $page.Content }} +{{ $content := partial "paige/func-content.html" $page }} {{ $draft := $page.Draft }} {{ $expired := and $page.ExpiryDate (lt $page.ExpiryDate now) }} {{ $future := and $page.PublishDate (gt $page.PublishDate now) }}