Format HTML everywhere

This commit is contained in:
ItsDrike 2022-05-11 14:10:49 +02:00
parent 8955235db0
commit 75a45a192b
No known key found for this signature in database
GPG key ID: B014E761034AF742
18 changed files with 174 additions and 189 deletions

View file

@ -1 +1,3 @@
<h{{ .Level }} id="{{ .Anchor | safeURL }}"> <a class="anchor" href="#{{ .Anchor | safeURL }}">#</a> {{ .Text | safeHTML}}</h{{ .Level }}>
<h{{ .Level }} id="{{ .Anchor | safeURL }}">
<a class="anchor" href="#{{ .Anchor | safeURL }}">#</a> {{ .Text | safeHTML}}
</h{{ .Level }}>

View file

@ -3,12 +3,13 @@
{{ $resource := .Page.Resources.GetMatch $destination }}
{{ if $resource }}
{{ $destination = ($resource.Resize "1500x webp").RelPermalink }}
{{ $destination = ($resource.Resize "1500x webp").RelPermalink }}
{{ end }}
<figure class="text-center">
<img src="{{ $destination | safeURL }}" alt="{{ .Text | plainify }}" style='max-width: {{ default "90" .Title }}%;' referrerpolicy="no-referrer" loading="lazy" decoding="async" />
<figcaption class="text-center">
<small>{{ .Text }}</small>
</figcaption>
<img src="{{ $destination | safeURL }}" alt="{{ .Text | plainify }}" style='max-width: {{ default "90" .Title }}%;'
referrerpolicy="no-referrer" loading="lazy" decoding="async" />
<figcaption class="text-center">
<small>{{ .Text }}</small>
</figcaption>
</figure>

View file

@ -1,6 +1,7 @@
<!DOCTYPE HTML>
<html lang="en">
<head>
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Language" content="{{ .Site.Language.Lang }}">
{{ partial "style.html" "scss/style.scss" }}
@ -12,8 +13,9 @@
<title>{{ partial "title-item.html" . }}{{ .Site.Title }}</title>
{{ block "head_extra" . }}{{ end }}
</head>
<body>
</head>
<body>
{{ partial "navbar.html" . }}
{{ block "main" . }}{{ end }}
{{ partial "footer.html" . }}
@ -21,5 +23,6 @@
{{ partial "script.html" "js/jquery.min.js" }}
{{ partial "script_async.html" "js/bootstrap.min.js" }}
{{ block "scripts_extra" . }}{{ end }}
</body>
</body>
</html>

View file

