blog/themes/chosto/layouts/_default/single.html

83 lines
3.1 KiB
HTML

{{ define "main" }}
<div class="section">
<!--
If the current page is a blog post and belongs to a case, we will add a side menu
with all other blog posts belonging to that case, emphasis to the current.
Still use empty container if nothing to show for homogeneous layout
-->
{{ if (and .IsPage (eq .FirstSection.Section "posts"))}}
{{ with .CurrentSection }}
{{ if .Params.Title }}
<div class="container">
<div class="columns mt-5 is-variable">
<aside class="menu column is-3 mt-2 is-align-self-flex-start">
<p class="menu-label">
Dans le dossier « <a href="{{ .Permalink }}">{{ .Params.Title }} »</a>...
</p>
<div class="menu-list">
{{ $posts := (where $.Site.RegularPages "CurrentSection.Params.Code" "==" $.CurrentSection.Params.Code )}}
{{ $postsSorted := (sort $posts "Date" )}}
{{ range $postsSorted }}
<a {{ if eq $.Title .Title }} class="is-active" {{ end }} href="{{ .Permalink }}">{{ .Title }}</a>
{{ end }}
</div>
</aside>
{{ else }}
<div class="container content is-max-desktop">
{{ end }}
{{ end }}
{{ else }}
<div class="container content is-max-desktop">
{{ end }}
<section class="column content">
<div>
<article class="mx-6">
<!-- First thing is a legend for the hero image, if it exists -->
{{ with .Params.imgExplanation }}
<article class="message mb-5">
<div class="message-body content is-italic">
{{ . }}
</div>
</article>
{{ end }}
<!-- Second, a summary before ToC, if it exists -->
{{ with .Params.summary }}
<div class="message is-primary">
<div class="message-body">
{{ . }}
</div>
</div>
{{ end }}
<!-- Then, ToC if text has more than 600 words and not explicitly asked not to -->
{{ if (and (not .Params.notoc) (gt .WordCount 600)) }}
<div class="message is-info">
<div class="message-header">Sommaire</div>
<!-- Appreciate this horrible trick, even a 2000's HTML generator won't generate such code -->
<div class="message-body pt-1">{{ .TableOfContents | replaceRE "<a" "<a style='text-decoration:none;'" | safeHTML }}</div>
</div>
{{ end }}
<!-- Finally, content! -->
{{ .Content }}
</article>
</div>
<aside class="container level my-5">
<div class="level-left">
{{ with .PrevInSection }}
<div class="level-item">
<a class="button is-info" href="{{ .Permalink }}">&laquo;&nbsp;{{ .Title }}</a>
</div>
{{ end }}
</div>
<div class="level-right">
{{ with .NextInSection }}
<div class="level-item">
<a class="button is-info" href="{{ .Permalink }}">{{ .Title }}&nbsp;&raquo;</a>
</div>
{{ end }}
</div>
</aside>
</section>
</div>
</div>
{{ end }}