Skip to content

Commit

Permalink
blog card with better summary
Browse files Browse the repository at this point in the history
  • Loading branch information
tmastny committed Jun 23, 2020
1 parent 8b11d51 commit 3692458
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions layouts/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ <h2>Projects</h2>

<h2>Recent Posts</h2>

<ul>
{{ $pages := (where .Site.RegularPages "Section" "=" "blog") }}
{{ $first_four := (first 4 $pages) }}

{{ $partial_dict := (dict "pages" $first_four "partial" "blog-card.html") }}
{{ partial "two-column.html" $partial_dict }}

</ul>


<h2>Posts</h2>

<ul>
{{ $pages := .Site.RegularPages }}
{{ $paginator := .Paginate (where $pages "Section" "=" "blog") }}
Expand Down
13 changes: 13 additions & 0 deletions layouts/partials/blog-card.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{{/* parameter: .Page */}}

<p><article class="card">
<h3><a href="{{ .RelPermalink }}">{{ .Title | markdownify }}</a></h3>

{{ with .Description }}
{{ $.Scratch.Set "summary" (markdownify .) }}
{{ else }}
{{ $.Scratch.Set "summary" ((delimit (findRE "(<p.*?>(.|\n)*?</p>\\s*)+" .Content) "[&hellip;] ") | plainify | truncate (default 200 .Site.Params.summary_length) (default " &hellip;" .Site.Params.text.truncated ) | replaceRE "&amp;" "&" | safeHTML) }}
{{ end }}
{{ $.Scratch.Get "summary" }}

</article></p>

0 comments on commit 3692458

Please sign in to comment.