@ -1,48 +1,40 @@
{{ define "head_extra" }}
{{ partial "style.html" "scss/forbid_style.scss" }}
{{ partial "style.html" "scss/forbid_style.scss" }}
{{ end }}
{{ define "main" }}
<div id="main" class="wrapper_forbid">
<div id="main" class="wrapper_forbid">
<h1>{{ .Title }}</h1>
<p>{{ .Content }}</p>
<svg
viewbox="0 0 100 150"
preserveAspectRatio="xMidYMid slice"
height="720" width="480"
>
<svg viewbox="0 0 100 150" preserveAspectRatio="xMidYMid slice" height="720" width="480">
<path class="grid-lines__line grid-lines__line--hor" d="m0,39 l100,0" />
<path class="grid-lines__line grid-lines__line--hor" d="m0,75 l100,0" />
<path class="grid-lines__line grid-lines__line--hor" d="m0,111 l100,0" />
<path class="grid-lines__line grid-lines__line--ver" d="m14,0 l0,150" />
<path class="grid-lines__line grid-lines__line--ver" d="m32,0 l0,150" />
<path class="grid-lines__line grid-lines__line--ver" d="m50,0 l0,150" />
<path class="grid-lines__line grid-lines__line--ver" d="m68,0 l0,150" />
<path class="grid-lines__line grid-lines__line--ver" d="m86,0 l0,150" />
<path class="grid-lines__line grid-lines__line--diag" d="m14,0 l72,150" />
<path class="grid-lines__line grid-lines__line--diag" d="m0,25 l100,100" />
<path class="grid-lines__line grid-lines__line--diag" d="m100,25 l-100,100" />
<path class="grid-lines__line grid-lines__line--diag" d="m86,0 l-72,150" />
<path class="grid-lines__line grid-lines__line--cir"
d="m50,57 c18,0 18,18 18,18
<path class="grid-lines__line grid-lines__line--hor" d="m0,39 l100,0" />
<path class="grid-lines__line grid-lines__line--hor" d="m0,75 l100,0" />
<path class="grid-lines__line grid-lines__line--hor" d="m0,111 l100,0" />
<path class="grid-lines__line grid-lines__line--ver" d="m14,0 l0,150" />
<path class="grid-lines__line grid-lines__line--ver" d="m32,0 l0,150" />
<path class="grid-lines__line grid-lines__line--ver" d="m50,0 l0,150" />
<path class="grid-lines__line grid-lines__line--ver" d="m68,0 l0,150" />
<path class="grid-lines__line grid-lines__line--ver" d="m86,0 l0,150" />
<path class="grid-lines__line grid-lines__line--diag" d="m14,0 l72,150" />
<path class="grid-lines__line grid-lines__line--diag" d="m0,25 l100,100" />
<path class="grid-lines__line grid-lines__line--diag" d="m100,25 l-100,100" />
<path class="grid-lines__line grid-lines__line--diag" d="m86,0 l-72,150" />
<path class="grid-lines__line grid-lines__line--cir" d="m50,57 c18,0 18,18 18,18
c0,18 -18,18 -18,18
c-18,0 -18,-18 -18,-18
c0,-18 18,-18 18,-18" />
<path class="grid-lines__line grid-lines__line--cir"
d="m50,39 c36,0 36,36 36,36
<path class="grid-lines__line grid-lines__line--cir" d="m50,39 c36,0 36,36 36,36
c0,36 -36,36 -36,36
c-36,0 -36,-36 -36,-36
c0,-36 36,-36 36,-36" />
<path class="grid-lines__line grid-lines__line--cir"
d="m50,21 c54,0 54,54 54,54
<path class="grid-lines__line grid-lines__line--cir" d="m50,21 c54,0 54,54 54,54
c0,54 -54,54 -54,54
c-54,0 -54,-54 -54,-54
c0,-54 54,-54 54,-54" />
<path class="wiz wiz--hair-bg"
d="m50,48
<path class="wiz wiz--hair-bg" d="m50,48
c0,0 6,0 6,2
c0,0 0,3 2,3
c0,0 2,0 2,4
@ -62,15 +54,13 @@
c0,0 2,0 2,-3
c0,0 6,0 6,-2" />
<path class="wiz wiz--head"
d="m50,50
<path class="wiz wiz--head" d="m50,50
c0,0 8,0 8,10
c0,0 0,10 -8,10
c0,0 -8,0 -8,-10
c0,0 0,-10 8,-10" />
<path class="wiz wiz--hair"
d="m50,48
<path class="wiz wiz--hair" d="m50,48
c0,0 6,0 6,2
c0,0 0,3 2,3
c0,0 2,0 2,4
@ -90,8 +80,7 @@
c0,0 0,-6 -4,-3" />
<path class="wiz wiz--hair"
d="m50,52
<path class="wiz wiz--hair" d="m50,52
c0,0 -6,-4 -6,4
c0,0 0,4 -2,4
c0,0 0,4 -2,4
@ -111,8 +100,7 @@
c0,0 -1,0 0,-4
c0,0 2,1 8,-1" />
<path class="wiz wiz--beard"
d="m50,69
<path class="wiz wiz--beard" d="m50,69
c0,0 5,0 5,-1
c0,0 4,0 4,2
c0,0 2,0 1,4
@ -135,15 +123,13 @@
c0,0 0,-4 2,-4
c0,0 0,1 6,1" />
<path class="wiz wiz--mouth"
d="m50,65
<path class="wiz wiz--mouth" d="m50,65
c0,0 5,0 5,3
c0,0 0,2 -5,2
c0,0 -5,0 -5,-2
c0,0 0,-4 5,-3" />
<path class="wiz wiz--mustache"
d="m50,64
<path class="wiz wiz--mustache" d="m50,64
c0,0 4,0 4,1
c0,0 2,0 2,2
c0,0 2,0 1,3
@ -159,34 +145,29 @@
c0,0 -2,-3 1,-3
c0,0 -1,-5 6,-2" />
<path class="wiz wiz--eye wiz--left"
d="m45,60
<path class="wiz wiz--eye wiz--left" d="m45,60
c0,0 2,0 2,1
c0,0 0,1 -2,0
c0,0 -1,0 0,-1" />
<path class="wiz wiz--eye wiz--right"
d="m52,60
<path class="wiz wiz--eye wiz--right" d="m52,60
c0,0 1,-1 2,0
c0,0 0,1 -2,1
c0,0 -1,0 0,-1" />
<path class="wiz wiz--eye-brow wiz--left"
d="m42,61
<path class="wiz wiz--eye-brow wiz--left" d="m42,61
c0,0 0,-3 1,-3
c0,0 3,0 4,2
c0,0 -1,-1 -4,-1
c0,0 -1,0 -1,2" />
<path class="wiz wiz--eye-brow wiz--right"
d="m51,60
<path class="wiz wiz--eye-brow wiz--right" d="m51,60
c0,0 2,-3 4,-3
c0,0 2,0 2,3
c0,0 -1,-2 -2,-2
c0,0 -2,0 -4,2" />
<path class="wiz wiz--sword"
d="m50,30
<path class="wiz wiz--sword" d="m50,30
c0,0 2,2 2,6
l0,50
l6,0
@ -209,8 +190,7 @@
c0,0 0,-3 2,-6
z" />
<path class="wiz wiz--staff"
d="m46,30
<path class="wiz wiz--staff" d="m46,30
l2,0
c0,0 1,0 1,1
l0,2
@ -234,5 +214,5 @@
c0,0 -1,0 -1,-4
c0,0 0,-3 1,-3" />
</svg>
</div>
</div>
{{ end }}

