feat(home): add target and rel attribute to home actions (#3528)

pull/3542/head
Liana 2 years ago committed by GitHub
parent 30c665b29d
commit ab39fd8592
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -69,6 +69,12 @@ interface HeroAction {
// Destination link of the button. // Destination link of the button.
link: string link: string
// Link target attribute.
target?: string
// Link rel attribute.
rel?: string
} }
``` ```
@ -144,6 +150,9 @@ interface Feature {
// //
// e.g. `external` // e.g. `external`
rel?: string rel?: string
// Link target attribute for the `link` option.
target?: string
} }
type FeatureIcon = type FeatureIcon =

@ -9,6 +9,8 @@ interface Props {
theme?: 'brand' | 'alt' | 'sponsor' theme?: 'brand' | 'alt' | 'sponsor'
text: string text: string
href?: string href?: string
target?: string;
rel?: string;
} }
const props = withDefaults(defineProps<Props>(), { const props = withDefaults(defineProps<Props>(), {
size: 'medium', size: 'medium',
@ -30,8 +32,8 @@ const component = computed(() => {
class="VPButton" class="VPButton"
:class="[size, theme]" :class="[size, theme]"
:href="href ? normalizeLink(href) : undefined" :href="href ? normalizeLink(href) : undefined"
:target="isExternal ? '_blank' : undefined" :target="props.target ?? (isExternal ? '_blank' : undefined)"
:rel="isExternal ? 'noreferrer' : undefined" :rel="props.rel ?? (isExternal ? 'noreferrer' : undefined)"
> >
{{ text }} {{ text }}
</component> </component>

@ -8,6 +8,8 @@ export interface HeroAction {
theme?: 'brand' | 'alt' theme?: 'brand' | 'alt'
text: string text: string
link: string link: string
target?: string
rel?: string
} }
defineProps<{ defineProps<{
@ -43,6 +45,8 @@ const heroImageSlotExists = inject('hero-image-slot-exists') as Ref<boolean>
:theme="action.theme" :theme="action.theme"
:text="action.text" :text="action.text"
:href="action.link" :href="action.link"
:target="action.target"
:rel="action.rel"
/> />
</div> </div>
</div> </div>

Loading…
Cancel
Save