diff options
author | Fabian Tamp <fabian.tamp@gmail.com> | 2020-08-19 00:13:14 +0300 |
---|---|---|
committer | Fabian Tamp <fabian.tamp@gmail.com> | 2020-08-19 00:13:14 +0300 |
commit | 8511f007d8dcd6c28eac7d43342fe39aa3c95b65 (patch) | |
tree | af5d114fa19ef6339d465b27e8be55dcb4456ec8 | |
parent | ed4331a17ea1586555eff36413fbea94eccd5425 (diff) |
Get pages / posts down to a single template
-rw-r--r-- | layouts/_default/baseof.html | 2 | ||||
-rw-r--r-- | layouts/_default/single.html | 50 | ||||
-rw-r--r-- | layouts/partials/footer.html | 0 | ||||
-rw-r--r-- | layouts/partials/single-article.html | 33 | ||||
-rw-r--r-- | layouts/posts/single.html | 67 |
5 files changed, 66 insertions, 86 deletions
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html index 8948de7..4b4dba2 100644 --- a/layouts/_default/baseof.html +++ b/layouts/_default/baseof.html @@ -35,6 +35,6 @@ </nav> </div> {{ block "content" . }}{{ end }} - {{ partial "footer.html" . }} + {{ block "footer" .}}{{ end }} </body> </html> diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 79a3e5e..c96e7a5 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,6 +1,7 @@ {{ define "body-classes" -}} -look-sheet-bkg + {{ if .Draft }}draft{{ end }} look-sheet-bkg {{- end }} + {{ define "breadcrumbs" }} {{- if not .Parent.IsHome -}} <span class="divider">/ </span> @@ -9,22 +10,35 @@ look-sheet-bkg {{ end }} {{ define "content" }} -<section id="main" class="content-container look-sheet article-pad-v {{ if (or .Params.disableMarginNotes .Site.Params.disableMarginNotes) }}no-floating-footnotes{{ end }}" itemprop="mainEntityOfPage"> - <h1 itemprop="name" id="title">{{ .Title }}</h1> - {{ if .Date }} - {{ if eq .Lastmod .Date }} - <div class="post-date"><span itemprop="datePublished">{{ .Date.Format "January 2, 2006" }}</span></div> - <meta itemprop="dateModified" content="{{ .Lastmod.Format "January 2, 2006" }}"/> - {{ else }} - <div class="post-date">Created: <span itemprop="datePublished">{{ .Date.Format "January 2, 2006" }}</span></div> - <div class="post-date">Last Edited: <span itemprop="dateModified">{{ .Lastmod.Format "January 2, 2006" }}</span></div> - {{ end }} - {{ end }} - {{ if .Draft }} - <div class="post-date">{{ .WordCount }} words</div> +{{- partial "single-article" . -}} +{{ end }} + +{{ define "footer" }} + +<!-- TODO: right now, this gets weird when there's a big title on the right. +There might be better info here: https://stackoverflow.com/questions/34995740/css-when-inline-block-elements-line-break-parent-wrapper-does-not-fit-new-width +and you can test on the android-development-developer-productivity article. + +Would also be cool to make this fold on mobile so there's two links on separate lines. +--> + {{if (or .PrevInSection .NextInSection) }} + <div class="nav-bkg-50 content-container-narrow-pad bottom-links text-0p75"> + <nav class="flex-row"> + {{if .PrevInSection}} + <a href="{{.PrevInSection.Permalink}}" class="flex-row v-center no-underline" style="max-width:45%;"> + <span class="text-1p5">←</span> <span class="re-underline">Previous: {{ .PrevInSection.Title }}</span> + </a> + {{else}} + <span class="flex-row v-center"></span> + {{end}} + {{if .NextInSection}} + <a href="{{.NextInSection.Permalink}}" class="flex-row v-center no-underline" style="max-width: 45%;"> + <span class="re-underline">Next: {{.NextInSection.Title}}</span> <span class="text-1p5">→</span> + </a> + {{else}} + <span class="flex-row v-center"></span> + {{end}} + </nav> + </div> {{ end }} - <article itemprop="articleBody" id="content" class="article-body margin-top-2em"> - {{ .Content }} - </article> -</section> {{ end }} diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html deleted file mode 100644 index e69de29..0000000 --- a/layouts/partials/footer.html +++ /dev/null diff --git a/layouts/partials/single-article.html b/layouts/partials/single-article.html new file mode 100644 index 0000000..61c7330 --- /dev/null +++ b/layouts/partials/single-article.html @@ -0,0 +1,33 @@ +<article + id="main" + class="content-container look-sheet article-pad-v {{ if (or .Params.disableMarginNotes .Site.Params.disableMarginNotes) }}no-floating-footnotes{{ end }}" + itemscope + itemtype="https://schema.org/Article" > + <meta itemprop="author" content="{{ .Site.Params.Author }}" /> + <meta itemprop="publisher" content="{{ .Site.Params.Author }}" /> + <meta itemprop="image" content="{{ partial "feature_image" . }}" /> + <h1 itemprop="name" id="title">{{ .Title }}</h1> + <meta itemprop="headline" content="{{ .Title }}" /> + {{ with .Params.tags }} + <div class="post-tags"> + {{ range . }} + <a href="{{ (urlize (printf "tags/%s/" .)) | absLangURL }}">#{{ . }}</a> + {{ end }} + </div> + {{ end }} + {{ if .Date }} + {{ if eq .Lastmod .Date }} + <div class="post-date"><span itemprop="datePublished">{{ .Date.Format "January 2, 2006" }}</span></div> + <meta itemprop="dateModified" content="{{ .Lastmod.Format "January 2, 2006" }}"/> + {{ else }} + <div class="post-date">Created: <span itemprop="datePublished">{{ .Date.Format "January 2, 2006" }}</span></div> + <div class="post-date">Last Edited: <span itemprop="dateModified">{{ .Lastmod.Format "January 2, 2006" }}</span></div> + {{ end }} + {{ end }} + {{ if .Draft }} + <div class="post-date">{{ .WordCount }} words</div> + {{ end }} + <div itemprop="articleBody" id="content" class="article-body margin-top-2em"> + {{ .Content }} + </div> +</article> diff --git a/layouts/posts/single.html b/layouts/posts/single.html deleted file mode 100644 index 44ff315..0000000 --- a/layouts/posts/single.html +++ /dev/null @@ -1,67 +0,0 @@ -{{ define "body-classes" -}} - {{ if .Draft }}draft{{ end }} look-sheet-bkg -{{- end }} - -{{ define "breadcrumbs" }} - <span class="divider">/ </span> - <a href="{{ .Site.BaseURL }}{{ .CurrentSection.Type }}">{{.CurrentSection.Name}}</a> -{{ end }} - -{{ define "content" }} - -<article - id="main" - class="content-container look-sheet article-pad-v {{ if (or .Params.disableMarginNotes .Site.Params.disableMarginNotes) }}no-floating-footnotes{{ end }}" - itemscope - itemtype="https://schema.org/Article" > - <meta itemprop="author" content="{{ .Site.Params.Author }}" /> - <meta itemprop="publisher" content="{{ .Site.Params.Author }}" /> - <meta itemprop="image" content="{{ partial "feature_image" . }}" /> - <h1 itemprop="name" id="title">{{ .Title }}</h1> - <meta itemprop="headline" content="{{ .Title }}" /> - {{ if .Params.tags }} - <div class="post-tags"> - {{ range .Params.tags }} - <a href="{{ (urlize (printf "tags/%s/" .)) | absLangURL }}">#{{ . }}</a> - {{ end }} - </div> - {{ end }} - {{ if eq .Lastmod .Date }} - <div class="post-date"><span itemprop="datePublished">{{ .Date.Format "January 2, 2006" }}</span></div> - <meta itemprop="dateModified" content="{{ .Lastmod.Format "January 2, 2006" }}"/> - {{ else }} - <div class="post-date">Created: <span itemprop="datePublished">{{ .Date.Format "January 2, 2006" }}</span></div> - <div class="post-date">Last Edited: <span itemprop="dateModified">{{ .Lastmod.Format "January 2, 2006" }}</span></div> - {{ end }} - {{ if .Draft }} - <div class="post-date">{{ .WordCount }} words</div> - {{ end }} - <div itemprop="articleBody" id="content" class="article-body margin-top-2em"> - {{ .Content }} - </div> -</article> -<!-- TODO: right now, this gets weird when there's a big title on the right. -There might be better info here: https://stackoverflow.com/questions/34995740/css-when-inline-block-elements-line-break-parent-wrapper-does-not-fit-new-width -and you can test on the android-development-developer-productivity article. - -Would also be cool to make this fold on mobile so there's two links on separate lines. ---> -<div class="nav-bkg-50 content-container-narrow-pad bottom-links text-0p75"> - <nav class="flex-row"> - {{if .PrevInSection}} - <a href="{{.PrevInSection.Permalink}}" class="flex-row v-center no-underline" style="max-width:45%;"> - <span class="text-1p5">←</span> <span class="re-underline">Previous: {{ .PrevInSection.Title }}</span> - </a> - {{else}} - <span class="flex-row v-center"></span> - {{end}} - {{if .NextInSection}} - <a href="{{.NextInSection.Permalink}}" class="flex-row v-center no-underline" style="max-width: 45%;"> - <span class="re-underline">Next: {{.NextInSection.Title}}</span> <span class="text-1p5">→</span> - </a> - {{else}} - <span class="flex-row v-center"></span> - {{end}} - </nav> -</div> -{{ end }} |