View file

@ -1,8 +1,8 @@
{{ define "main" }}
<div id="main">
<div id="main">
<div class="container">
{{ partial "header_image.html" . }}
{{ partial "content.html" . }}
{{ partial "header_image.html" . }}
{{ partial "content.html" . }}
</div>
</div>
</div>
{{ end }}

View file

@ -1,19 +1,19 @@
{{ define "main" }}
<div id="main">
<div id="main">
<div class="container">
{{ partial "content.html" . }}
{{ if .Content }}
{{ partial "content.html" . }}
{{ if .Content }}
<hr>
{{ end }}
{{ range .Pages.ByTitle }}
{{ end }}
{{ range .Pages.ByTitle }}
<div class="media list-page-item mb-3">
<div class="media-body">
<a href="{{ .RelPermalink }}">
<h5 class="my-0"><code>#{{ .Title }}</code></h5>
</a>
</div>
<div class="media-body">
<a href="{{ .RelPermalink }}">
<h5 class="my-0"><code>#{{ .Title }}</code></h5>
</a>
</div>
</div>
{{ end }}
{{ end }}
</div>
</div>
</div>
{{ end }}

View file

@ -1,8 +1,8 @@
{{ define "main" }}
<div id="main" class="short-top">
<div id="main" class="short-top">
<div class="container">
{{ partial "header_image.html" . }}
{{ .Content }}
{{ partial "header_image.html" . }}
{{ .Content }}
</div>
</div>
</div>
{{ end }}

View file

@ -5,21 +5,23 @@
{{ end }}
{{ if not .Parent.IsHome }}
{{ if gt .ReadingTime 2 }}
<span class="pr-2" title='Reading time'>
<i class="far fa-clock pr-1 content-detail"></i> {{ .ReadingTime }} minutes
</span>
{{ end }}
<span class="pr-2" title="Word count">
{{ if gt .ReadingTime 2 }}
<span class="pr-2" title="Reading time">
<i class="far fa-clock pr-1 content-detail"></i> {{ .ReadingTime }} minutes
</span>
{{ end }}
<span class="pr-2" title="Word count">
<i class="far fa-file-alt pr-1 content-detail"></i> {{ .WordCount }} words
</span>
</span>
{{ end }}
{{ if .Params.tags }}
<a href="{{ ref . " /tags" }}" class="no-color-change mr-1">
<i class="fas fa-tags small content-detail"></i>
</a>
{{ range $i, $e := .Params.tags }}
<span class="pr-2" title="Tags">
<a href="{{ ref . " /tags" }}" class="no-color-change mr-1">
<i class="fas fa-tags small content-detail"></i>
</a>
{{ range $i, $e := .Params.tags }}
<a href="/tags/{{ urlize . }}" class="mr-1">#{{ . }}</a>
{{ end }}
{{ end }}
</span>
{{ end }}

View file

