diff options
author | Jhaura Wachsman <jhaurawachsman@gmail.com> | 2020-04-18 22:00:48 +0300 |
---|---|---|
committer | Jhaura Wachsman <jhaurawachsman@gmail.com> | 2020-04-18 22:00:48 +0300 |
commit | 41e40c4cbb427a823f1e71753ababd69fe98048f (patch) | |
tree | 2853dfb94446179420fb5b7a3e49d567a49bec1a /layouts | |
parent | cbeaa6980ce8e0d7098146ce4c7f413ae35c8886 (diff) |
Harden Author data
Diffstat (limited to 'layouts')
-rw-r--r-- | layouts/partials/author-data.html | 8 | ||||
-rw-r--r-- | layouts/partials/author.html | 3 | ||||
-rw-r--r-- | layouts/partials/svg/avatar.svg | 1 |
3 files changed, 9 insertions, 3 deletions
diff --git a/layouts/partials/author-data.html b/layouts/partials/author-data.html index 8454054..efb1003 100644 --- a/layouts/partials/author-data.html +++ b/layouts/partials/author-data.html @@ -1,4 +1,6 @@ -{{- $data := (dict "default" (dict "name" "Unknown" "uri" "#" "email" "#" "twitter" "#" "image" "#")) -}} +{{- $image := partial "svg/avatar.svg" (dict) | base64Encode -}} +{{- $image = printf "%s%s" "data:image/svg+xml;base64," $image | safeURL -}} +{{- $data := (dict "default" (dict "name" "Unknown" "uri" "#" "email" "#" "twitter" "#" "image" $image)) -}} {{- with .Site.Data.author }} {{- $data = . -}} {{- end }} @@ -7,4 +9,8 @@ {{- $author = index $data . -}} {{- end }} {{- $author = $author | default $data.default -}} +{{- if not (eq (substr $author.image 0 10) "data:image") }} +{{- $image = partial "cdn-src" (dict "Site" $.Site "Page" . "src" $author.image) -}} +{{- $author = merge $author (dict "image" $image) -}} +{{- end }} {{- return $author }} diff --git a/layouts/partials/author.html b/layouts/partials/author.html index 1fd922a..0021d43 100644 --- a/layouts/partials/author.html +++ b/layouts/partials/author.html @@ -1,11 +1,10 @@ {{- $author := partial "author-data" . -}} -{{- $imgAuthor := partial "cdn-src" (dict "Site" $.Site "Page" . "src" $author.image) }} {{- $dateFormat := .Site.Params.dateFormat | default "Jan 2, 2006 3:04PM" -}} <div class="flex items-center"> <div class="flex-shrink-0"> <img class="w-14 h-14 object-cover p-05 rounded-full border border-blue-300" - src="{{ $imgAuthor }}" + src="{{ $author.image }}" alt="{{ $author.name }}"> </div> <div class="flex-shrink-0 ml-2 leading-tight font-content-sans"> diff --git a/layouts/partials/svg/avatar.svg b/layouts/partials/svg/avatar.svg new file mode 100644 index 0000000..6a1e1a4 --- /dev/null +++ b/layouts/partials/svg/avatar.svg @@ -0,0 +1 @@ +<svg {{ with .class }}class="{{ . }}" {{ end }}{{ with .style }}style="{{ . | safeCSS }}" {{ end }}viewBox="{{ with .viewbox }}{{ . }}{{ else }}0 0 32 32{{ end }}" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><path fill="#eceff1" d="M0 0h32v32H0z"/><path fill="#455a64" d="M29.305 24.407c-.795-.63-1.765-1.08-2.816-1.3L21.476 22.1a1.13 1.13 0 0 1-.905-1.12v-1.15c.322-.453.626-1.054.944-1.682.247-.487.62-1.22.805-1.4 1.015-1.02 1.995-2.165 2.3-3.64.283-1.385.005-2.112-.322-2.697 0-1.46-.046-3.29-.39-4.62-.04-1.8-.368-2.814-1.19-3.7-.58-.63-1.435-.775-2.123-.89-.27-.046-.642-.1-.78-.183C18.594.347 17.4.025 15.952 0c-3 .123-6.71 2.04-7.95 5.454-.384 1.04-.345 2.747-.313 4.12l-.03.825c-.295.576-.585 1.307-.3 2.697.302 1.48 1.282 2.626 2.315 3.66.17.174.55.914.802 1.403l.95 1.675v1.15c0 .546-.382 1.017-.9 1.12L5.5 23.11c-1.045.222-2.014.67-2.807 1.298a1.15 1.15 0 0 0-.427.805 1.14 1.14 0 0 0 .293.859C5.975 29.838 10.873 32 16 32s10.027-2.16 13.44-5.93a1.14 1.14 0 0 0-.135-1.664z"/></svg> |