Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blog: Use standard summaryLength or explicit summary length (if set) #44

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ defaultContentLanguageInSubdir = false
googleanalytics = "UA-Not-Yet"
metaDataFormat = "toml"
pagination.pagerSize = 5
summaryLength = 25
theme = ["blog", "solus"]
enableInlineShortcodes = true

Expand Down
23 changes: 13 additions & 10 deletions themes/blog/layouts/blog/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +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) }}
{{ if ge (len $firstBlog.Summary) 397 }}
<p itemprop="description">{{- htmlUnescape (plainify (safeHTML (substr $firstBlog.Summary 0 187))) -}}...</p>
{{ else }}
<p itemprop="description">{{- htmlUnescape (plainify (safeHTML $firstBlog.Summary)) -}}</p>
{{ end }}
<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