@ -1,45 +1,45 @@
<h1 class="display-4">{{ .Title }}</h1>
{{ if .Params.subtitle }}
<h5 class="my-3">{{ markdownify .Params.subtitle | emojify }}</h5>
<h5 class="my-3">{{ markdownify .Params.subtitle | emojify }}</h5>
{{ end }}
{{ if .IsPage }}
<p>{{ partial "content-details.html" . }}</p>
<p>{{ partial "content-details.html" . }}</p>
<!-- When directly viewing the article, if available, we also include revision date-->
{{ if and (not .Lastmod.IsZero) (not (.Lastmod.Equal .Date)) }}
<span class="pr-2" title='{{ .Lastmod.Format "January 2 2006" }}'>
<i class="pr-1 content-detail">Article revised in: {{ .Lastmod.Format "January 2 2006" }}</i>
</span>
{{ end }}
<!-- When directly viewing the article, if available, we also include revision date-->
{{ if and (not .Lastmod.IsZero) (not (.Lastmod.Equal .Date)) }}
<span class="pr-2" title='{{ .Lastmod.Format "January 2 2006" }}'>
<i class="pr-1 content-detail">Article revised in: {{ .Lastmod.Format "January 2 2006" }}</i>
</span>
{{ end }}
{{ end }}
{{ if .Content }}
<hr>
<hr>
<div class="content mt-3">
<div class="content mt-3">
{{ if .TableOfContents }}
<!-- Get the amount of headers using regex -->
{{ $headers := findRE "<h[1-6].*?>(.|\n])+?</h[1-6]>" .Content }}
<!-- We only need to show a table of contents if we have over 4 headers -->
{{ if ge (len $headers) 4 }}
<!-- Get the amount of headers using regex -->
{{ $headers := findRE "<h[1-6].*?>(.|\n])+?</h[1-6]>" .Content }}
<!-- We only need to show a table of contents if we have over 4 headers -->
{{ if ge (len $headers) 4 }}
<div class="float-lg-end ml-lg-3 mb-3 p-3">
{{ .TableOfContents }}
{{ .TableOfContents }}
</div>
{{ end }}
{{ end }}
{{ .Content }}
<div id="sources">
{{ if .Params.Sources }}
<h2>Sources</h2>
<ul>
{{ range $i, $e := .Params.Sources }}
<li>{{ markdownify $e }}</li>
{{ end }}
</ul>
{{ end }}
</div>
</div>
{{ end }}
{{ .Content }}
<div id="sources">
{{ if .Params.Sources }}
<h2>Sources</h2>
<ul>
{{ range $i, $e := .Params.Sources }}
<li>{{ markdownify $e }}</li>
{{ end }}
</ul>
{{ end }}
</div>
</div>
{{ end }}

View file

@ -2,7 +2,7 @@
{{ $sizes := slice 16 32 64 100 200 }}
{{ range $sizes }}
{{ $sizes := printf "%dx%d" . . }}
<link rel="icon" type="image/png" sizes="{{ $sizes }}"
{{ $sizes := printf "%dx%d" . . }}
<link rel="icon" type="image/png" sizes="{{ $sizes }}"
href='{{ ((resources.Get $image | fingerprint).Resize $sizes).RelPermalink }}'>
{{ end }}

View file

@ -1,21 +1,22 @@
<footer class="p-5">
<div class="container">
<div class="row">
<div class="col-sm-2">
<p>&copy; {{ now.Year }} <a href='{{ ref . "contact" }}'>{{ .Site.Title }}</a>.</p>
<p></p>
</div>
<div class="col-sm-7">
<a href='{{ ref . "privacy-policy" }}'>Privacy policy</a>
</div>
<div class="col-sm-3">
<h3 class="text-right">
{{ range .Site.Data.social.footer_accounts }}
{{ $account := index $.Site.Data.social.accounts . }}
<a href="{{ $account.link }}"><i class="mx-1 {{ $account.icon }}" aria-hidden="true" title="{{ $account.name }}"></i></a>
{{ end }}
</h3>
</div>
<div class="container">
<div class="row">
<div class="col-sm-2">
<p>&copy; {{ now.Year }} <a href='{{ ref . "contact" }}'>{{ .Site.Title }}</a>.</p>
<p></p>
</div>
<div class="col-sm-7">
<a href='{{ ref . "privacy-policy" }}'>Privacy policy</a>
</div>
<div class="col-sm-3">
<h3 class="text-right">
{{ range .Site.Data.social.footer_accounts }}
{{ $account := index $.Site.Data.social.accounts . }}
<a href="{{ $account.link }}"><i class="mx-1 {{ $account.icon }}" aria-hidden="true"
title="{{ $account.name }}"></i></a>
{{ end }}
</h3>
</div>
</div>
</div>
</div>
</footer>

View file

