feat(svg): now serving svgs in separate files

This commit is contained in:
2022-08-18 17:33:56 +02:00
parent 8eea49af62
commit d888c8eeff
8 changed files with 87 additions and 73 deletions

View File

@@ -32,7 +32,7 @@ class="toxicGlow"
<div id="home-nav-header"> <div id="home-nav-header">
All the fun lies right here All the fun lies right here
<br> <br>
<img width="30" height="20" alt="Down arrow" src="{{"arrow.svg" | relURL}}"> <object type="image/svg+xml" width="30" height="20" data="{{"arrow.svg" | relURL}}"></object>
</div> </div>
<nav id="home-nav" class="site-nav"> <nav id="home-nav" class="site-nav">
{{ partialCached "menu.html" . }} {{ partialCached "menu.html" . }}

View File

@@ -43,9 +43,9 @@
{{- else if (eq .name "qq") -}} {{- else if (eq .name "qq") -}}
<svg xmlns="http://www.w3.org/2000/svg" class="feather" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path transform="scale(0.04) translate(75 40)" stroke-width="50" d="M433.754 420.445c-11.526 1.393-44.86-52.741-44.86-52.741 0 31.345-16.136 72.247-51.051 101.786 16.842 5.192 54.843 19.167 45.803 34.421-7.316 12.343-125.51 7.881-159.632 4.037-34.122 3.844-152.316 8.306-159.632-4.037-9.045-15.25 28.918-29.214 45.783-34.415-34.92-29.539-51.059-70.445-51.059-101.792 0 0-33.334 54.134-44.859 52.741-5.37-.65-12.424-29.644 9.347-99.704 10.261-33.024 21.995-60.478 40.144-105.779C60.683 98.063 108.982.006 224 0c113.737.006 163.156 96.133 160.264 214.963 18.118 45.223 29.912 72.85 40.144 105.778 21.768 70.06 14.716 99.053 9.346 99.704z"></path></svg> <svg xmlns="http://www.w3.org/2000/svg" class="feather" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path transform="scale(0.04) translate(75 40)" stroke-width="50" d="M433.754 420.445c-11.526 1.393-44.86-52.741-44.86-52.741 0 31.345-16.136 72.247-51.051 101.786 16.842 5.192 54.843 19.167 45.803 34.421-7.316 12.343-125.51 7.881-159.632 4.037-34.122 3.844-152.316 8.306-159.632-4.037-9.045-15.25 28.918-29.214 45.783-34.415-34.92-29.539-51.059-70.445-51.059-101.792 0 0-33.334 54.134-44.859 52.741-5.37-.65-12.424-29.644 9.347-99.704 10.261-33.024 21.995-60.478 40.144-105.779C60.683 98.063 108.982.006 224 0c113.737.006 163.156 96.133 160.264 214.963 18.118 45.223 29.912 72.85 40.144 105.778 21.768 70.06 14.716 99.053 9.346 99.704z"></path></svg>
{{- else if (eq .name "root me") -}} {{- else if (eq .name "root me") -}}
<img class="feather" width="24" height="24" alt="Root-me" src="{{"rootme.svg" | relURL}}"> <object type="image/svg+xml" class="feather" width="24" height="24" alt="Root-me" data="{{"rootme.svg" | relURL}}"></object>
{{- else if (eq .name "GPG") -}} {{- else if (eq .name "GPG") -}}
<img class="feather" width="24" height="24" alt="GPG" src="{{"Gnupg-logo.svg" | relURL}}"> <object type="image/svg+xml" class="feather" width="24" height="24" alt="GPG" data="{{"Gnupg-logo.svg" | relURL}}"></object>
{{- else -}} {{- else -}}
<svg xmlns="http://www.w3.org/2000/svg" class="feather feather-link" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg> <svg xmlns="http://www.w3.org/2000/svg" class="feather feather-link" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"></path><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"></path></svg>
{{- end -}} {{- end -}}

View File

