commit 0635c6a3510fdaa08a0a4cbba5b4317ad3708eed
parent 87ef1ca8e272f7831f6899769032e9b3577a870d
Author: oscarbenedito <oscar@oscarbenedito.com>
Date: Fri, 20 Mar 2020 14:27:28 +0100
Go templates are now more aware of output endlines and spaces
Diffstat:
12 files changed, 67 insertions(+), 65 deletions(-)
diff --git a/content/composer.html b/content/composer.md
diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
@@ -1,20 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
- {{ partial "head-base.html" . }}
+ {{ partial "head-base.html" . -}}
<link rel="alternate" type="application/atom+xml" title="{{ .Site.Params.blog_title }}" href=/blog/index.xml>
- {{ $options := (dict "targetPath" "css/style.css" "outputStyle" "compressed") }}
- {{ $style := resources.Get "css/style.scss" | resources.ToCSS $options }}
+ {{- $options := (dict "targetPath" "css/style.css" "outputStyle" "compressed") }}
+ {{- $style := resources.Get "css/style.scss" | resources.ToCSS $options }}
<link id="theme" rel="stylesheet" type="text/css" href="{{ $style.RelPermalink }}">
</head>
<body>
{{ partial "navbar.html" . }}
- {{ block "main" . }}
+ {{- block "main" . }}
<main>
{{ .Content }}
</main>
- {{ end }}
- {{ partial "footer.html" . }}
- {{ partial "scripts.html" . }}
+ {{- end }}
+ {{ partial "footer.html" . -}}
+ {{ partial "scripts.html" . -}}
</body>
</html>
diff --git a/layouts/_default/list.html b/layouts/_default/list.html
@@ -1,50 +1,50 @@
{{ define "main" }}
<header class="page-header">
- {{ if eq .Kind "taxonomy" }}
+ {{- if eq .Kind "taxonomy" }}
<h1>{{ .Title | title }}</h1>
- {{ else }}
+ {{- else }}
<h1>{{ .Title }}</h1>
- {{ end }}
- {{ if eq .Kind "taxonomy" }}
+ {{- end }}
+ {{- if eq .Kind "taxonomy" }}
<h2>{{ .Data.Singular | title }}</h2>
- {{ else }}
- {{ with .Params.subtitle }}
+ {{- else }}
+ {{- with .Params.subtitle }}
<h2>{{ . }}</h2>
- {{ end }}
- {{ end }}
+ {{- end }}
+ {{- end }}
</header>
<main class="list">
- {{ $paginator := .Paginator }}
- {{ range $paginator.Pages }}
+ {{- $paginator := .Paginator }}
+ {{- range $paginator.Pages }}
<div class="card h-entry">
<header>
<h2 class="p-name">{{ .Title }}</h2>
</header>
<section class="content">
- {{ if .Params.subtitle }}
+ {{- if .Params.subtitle }}
<p class="p-summary">{{ .Params.subtitle }}</p>
- {{ else }}
+ {{- else }}
<p class="p-summary">{{ .Plain | htmlUnescape | truncate 200 }}</p>
- {{ end }}
+ {{- end }}
</section>
<footer>
{{ with .Params.categories }}<a class="p-category" style="color: var(--secondary-text-color)" href="{{ "blog/categories/" | relURL }}{{ . | urlize }}">{{ . | title }}</a> · {{ end }}<data class="dt-published" datetime="{{ .Date.Format "2006-01-02" }}">{{ .Date.Format "January 2, 2006" }}</data> · {{ partial "read-time.html" . }}
</footer>
<a class="card-link u-url" href="{{ .RelPermalink }}"></a>
</div>
- {{ end }}
+ {{- end }}
- {{ $paginator := .Paginator }}
- {{ if or $paginator.HasPrev $paginator.HasNext }}
+ {{- $paginator := .Paginator }}
+ {{- if or $paginator.HasPrev $paginator.HasNext }}
<div class="pagination">
- {{ if $paginator.HasPrev }}
+ {{- if $paginator.HasPrev }}
<a class="button" href="{{ $paginator.Prev.URL }}">← Newer Posts</a>
- {{ end }}
- {{ if $paginator.HasNext }}
+ {{- end }}
+ {{- if $paginator.HasNext }}
<a class="button right" href="{{ $paginator.Next.URL }}">Older Posts →</a>
- {{ end }}
+ {{- end }}
</div>
- {{ end }}
+ {{- end }}
</main>
{{ end }}
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
@@ -11,24 +11,26 @@
</div>
</header>
<div class="post-content e-content">{{ .Content }}</div>
- {{ if .Params.tags }}
+ {{- if .Params.tags }}
<footer>
<ul class="post-tags">
- {{ range .Params.tags | sort }}<li><a class="p-category" href="{{ "blog/tags/" | relURL }}{{ . | urlize }}">{{ . }}</a></li>{{ end }}
+ {{- range .Params.tags | sort }}
+ <li><a class="p-category" href="{{ "blog/tags/" | relURL }}{{ . | urlize }}">{{ . }}</a></li>
+ {{- end }}
</ul>
</footer>
- {{ end }}
+ {{- end }}
</article>
- {{ if or .NextInSection .PrevInSection }}
+ {{- if or .NextInSection .PrevInSection }}
<nav class="pagination transparent">
- {{ if .NextInSection }}
+ {{- if .NextInSection }}
<a class="button" href="{{ .NextInSection.RelPermalink }}" title="{{ .NextInSection.Title }}">← Newer Post</a>
- {{ end }}
- {{ if .PrevInSection }}
+ {{- end }}
+ {{- if .PrevInSection }}
<a class="button right" href="{{ .PrevInSection.RelPermalink }}" title="{{ .PrevInSection.Title }}">Previous Post →</a>
- {{ end }}
+ {{- end }}
</nav>
- {{ end }}
+ {{- end }}
</main>
-{{ end }}
+{{- end }}
diff --git a/layouts/archive/single.html b/layouts/archive/single.html
@@ -1,36 +1,36 @@
{{ define "main" }}
<header class="page-header">
<h1>{{ .Title }}</h1>
- {{ with .Params.subtitle }}
+ {{- with .Params.subtitle }}
<h2>{{ . }}</h2>
- {{ end }}
+ {{- end }}
</header>
<main>
<article>
<div class="post-content">
<h2>Posts ({{ len (where (where .Site.Pages "File.Dir" "==" "blog/") "IsPage" true) }})</h2>
- {{ range .Site.Params.active_years -}}
- {{ $y := . -}}
+ {{- range .Site.Params.active_years }}
+ {{- $y := . }}
<h4>{{ . }}</h4>
<ul>
- {{ range $.Site.Pages -}}
- {{ if and (eq .File.Dir "blog/") (.IsPage) (eq $y (.Date.Format "2006")) -}}
+ {{- range $.Site.Pages }}
+ {{- if and (eq .File.Dir "blog/") (.IsPage) (eq $y (.Date.Format "2006")) }}
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a> ({{ .Date.Format "January 2" }})</li>
- {{ end -}}
- {{ end -}}
+ {{- end }}
+ {{- end }}
</ul>
- {{ end -}}
+ {{- end }}
<h2>Categories ({{ len .Site.Taxonomies.categories }})</h2>
<ul>
- {{ range .Site.Taxonomies.categories -}}
+ {{- range .Site.Taxonomies.categories }}
<li><a href="{{ .Page.RelPermalink }}">{{ .Page.Title | title }}</a> ({{ .Count }} {{ if eq .Count 1}}entry{{ else }}entries{{ end }})</li>
- {{ end -}}
+ {{- end }}
</ul>
<h2>Tags ({{ len .Site.Taxonomies.tags }})</h2>
<ul>
- {{ range .Site.Taxonomies.tags -}}
+ {{- range .Site.Taxonomies.tags }}
<li><a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a> ({{ .Count }} {{ if eq .Count 1}}entry{{ else }}entries{{ end }})</li>
- {{ end -}}
+ {{- end }}
</ul>
</div>
</article>
diff --git a/layouts/composer/single.html b/layouts/composer/single.html
@@ -2,8 +2,8 @@
<html lang="en">
<head>
{{ partial "head-base.html" . }}
- {{ $options := (dict "targetPath" "css/composer.css" "outputStyle" "compressed") }}
- {{ $style := resources.Get "css/composer.scss" | resources.ToCSS $options }}
+ {{- $options := (dict "targetPath" "css/composer.css" "outputStyle" "compressed") }}
+ {{- $style := resources.Get "css/composer.scss" | resources.ToCSS $options }}
<link rel="stylesheet" type="text/css" href="{{ $style.RelPermalink }}">
</head>
<body>
@@ -11,7 +11,7 @@
<span id="word-count">0 words · 0 minutes</span> · <a onclick="toggleTheme()">Toggle theme</a>
</nav>
<textarea id="composer" placeholder="Start writing..." autofocus></textarea>
- {{ $js := resources.Get "js/composer.js" | resources.Minify }}
+ {{- $js := resources.Get "js/composer.js" | resources.Minify }}
<script type="text/javascript" src="{{ $js.RelPermalink }}"></script>
<a href="/jsweblabels/" rel="jslicense" style="display: none;">JavaScript Web Labels</a>
</body>
diff --git a/layouts/index.html b/layouts/index.html
@@ -6,7 +6,7 @@
<meta name="author" content="{{ .Site.Author.name }}">
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no">
<title>Oscar Benedito</title>
- {{ $favicon := resources.Get "img/favicon.min.svg" }}
+ {{- $favicon := resources.Get "img/favicon.min.svg" }}
<link rel="icon" href="{{ $favicon.RelPermalink }}">
<link rel="shortcut icon" href="/favicon.ico">
{{- $style := resources.Get "css/landing.css" | resources.Minify }}
diff --git a/layouts/page/single.html b/layouts/page/single.html
@@ -1,9 +1,9 @@
{{ define "main" }}
<header class="page-header">
<h1>{{ .Title }}</h1>
- {{ with .Params.subtitle }}
+ {{- with .Params.subtitle }}
<h2>{{ . }}</h2>
- {{ end }}
+ {{- end }}
</header>
<main>
<article>
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html
@@ -14,12 +14,12 @@
</div>
<div class="column right">
<h3>License</h3>
- {{ if eq .Params.headtitle "GPLv3" }}
+ {{- if or (eq .Params.headtitle "GPLv3") (eq .Params.headtitle "AGPLv3") }}
<p>Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.</p>
- {{ end }}
- {{ if eq .Params.headtitle "CC BY 4.0" }}
+ {{- end }}
+ {{- if eq .Params.headtitle "CC BY 4.0" }}
<p>See the <a href="https://wiki.creativecommons.org/wiki/Modifying_the_CC_licenses">License Modification Policy</a>.</p>
- {{ end }}
+ {{- end }}
<p>{{ if eq .Params.title "License" }}Any other part of this page{{ else }}This work{{ end }} is licensed under a <a rel="license" href="https://creativecommons.org/licenses/by/4.0/">Creative Commons Attribution 4.0 International License</a>.</p>
<p><a href="/licenses/cc-by-4.0/">Local copy of the license</a>.</p>
</div>
diff --git a/layouts/partials/head-base.html b/layouts/partials/head-base.html
@@ -2,7 +2,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
{{/* {{ if .Site.Params.description }}<meta name="description" content="{{ site.description }}">{% endif %} */}}
<meta name="author" content="{{ .Site.Author.name }}">
-{{ $favicon := resources.Get "img/favicon.min.svg" }}
+{{- $favicon := resources.Get "img/favicon.min.svg" }}
<link rel="icon" href="{{ $favicon.RelPermalink }}">
<link rel="shortcut icon" href="/favicon.ico">
<title>{{ if .Params.headtitle }}{{ .Params.headtitle }} | {{ else if eq .Kind "taxonomy" }}{{ .Title | title }} | {{ else if not .IsHome }}{{ .Title }} | {{ end }}{{ .Site.Title }}</title>
diff --git a/layouts/partials/read-time.html b/layouts/partials/read-time.html
@@ -1,2 +1,2 @@
-{{ $readTime := math.Round (div (countwords .Content) 140.0) }}
+{{ $readTime := math.Round (div (countwords .Content) 140.0) -}}
{{ if le $readTime 1.0 }}1 minute{{ else }}{{ $readTime }} minutes{{ end }}
diff --git a/layouts/shortcodes/js-label.html b/layouts/shortcodes/js-label.html
@@ -1,7 +1,7 @@
<tr>
- {{ $js := resources.Get (.Get "asset") | resources.Minify -}}
+ {{- $js := resources.Get (.Get "asset") | resources.Minify -}}
<td><a href="{{ $js.RelPermalink }}">{{ $js.RelPermalink }}</a></td>
<td><a href="{{ .Get "license-url" }}">{{ .Get "license-slug" }}</a></td>
- {{ $js := resources.Get (.Get "asset") -}}
+ {{- $js := resources.Get (.Get "asset") -}}
<td><a href="{{ $js.RelPermalink }}">{{ $js.RelPermalink }}</a></td>
</tr>