refactor: use base64 encode protect email address

pull/225/head
Septs 2021-12-24 16:48:10 +08:00
parent 552dafbebf
commit 880c35f9d1
No known key found for this signature in database
GPG Key ID: 6EC3B9D7E6EE828F
4 changed files with 10 additions and 3 deletions

View File

@ -0,0 +1,5 @@
document.querySelectorAll('a[data-href]').forEach((element) => {
element.href = atob(element.dataset.href);
delete element.dataset.href;
})

View File

@ -5,8 +5,7 @@ img.shields-icon {
a.github-profile {
color: inherit;
cursor: pointer;
text-decoration: none;
text-decoration: none !important;
display: inline-block;
vertical-align: middle;
img {

View File

@ -22,6 +22,9 @@ hostName = "https://mtf.wiki"
custom_css = [
"customize.scss"
]
custom_js = [
"customize.js"
]
[markup]
[markup.goldmark]

View File

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