astro-obfuscate is a set of components that prevent spam bots from finding email addresses, phone numbers, or other text that you wish to hide. Both SSG and SSR modes are supported.
npm install astro-obfuscateastro-obfuscate is a set of components that prevent spam bots from finding email addresses, phone numbers, or other text that you wish to hide. Both SSG and SSR modes are supported.
There are four components included in this library:
- ObfuscatedEmail: Obfuscates email addresses, creating a mailto link upon deobfuscation
- ObfuscatedPhone: Obfuscates phone numbers, creating a tel link upon deobfuscation
- ObfuscatedText: Obfuscates text, creating a span element upon deobfuscation
- ObfuscatedData: Base component, can be used to create custom obfuscated elements
``astro
---
import {
ObfuscatedEmail,
ObfuscatedPhone,
ObfuscatedText,
ObfuscatedData
} from 'astro-obfuscate/components';
---
`
All obfuscated components accept a class and noscriptClass attribute to allow styling. These classes are added to the obfuscated-data and noscript elements, respectively.
`astro
`
The script will wait 500ms returning the result of deobfuscation in a custom element (obfuscated-data). During this time, [please wait] will be displayed in its place. If JavaScript is disabled, or deobfuscation fails, an error message is shown in its place.
See the server.ts` file for the obfuscation implementation.
This method of obfuscation should work against most bots. More sophisticated bots may bypass any client-side obfuscation methods.