chore: improve email protect

pull/225/head
Septs 2021-12-24 18:12:54 +08:00
parent f50fb32988
commit 1d6df79e17
No known key found for this signature in database
GPG Key ID: 6EC3B9D7E6EE828F
3 changed files with 5 additions and 6 deletions

View File

@ -3,6 +3,7 @@
"editor.codeActionsOnSave": {
"source.fixAll": true
},
"editor.wordWrap": "on",
"markdownlint.config": {
"single-h1": false,
"no-inline-html": false,

View File

@ -1,5 +1,3 @@
document.querySelectorAll('a[data-href]').forEach((element) => {
element.href = atob(element.dataset.href);
delete element.dataset.href;
})
document.querySelectorAll('a[href^="mailto:"]').forEach((element) => {
element.href = atob(element.href.replace(/^mailto:/, ''));
});

View File

@ -1,7 +1,7 @@
{{- if hasPrefix .Destination "mailto:" -}}
{{- $text := replace (replace .Text "-" "--") "_" "__" -}}
{{- $icon := resources.GetRemote (printf "https://img.shields.io/badge/email-%s-blue.svg?style=flat-square" $text) -}}
<a class="email" data-href="{{ .Destination | base64Encode }}"><img class="shields-icon" src="{{ $icon.Permalink }}" /></a>
<a href="mailto:{{ .Destination | base64Encode }}"><img class="shields-icon" src="{{ $icon.Permalink }}" /></a>
{{- else -}}
<a href="{{ .Destination }}"{{ with .Title}} title="{{ . }}"{{ end }}{{ if hasPrefix .Destination "http" }} target="_blank"{{ end }}>
{{- .Text | safeHTML -}}