Skip to content

Commit

Permalink
blog: Split summaries into paragraphs so they're properly (un)formatted
Browse files Browse the repository at this point in the history
Except for paragraph splits

Signed-off-by: Thomas Staudinger <Staudi.Kaos@gmail.com>
  • Loading branch information
Staudey committed Dec 10, 2024
1 parent 6b8c6c2 commit 1ffbec8
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions themes/blog/layouts/blog/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@
<meta itemscope itemprop="mainEntityOfPage" itemType="https://schema.org/WebPage" itemid="{{ $firstBlog.Permalink | absURL }}"/>
<section>
{{ partial "blog/info.html" (dict "blog" $firstBlog "site" .Site) }}
<div itemprop="description">{{- safeHTML $firstBlog.Summary -}}</div>
<div class="menu">
<nav>
<a class="button inverse" href="{{ $firstBlog.Permalink }}">Read More</a>
</nav>
</div>
<!-- Split summary into paragraphs so they are properly formatted -->
{{ $summaryParagraphs := split $firstBlog.Summary "<p>" }}
{{range $summaryParagraphs }}
{{ if eq . "" }}
{{ continue }}
{{ end }}
<p itemprop="description">{{ htmlUnescape (plainify (safeHTML .)) }}</p>
{{end}}
<div class="menu">
<nav>
<a class="button inverse" href="{{ $firstBlog.Permalink }}">Read More</a>
</nav>
</div>
</section>
{{ $url := (printf "%s/%s" $firstBlog.Params.url $firstBlog.Params.featuredimage) | absURL }}
<img alt="{{ $firstBlog.Title }}" src="{{ $url }}"></img>
Expand Down

0 comments on commit 1ffbec8

Please sign in to comment.