@@ -1,77 +1,86 @@
{{ define "head" }} {{ define "head" }}
{{ if .Params.featuredImg -}} {{ if .Params.featuredImg -}}
<style>.bg-img {background-image: url('{{.Params.featuredImg}}');}</style> <style>
{{- else if .Params.images -}} .bg-img {
{{- range first 1 .Params.images -}} background-image: url('{{.Params.featuredImg}}');
<style>.bg-img {background-image: url('{{. | absURL}}');}</style> }
{{- end -}} </style>
{{- end -}} {{- else if .Params.images -}}
{{- range first 1 .Params.images -}}
<style>
.bg-img {
background-image: url('{{. | absURL}}');
}
</style>
{{- end -}}
{{- end -}}
{{ end }} {{ end }}
{{ define "header" }} {{ define "header" }}
{{ partial "header.html" . }} {{ partial "header.html" . }}
{{ end }} {{ end }}
{{ define "main" }} {{ define "main" }}
{{- if (or .Params.images .Params.featuredImg) }} {{- if (or .Params.images .Params.featuredImg) }}
<div class="bg-img"></div> <div class="bg-img"></div>
{{- end }} {{- end }}
<main class="site-main section-inner animated fadeIn faster"> <main class="site-main section-inner animated fadeIn faster">
<article class="thin"> <article class="thin">
<header class="post-header"> <header class="post-header">
<div class="post-meta"><span>{{ .Date.Format .Site.Params.dateform }}</span></div> <div class="post-meta"><span>{{ .Date.Format .Site.Params.dateform }}</span></div>
<h1>{{ .Title }}</h1> <h1>{{ .Title }}</h1>
</header> </header>
<div class="content"> <div class="content">
{{ .Content | replaceRE "(<h[1-6] id=\"([^\"]+)\".+)(</h[1-6]+>)" `${1}<a href="#${2}" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg></a>${3}` | safeHTML }} {{ .Content | replaceRE "(
</div> <h[1-6] id=\ "([^\"]+)\ ".+)(</h[1-6]+>)" `${1}<a href="#${2}" class="anchor" aria-hidden="true"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M15 7h3a5 5 0 0 1 5 5 5 5 0 0 1-5 5h-3m-6 0H6a5 5 0 0 1-5-5 5 5 0 0 1 5-5h3"></path><line x1="8" y1="12" x2="16" y2="12"></line></svg></a>${3}`
{{- if .Site.Params.relatedPosts }} | safeHTML }}
{{- partial "related-posts.html" . -}} </div>
{{- end }} {{- if .Site.Params.relatedPosts }} {{- partial "related-posts.html" . -}} {{- end }}
<hr class="post-end"> <hr class="post-end">
<footer class="post-info"> <footer class="post-info">
{{- with $.Param "author" }} {{- with $.Param "author" }}
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-feather"><path d="M20.24 12.24a6 6 0 0 0-8.49-8.49L5 10.5V19h8.5z"></path><line x1="16" y1="8" x2="2" y2="22"></line><line x1="17.5" y1="15" x2="9" y2="15"></line></svg>{{ . }}</p> <p>
{{- end }} <object type="image/svg+xml" width="24" height="24" data="{{"author.svg" | relURL}}">{{.}}</object>
{{- with .Params.tags }} </p>
<p> {{- end }}
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tag meta-icon"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7" y2="7"></line></svg> {{- with .Params.tags }}
{{- range . -}} <p>
<span class="tag"><a href="{{ "tags/" | absLangURL }}{{ . | urlize }}">{{.}}</a></span> <object type="image/svg+xml" width="24" height="24" data="{{"tag.svg" | relURL}}"></object>
{{- end }} {{- range . -}}
</p> <span class="tag"><a href="{{ "tags/" | absLangURL }}{{ . | urlize }}">{{.}}</a></span>
{{- end }} {{- end }}
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file-text"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>{{ i18n "wordCount" . }}</p> </p>
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-calendar"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>{{ dateFormat .Site.Params.dateformNumTime .Date.Local }}</p> {{- end }}
{{- if and .GitInfo .Site.Params.gitUrl }} <p><object type="image/svg+xml" width="24" height="24" data="{{"page.svg" | relURL}}">{{ i18n "wordCount " . }}</object></p>
<p><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-git-commit"><circle cx="12" cy="12" r="4"></circle><line x1="1.05" y1="12" x2="7" y2="12"></line><line x1="17.01" y1="12" x2="22.96" y2="12"></line></svg><a href="{{ .Site.Params.gitUrl -}}{{ .GitInfo.Hash }}" target="_blank" rel="noopener">{{ .GitInfo.AbbreviatedHash }}</a> @ {{ dateFormat .Site.Params.dateformNum .GitInfo.AuthorDate.Local }}</p> <p><object type="image/svg+xml" width="24" height="24" data="{{"calendar.svg" | relURL}}">{{ dateFormat .Site.Params.dateform .Date.Local }}</object></p>
{{- end }} {{- if and .GitInfo .Site.Params.gitUrl }}
</footer> <p><object type="image/svg+xml" width="24" height="24" data="{{"gitinfo.svg" | relURL}}"></object><a href="{{ .Site.Params.gitUrl -}}{{ .GitInfo.Hash }}" target="_blank" rel="noopener">{{ .GitInfo.AbbreviatedHash }}</a> @ {{ dateFormat .Site.Params.dateform .GitInfo.AuthorDate.Local }}</p>
</article> {{- end }}
{{- if .Params.toc }} </footer>
<aside id="toc"> </article>
<div class="toc-title">{{ i18n "tableOfContents" }}</div> {{- if .Params.toc }}
{{ .TableOfContents }} <aside id="toc ">
</aside> <div class="toc-title ">{{ i18n "tableOfContents " }}</div>
{{- end }} {{ .TableOfContents }}
<div class="post-nav thin"> </aside>
{{- with .NextInSection }} {{- end }}
<a class="next-post" href="{{ .Permalink }}"> <div class="post-nav thin ">
<span class="post-nav-label"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-left"><line x1="19" y1="12" x2="5" y2="12"></line><polyline points="12 19 5 12 12 5"></polyline></svg>&nbsp;{{ i18n "newer" }}</span><br><span>{{ .Title }}</span> {{- with .NextInSection }}
</a> <a class="next-post " href="{{ .Permalink }} ">
{{- end }} <span class="post-nav-label "><svg xmlns="http://www.w3.org/2000/svg " width="24 " height="24 " viewBox="0 0 24 24 " fill="none " stroke="#fff " stroke-width="2 " stroke-linecap="round " stroke-linejoin="round " class="feather feather-arrow-left
{{- with .PrevInSection }} "><line x1="19 " y1="12 " x2="5 " y2="12 "></line><polyline points="12 19 5 12 12 5 "></polyline></svg>&nbsp;{{ i18n "newer " }}</span><br><span>{{ .Title }}</span>
<a class="prev-post" href="{{ .Permalink }}"> </a>
<span class="post-nav-label">{{ i18n "older" }}&nbsp;<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-arrow-right"><line x1="5" y1="12" x2="19" y2="12"></line><polyline points="12 5 19 12 12 19"></polyline></svg></span><br><span>{{ .Title }}</span> {{- end }}
</a> {{- with .PrevInSection }}
{{- end }} <a class="prev-post " href="{{ .Permalink }} ">
</div> <span class="post-nav-label ">{{ i18n "older " }}&nbsp;<svg xmlns="http://www.w3.org/2000/svg " width="24 " height="24 " viewBox="0 0 24 24 " fill="none " stroke="#fff " stroke-width="2 " stroke-linecap="round " stroke-linejoin="round
<div id="comments" class="thin"> " class="feather feather-arrow-right "><line x1="5 " y1="12 " x2="19 " y2="12 "></line><polyline points="12 5 19 12 12 19 "></polyline></svg></span><br><span>{{ .Title }}</span>
{{- partial "comments.html" . -}} </a>
</div> {{- end }}
</main> </div>
<div id="comments " class="thin ">
{{- partial "comments.html " . -}}
</div>
</main>
{{ end }} {{ end }}
{{ define "footer " }}
{{ define "footer" }} {{ partialCached "footer.html " . }}
{{ partialCached "footer.html" . }}
{{ end }} {{ end }}

