Added security and target

This commit is contained in:
Patrick Alvin Alcala 2025-09-18 12:54:10 +08:00
parent 64458773d2
commit 92eeebaf87
2 changed files with 5 additions and 3 deletions

View file

@ -8,6 +8,7 @@ interface Props {
edges?: 'curved' | 'rounded' | 'flat' edges?: 'curved' | 'rounded' | 'flat'
design?: 'bu-primary' | 'bu-link' | 'bu-info' | 'bu-success' | 'bu-warning' | 'bu-danger' | 'bu-dark' | 'bu-light' | 'bu-text' | 'bu-ghost' | 'bo-primary' | 'bo-secondary' | 'bo-success' | 'bo-danger' | 'bo-warning' | 'bo-info' | 'bo-light' | 'bo-dark' | 'bo-link' design?: 'bu-primary' | 'bu-link' | 'bu-info' | 'bu-success' | 'bu-warning' | 'bu-danger' | 'bu-dark' | 'bu-light' | 'bu-text' | 'bu-ghost' | 'bo-primary' | 'bo-secondary' | 'bo-success' | 'bo-danger' | 'bo-warning' | 'bo-info' | 'bo-light' | 'bo-dark' | 'bo-link'
submit?: boolean submit?: boolean
newtab?: boolean
} }
const getBorderRadius = (edge: Props['edges']) => { const getBorderRadius = (edge: Props['edges']) => {
@ -31,14 +32,14 @@ export default (props: Props) => {
<Show when={props.to}> <Show when={props.to}>
<Switch> <Switch>
<Match when={props.design}> <Match when={props.design}>
<a href={props.to} aria-label={props.label} data-astro-prefetch> <a href={props.to} aria-label={props.label} rel="noopener" target={props.newtab ? '_blank' : '_self'} data-astro-prefetch>
<button class={props.design} style={borderRadius}> <button class={props.design} style={borderRadius}>
{props.label || 'Click Me!'} {props.label || 'Click Me!'}
</button> </button>
</a> </a>
</Match> </Match>
<Match when={!props.design}> <Match when={!props.design}>
<a href={props.to} aria-label={props.label} data-astro-prefetch> <a href={props.to} aria-label={props.label} rel="noopener" target={props.newtab ? '_blank' : '_self'} data-astro-prefetch>
<button class="button" style={borderRadius}> <button class="button" style={borderRadius}>
{props.label || 'Click Me!'} {props.label || 'Click Me!'}
</button> </button>

View file

@ -3,12 +3,13 @@ import '../styles/Link.sass'
interface Props { interface Props {
to: string to: string
children?: any children?: any
newtab?: boolean
} }
export default (props: Props) => { export default (props: Props) => {
return ( return (
<> <>
<a href={props.to} aria-label={`Go to ${props.to}`} data-astro-prefetch> <a href={props.to} aria-label={`Go to ${props.to}`} rel="noopener" target={props.newtab ? '_blank' : '_self'} data-astro-prefetch>
{props.children} {props.children}
</a> </a>
</> </>