feat: Add obfuscates partials
This commit is contained in:
parent
84539d10ae
commit
b8ae0a19ca
|
@ -15,6 +15,10 @@ cd themes
|
|||
git submodule add https://git.weko.io/kosssi/hugo-theme-lowtech.git
|
||||
```
|
||||
|
||||
## Contact
|
||||
|
||||
Pour la gestion de contact il est possible d'utiliser des shortcodes spécifiques `{{< mail >}}` ou `{{< tel >}}`
|
||||
|
||||
## Inspirations
|
||||
|
||||
- https://github.com/yuin/goldmark/issues/59
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
const obfuscates = document.getElementsByClassName("obfuscate");
|
||||
for (const element of obfuscates) {
|
||||
const link = document.createElement("a");
|
||||
const separators = element.dataset.separators;
|
||||
const protocol = element.dataset.param1.split("").reverse().join("");
|
||||
let url = protocol;
|
||||
for (let i = 0; i < separators.length; i++) {
|
||||
url += separators[i] + element.dataset["param" + (i+2)].split("").reverse().join("");
|
||||
}
|
||||
let text = element.dataset.param2.split("").reverse().join("");
|
||||
for (let i = 1; i < separators.length; i++) {
|
||||
text += separators[i] + element.dataset["param" + (i+2)].split("").reverse().join("");
|
||||
}
|
||||
link.innerText = url.replace(new RegExp(element.dataset.regex, 'i'), element.dataset.replace);
|
||||
link.href = url;
|
||||
link.rel = "nofollow";
|
||||
element.parentElement.insertBefore(link, element);
|
||||
}
|
||||
while (obfuscates.length > 0) obfuscates[0].remove();
|
|
@ -0,0 +1,9 @@
|
|||
export default function abfuscates() {
|
||||
const obfuscates = document.getElementsByClassName("obfuscate");
|
||||
while (obfuscates.length > 0) {
|
||||
const element = obfuscates[0]
|
||||
element.href = element.dataset.link.split("").reverse().join("");
|
||||
element.innerText = element.innerText.split("").reverse().join("");
|
||||
element.classList.remove('obfuscate');
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
.obfuscate
|
||||
unicode-bidi: bidi-override
|
||||
direction: rtl
|
|
@ -1,3 +1,9 @@
|
|||
{{- with .Site.Data.contact.mail -}}
|
||||
<a class="mail" href="mailto:{{ .}}">{{ . }}</a>
|
||||
{{- $protocol := "mailto" -}}
|
||||
{{- $mail := . -}}
|
||||
{{- $mailWithProtocol := print $protocol ":" . -}}
|
||||
<a
|
||||
class="mail obfuscate"
|
||||
data-link="{{ range $index := seq (sub (len $mailWithProtocol) 1) 0}}{{ substr $mailWithProtocol $index 1}}{{ end }}"
|
||||
>{{ range $index := seq (sub (len $mail) 1) 0}}{{ substr $mail $index 1}}{{ end }}</a>
|
||||
{{- end -}}
|
||||
|
|
|
@ -1,3 +1,9 @@
|
|||
{{- with .Site.Data.contact.telephone -}}
|
||||
<a class="tel" href="tel:{{ . }}">{{ . }}</a>
|
||||
{{- $protocol := "tel" -}}
|
||||
{{- $tel := . -}}
|
||||
{{- $telWithProtocol := print $protocol ":" (replace $tel " " "") -}}
|
||||
<a
|
||||
class="tel obfuscate"
|
||||
data-link="{{ range $index := seq (sub (len $telWithProtocol) 1) 0}}{{ substr $telWithProtocol $index 1}}{{ end }}"
|
||||
>{{ range $index := seq (sub (len $tel) 1) 0}}{{ substr $tel $index 1}}{{ end }}</a>
|
||||
{{- end -}}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{{ $js := resources.Get "js/main.js" }}
|
||||
{{ with $js }}
|
||||
{{ $secureJS := . | resources.Minify | resources.Fingerprint }}
|
||||
{{ $secureJS := . | js.Build | resources.Minify | resources.Fingerprint }}
|
||||
<script src="{{ $secureJS.Permalink }}" integrity="{{ $secureJS.Data.Integrity }}"></script>
|
||||
{{ end }}
|
||||
|
|
Loading…
Reference in New Issue