@igor.dvlpr/astro-escaped-component
v1.0.0
Published
ππ»ββοΈββ‘οΈ An Astro component that holds only HTML-encoded content. π
Downloads
6
Maintainers
Readme
π Table of contents
π΅πΌ Usage
Install it by executing:
npm i -D "@igor.dvlpr/astro-escaped-component"
π€ΉπΌ API
The API exposes a single Astro component Escaped
, see a usage example below.
After importing the component into a project, add it to an Astro
page markup as:
<Escaped is:raw>
{/* text/code to be escaped */}
</Escaped>
[!IMPORTANT] The attribute
is:raw
is crucial for the component to work, if not specified, Astro will parse all content as pure HTML, including<script>
and<style>
tags.
[!CAUTION] This component escapes/encodes text using HTML entities and can help prevent XSS attacks. However, this may not be sufficient in all cases.
Ensure additional security measures are in place.
β¨ Examples
example.astro
---
import Escaped from '@igor.dvlpr/astro-escaped-component'
---
<Escaped is:raw>
Mitochondria are known as the "powerhouses" of the cell because they generate most of the cell's supply of ATP & CO<sub>2</sub>, which is used as a source of chemical energy.
<, >, ", ', &, =, `, !, @, $, %, (, ), +, {, }, [, ].
<script>console.log('Hello? No? π')</script>
</Escaped>
{/*
Will be rendered as:
Mitochondria are known as the "powerhouses" of the cell because they generate most of the cell's supply of ATP & CO<sub>2</sub>, which is used as a source of chemical energy.
<, >, ", ', &, =, `, !, @, $, %, (, ), +, {, }, [, ].
<script>console.log('Hello? No? π')</script>
*/}
π Changelog
π The changelog is available here: CHANGELOG.md.
πͺͺ License
Licensed under the MIT license which is available here, MIT license.
𧬠Related
π¦ Provides frequently used types for your TypeScript projects. π¦
πͺ A Node.js module for reading the AppPaths registry key on Windows. Useful for retrieving applications that can be launched from the command prompt. π
@igor.dvlpr/scrollend-polyfill
π΄ A performant and light (< 1.5KB) JavaScript polyfill for the scrollend Event. βΈοΈ
@igor.dvlpr/astro-easynav-button
π§ Add an easy-to-use navigational button (jump to top/bottom) to your Astro site. πΌ
π Provides ways of checking whether a path is a legacy Windows device. πΎ
π¨π»βπ» Author
Created by Igor DimitrijeviΔ (@igorskyflyer).