Skip to content

Commit

Permalink
jakewies#73 Enable summary for the post in blog
Browse files Browse the repository at this point in the history
 - enabling summary params variable
  • Loading branch information
aldrineeinsteen committed Jul 13, 2020
1 parent ec69a7c commit 00aff75
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
3 changes: 3 additions & 0 deletions exampleSite/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ copyright = "© {year}"
# Currently, these icons are supported:
# "Twitter", "GitHub", "Email", "Facebook", "GitLab", "Instagram", "LinkedIn", "YouTube"
iconTitles = ["Twitter", "GitHub"]
[params.blog]
# Enables summary view on blogs
summary = true

# This disables Hugo's default syntax highlighting in favor
# of prismjs. If you wish to use Hugo's default syntax highlighting
Expand Down
49 changes: 26 additions & 23 deletions layouts/_default/list.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,37 @@
{{ define "styles" }}
{{ $.Scratch.Set "style_opts" (dict "src" "scss/pages/posts.scss" "dest" "css/posts.css") }}
{{ $.Scratch.Set "style_opts" (dict "src" "scss/pages/posts.scss" "dest" "css/posts.css") }}
{{ end }}

{{ define "main" }}

{{ $dateFormat := .Site.Params.dateFormat | default "Jan 2 2006" }}

<div class="post-list__container">
<ul class="post-list">
{{ range (.Paginator 5).Pages }}
<li class="post">
<div class="post__header">
<time class="post__date" datetime="{{ .Date }}"
>{{ .Date.Format $dateFormat }}</time>
<h2 class="post__title">
<a href="{{.RelPermalink}}">{{ .Title }}</a>
</h2>
{{ .Summary }}
{{ if .Truncated }}
<!-- This <div> includes a read more link, but only if the summary is truncated... -->
<div class="post__title" align="right">
<a href="{{ .RelPermalink }}">Read More</a>
</div>
{{ end }}
{{ partial "tags.html" .}}
</div>
</li>
{{ end }}
</ul>
{{ partial "browse-by-tag.html" .}}
<ul class="post-list">
{{ range (.Paginator 5).Pages }}
<li class="post">
<div class="post__header">
<time class="post__date" datetime="{{ .Date }}"
>{{ .Date.Format $dateFormat }}
</time>
<h2 class="post__title">
<a href="{{.RelPermalink}}">{{ .Title }}</a>
</h2>
{{if .Site.Params.blog.summary}}
{{ .Summary }}
{{ if .Truncated }}
<!-- This <div> includes a read more link, but only if the summary is truncated... -->
<div class="post__title" align="right">
<a href="{{ .RelPermalink }}">Read More</a>
</div>
{{ end }}
{{end}}
{{ partial "tags.html" .}}
</div>
</li>
{{ end }}
</ul>
{{ partial "browse-by-tag.html" .}}
</div>

{{ partial "pagination.html" . }}
Expand Down

0 comments on commit 00aff75

Please sign in to comment.