@ -1,9 +1,9 @@
{{ if .Params.image }}
{{ .Scratch.Set "image" .Params.image }}
{{ if hasPrefix .Params.image "resource:" }}
{{ $resource := .Resources.GetMatch (replace .Params.image "resource:" "") }}
{{ .Scratch.Set "image" ($resource.Resize "2000x").RelPermalink }}
{{ end }}
<img class="mb-3 header-image" src='{{ .Scratch.Get "image" }}' />
{{ .Scratch.Set "image" .Params.image }}
{{ if hasPrefix .Params.image "resource:" }}
{{ $resource := .Resources.GetMatch (replace .Params.image "resource:" "") }}
{{ .Scratch.Set "image" ($resource.Resize "2000x").RelPermalink }}
{{ end }}
<img class="mb-3 header-image" src='{{ .Scratch.Get "image" }}' />
{{ end }}

View file

@ -1,31 +1,31 @@
<nav class="navbar navbar-expand-sm navbar-dark">
<!-- Navbar home -->
<a class="navbar-brand" href="{{ ref . "/" }}">
<code>/home/{{ lower .Site.Title }}</code>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav" aria-controls="navbarNav"
aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<!-- Navbar home -->
<a class="navbar-brand" href="{{ ref . " /" }}">
<code>/home/{{ lower .Site.Title }}</code>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<!-- Left side of the Navbar -->
<ul class="navbar-nav mr-auto">
<!-- Navbar pages -->
{{ $home := .Site.GetPage "home" }}
<div class="collapse navbar-collapse" id="navbarNav">
<!-- Left side of the Navbar -->
<ul class="navbar-nav mr-auto">
<!-- Navbar pages -->
{{ $home := .Site.GetPage "home" }}
{{ $pages := where .Site.RegularPages.ByTitle "Section" "" }}
{{ $nav_pages := union $pages .Site.Sections }}
{{ $pages := where .Site.RegularPages.ByTitle "Section" "" }}
{{ $nav_pages := union $pages .Site.Sections }}
{{ $nav_pages = where $nav_pages "Params.hidden_from_navbar" "!=" true }}
{{ $nav_pages = where $nav_pages "Params.hidden_from_navbar" "!=" true }}
{{ range sort $nav_pages "LinkTitle" }}
<li class="nav-item">
<a href="{{ .RelPermalink }}" class="nav-link">
<code>~/{{ urlize .LinkTitle }}</code>
</a>
</li>
{{ end }}
</ul>
</div>
{{ range sort $nav_pages "LinkTitle" }}
<li class="nav-item">
<a href="{{ .RelPermalink }}" class="nav-link">
<code>~/{{ urlize .LinkTitle }}</code>
</a>
</li>
{{ end }}
</ul>
</div>
</nav>

View file

@ -1,9 +1,9 @@
{{ $script := resources.Get . }}
{{ if in . "min" }}
{{ $script = $script | minify | fingerprint }}
{{ $script = $script | minify | fingerprint }}
{{ else }}
{{ $script = $script | js.Build (dict "minify" true) | fingerprint }}
{{ $script = $script | js.Build (dict "minify" true) | fingerprint }}
{{ end }}
<script type="text/javascript" src="{{ $script.RelPermalink }}" integrity="{{ $script.Data.Integrity }}"></script>

View file

@ -1,9 +1,9 @@
{{ $script := resources.Get . }}
{{ if in . "min" }}
{{ $script = $script | minify | fingerprint }}
{{ $script = $script | minify | fingerprint }}
{{ else }}
{{ $script = $script | js.Build (dict "minify" true) | fingerprint }}
{{ $script = $script | js.Build (dict "minify" true) | fingerprint }}
{{ end }}
<script type="text/javascript" async src="{{ $script.RelPermalink }}" integrity="{{ $script.Data.Integrity }}"></script>

View file

@ -1,5 +1,5 @@
{{ if .Content }}
{{ .Summary | chomp }}{{ if .Truncated }}&hellip;{{ end }}
{{ .Summary | chomp }}{{ if .Truncated }}&hellip;{{ end }}
{{ else if .Params.subtitle }}
{{ .Params.subtitle | markdownify | emojify }}
{{ .Params.subtitle | markdownify | emojify }}
{{ end }}

View file

@ -1,5 +1,5 @@
{{ .Title }} ::
{{ if .Parent }}{{ if not .Parent.IsHome }}
{{ partial "title-item.html" .Parent }}
{{ partial "title-item.html" .Parent }}
{{ end }}{{ end }}

View file

@ -1,7 +1,3 @@
<iframe
class="youtube-embed"
src="https://www.youtube-nocookie.com/embed/{{ .Get 0 }}"
frameborder="0"
<iframe class="youtube-embed" src="https://www.youtube-nocookie.com/embed/{{ .Get 0 }}" frameborder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowfullscreen
></iframe>
allowfullscreen></iframe>