Add TOC (#126)
parent
3e78ce4955
commit
e5d9b6bdb7
|
|
@ -161,13 +161,29 @@ h6::before { color: var(--maincolor); content: '###### '; }
|
||||||
letter-spacing: -0.5px;
|
letter-spacing: -0.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.post-container {
|
||||||
|
align-items: flex-start;
|
||||||
|
display: flex;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.post-content {
|
||||||
|
flex: 3;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.toc {
|
.toc {
|
||||||
background-color: #ececec;
|
background-color: #ececec;
|
||||||
color: #232333;
|
|
||||||
padding: 10px;
|
|
||||||
padding-bottom: 0;
|
|
||||||
border-radius: 5px;
|
border-radius: 5px;
|
||||||
display: inline-block;
|
color: #232333;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
height: auto;
|
||||||
|
margin-left: 20px;
|
||||||
|
max-width: 300px;
|
||||||
|
overflow-y: auto;
|
||||||
|
padding: 10px;
|
||||||
|
position: sticky;
|
||||||
|
top: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Footer */
|
/* Footer */
|
||||||
|
|
|
||||||
|
|
@ -1,48 +1,54 @@
|
||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
<main>
|
<main>
|
||||||
<article>
|
<article>
|
||||||
<div class="title">
|
<div class="post-container">
|
||||||
<h1 class="title">{{ .Title }}</h1>
|
<!-- Main Content -->
|
||||||
<div class="meta">Posted on {{ dateFormat ":date_medium" .Date }}{{ if .Draft }} <span class="draft-label">DRAFT</span> {{ end }}</div>
|
<div class="post-content">
|
||||||
</div>
|
<div class="title">
|
||||||
{{ if isset .Params "tldr" }}
|
<h1 class="title">{{ .Title }}</h1>
|
||||||
<div class="tldr">
|
<div class="meta">Posted on {{ dateFormat ":date_medium" .Date }}{{ if .Draft }} <span class="draft-label">DRAFT</span> {{ end }}</div>
|
||||||
<strong>tl;dr:</strong>
|
</div>
|
||||||
{{ .Params.tldr }}
|
{{ if isset .Params "tldr" }}
|
||||||
</div>{{ end }}
|
<div class="tldr">
|
||||||
|
<strong>tl;dr:</strong>
|
||||||
|
{{ .Params.tldr }}
|
||||||
|
</div>{{ end }}
|
||||||
|
<section class="body">
|
||||||
|
{{ .Content }}
|
||||||
|
</section>
|
||||||
|
<div class="post-tags">
|
||||||
|
{{ if ne .Type "page" }}
|
||||||
|
{{ if gt .Params.tags 0 }}
|
||||||
|
<nav class="nav tags">
|
||||||
|
<ul class="tags">
|
||||||
|
{{ range .Params.tags }}
|
||||||
|
<li><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a></li>
|
||||||
|
{{ end }}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{ if isset .Params "toc" }}
|
<!-- TOC -->
|
||||||
<div class="toc">
|
{{ if isset .Params "toc" }}
|
||||||
<strong>Table of contents:</strong>
|
<div class="toc">
|
||||||
{{ .TableOfContents }}
|
<strong>Table of contents:</strong>
|
||||||
</div>{{ end }}
|
{{ .TableOfContents }}
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
|
||||||
<section class="body">
|
<!-- Disqus -->
|
||||||
{{ .Content }}
|
{{- $.Scratch.Set "isDisqus" true -}}
|
||||||
</section>
|
{{ if not .Site.Config.Services.Disqus.Shortname }}
|
||||||
|
{{- $.Scratch.Set "isDisqus" false -}}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
<div class="post-tags">
|
{{- if eq ($.Scratch.Get "isDisqus") true -}}
|
||||||
{{ if ne .Type "page" }}
|
{{- partial "disqus.html" . -}}
|
||||||
{{ if gt .Params.tags 0 }}
|
{{- end -}}
|
||||||
<nav class="nav tags">
|
</article>
|
||||||
<ul class="tags">
|
|
||||||
{{ range .Params.tags }}
|
|
||||||
<li><a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}">{{ . }}</a></li>
|
|
||||||
{{ end }}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
{{ end }}
|
|
||||||
{{ end }}
|
|
||||||
</div>
|
|
||||||
{{- $.Scratch.Set "isDisqus" true -}}
|
|
||||||
<!-- Check if disqus short name is given -->
|
|
||||||
{{ if not .Site.Config.Services.Disqus.Shortname }}
|
|
||||||
{{- $.Scratch.Set "isDisqus" false -}}
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{- if eq ($.Scratch.Get "isDisqus") true -}}
|
|
||||||
{{- partial "disqus.html" . -}}
|
|
||||||
{{- end -}}
|
|
||||||
</article>
|
|
||||||
</main>
|
</main>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue