Estou usando Astro e TypeScript.
Como adiciono condicionalmente um atributo HTML rel="noreferrer"
a um elemento no Astro?
Então, quando targetBlank = false
não renderiza rel
atributos no dom?
Ou a única solução é mostrar condicionalmente outro elemento HTML?
---
type Props = {
to: string;
targetBlank?: boolean;
};
const { to, targetBlank = false } = Astro.props;
---
<a
href={to}
target={targetBlank === true ? '_blank' : '_self'}
rel={targetBlank === true ? 'noreferrer' : ''}
>
<slot />
</a>
usar
undefined
: