mirror of
https://github.com/jbowdre/runtimeterror.git
synced 2024-11-24 16:02:18 +00:00
add featured posts, tweak ToC a bit
This commit is contained in:
parent
0ad452dc28
commit
27cdf6ee03
4 changed files with 64 additions and 20 deletions
|
@ -3,6 +3,7 @@ usePageBundles = true
|
|||
description = "while (true) { bugs++; }"
|
||||
mainSections = ["posts"]
|
||||
fallBackOgImage = "images/broken-computer.svg"
|
||||
numberOfFeaturedPosts = 5
|
||||
|
||||
# Comments
|
||||
comments = true
|
||||
|
|
36
layouts/_default/baseof.html
Normal file
36
layouts/_default/baseof.html
Normal file
|
@ -0,0 +1,36 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="{{- site.Language.Lang -}}">
|
||||
|
||||
<head>
|
||||
{{- partial "head.html" . -}}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="page">
|
||||
|
||||
<header class="page__header">
|
||||
{{- partial "header.html" . -}}
|
||||
</header>
|
||||
|
||||
<section class="page__body">
|
||||
{{- block "main" . }}{{- end }}
|
||||
</section>
|
||||
|
||||
<section class="page__aside">
|
||||
<div class="aside__about">
|
||||
{{- partial "about.html" . -}}
|
||||
</div>
|
||||
<hr>
|
||||
<div class="aside__content">
|
||||
{{- partial "aside" . }}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer class="page__footer">
|
||||
{{- partial "footer.html" . -}}
|
||||
</footer>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -3,10 +3,6 @@
|
|||
<header class="content__header">
|
||||
<h1>{{ .Title | markdownify }}</h1>
|
||||
</header>
|
||||
{{ if .Params.toc }}
|
||||
<aside>
|
||||
</aside>
|
||||
{{ end }}
|
||||
{{- with .Param "lastmod" -}}
|
||||
{{- $ageDays = div (sub now.Unix .Unix) 86400 -}}
|
||||
{{- end -}}
|
||||
|
@ -31,19 +27,3 @@
|
|||
{{- end }}
|
||||
<footer class="content__footer"></footer>
|
||||
{{ end }}
|
||||
|
||||
{{define "aside" }}
|
||||
{{ if .Params.description }}<p>{{ .Params.description }}</p>{{ end }}
|
||||
{{ if or (.Params.author) (.Params.date) }}
|
||||
<p>
|
||||
{{ if .Params.author }}By {{ .Params.author }}{{ if .Date }}, {{ end }}{{ end }}
|
||||
{{ if .Date }}{{ .Date.Format "2006-01-02" }}{{ end }}
|
||||
</p>
|
||||
{{ end }}
|
||||
|
||||
{{ if and (.Params.toc) (gt .WordCount 400 ) (gt (len .TableOfContents) 180) (.TableOfContents) }}
|
||||
<hr>
|
||||
On this page:
|
||||
{{ .TableOfContents }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
|
27
layouts/partials/aside.html
Normal file
27
layouts/partials/aside.html
Normal file
|
@ -0,0 +1,27 @@
|
|||
{{ if .Params.description }}<p>{{ .Params.description }}</p>{{ end }}
|
||||
{{ if or (.Params.author) (.Params.date) }}
|
||||
<p>
|
||||
{{ if .Params.author }}By {{ .Params.author }}{{ if .Date }}, {{ end }}{{ end }}
|
||||
{{ if .Date }}{{ .Date.Format "2006-01-02" }}{{ end }}
|
||||
</p>
|
||||
{{ end }}
|
||||
|
||||
{{ if and (gt .WordCount 400 ) (gt (len .TableOfContents) 180) }}
|
||||
<hr>
|
||||
<h2>On this page</h2>
|
||||
{{ .TableOfContents }}
|
||||
{{ end }}
|
||||
|
||||
{{- $posts := where .Site.RegularPages "Type" "in" .Site.Params.mainSections }}
|
||||
{{- $featured := default 8 .Site.Params.numberOfFeaturedPosts }}
|
||||
{{- $featuredPosts := first $featured (where $posts "Params.featured" true)}}
|
||||
{{- with $featuredPosts }}
|
||||
<h2>Featured Posts</h2>
|
||||
<ul>
|
||||
{{- range . }}
|
||||
<li>
|
||||
<a href="{{ .Permalink }}" title="{{ .Title }}">{{ .Title | markdownify }}</a>
|
||||
</li>
|
||||
{{- end }}
|
||||
</ul>
|
||||
{{- end }}
|
Loading…
Reference in a new issue