1
static/author.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-feather"><path d="M20.24 12.24a6 6 0 0 0-8.49-8.49L5 10.5V19h8.5z"></path><line x1="16" y1="8" x2="2" y2="22"></line><line x1="17.5" y1="15" x2="9" y2="15"></line></svg>

After

Width:  |  Height:  |  Size: 365 B

1
static/calendar.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-calendar"><rect x="3" y="4" width="18" height="18" rx="2" ry="2"></rect><line x1="16" y1="2" x2="16" y2="6"></line><line x1="8" y1="2" x2="8" y2="6"></line><line x1="3" y1="10" x2="21" y2="10"></line></svg>

After

Width:  |  Height:  |  Size: 402 B

1
static/gitinfo.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-git-commit"><circle cx="12" cy="12" r="4"></circle><line x1="1.05" y1="12" x2="7" y2="12"></line><line x1="17.01" y1="12" x2="22.96" y2="12"></line></svg>

After

Width:  |  Height:  |  Size: 350 B

1
static/page.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-file-text"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>

After

Width:  |  Height:  |  Size: 465 B

1
static/tag.svg Normal file
View File

@@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-tag meta-icon"><path d="M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"></path><line x1="7" y1="7" x2="7" y2="7"></line></svg>

After

Width:  |  Height:  |  Size: 354 B