Skip to content

Commit ab39fd8

Browse files
authored
feat(home): add target and rel attribute to home actions (#3528)
1 parent 30c665b commit ab39fd8

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

Diff for: docs/reference/default-theme-home-page.md

+9
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ interface HeroAction {
6969

7070
// Destination link of the button.
7171
link: string
72+
73+
// Link target attribute.
74+
target?: string
75+
76+
// Link rel attribute.
77+
rel?: string
7278
}
7379
```
7480

@@ -144,6 +150,9 @@ interface Feature {
144150
//
145151
// e.g. `external`
146152
rel?: string
153+
154+
// Link target attribute for the `link` option.
155+
target?: string
147156
}
148157

149158
type FeatureIcon =

Diff for: src/client/theme-default/components/VPButton.vue

+4-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ interface Props {
99
theme?: 'brand' | 'alt' | 'sponsor'
1010
text: string
1111
href?: string
12+
target?: string;
13+
rel?: string;
1214
}
1315
const props = withDefaults(defineProps<Props>(), {
1416
size: 'medium',
@@ -30,8 +32,8 @@ const component = computed(() => {
3032
class="VPButton"
3133
:class="[size, theme]"
3234
:href="href ? normalizeLink(href) : undefined"
33-
:target="isExternal ? '_blank' : undefined"
34-
:rel="isExternal ? 'noreferrer' : undefined"
35+
:target="props.target ?? (isExternal ? '_blank' : undefined)"
36+
:rel="props.rel ?? (isExternal ? 'noreferrer' : undefined)"
3537
>
3638
{{ text }}
3739
</component>

Diff for: src/client/theme-default/components/VPHero.vue

+4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export interface HeroAction {
88
theme?: 'brand' | 'alt'
99
text: string
1010
link: string
11+
target?: string
12+
rel?: string
1113
}
1214
1315
defineProps<{
@@ -43,6 +45,8 @@ const heroImageSlotExists = inject('hero-image-slot-exists') as Ref<boolean>
4345
:theme="action.theme"
4446
:text="action.text"
4547
:href="action.link"
48+
:target="action.target"
49+
:rel="action.rel"
4650
/>
4751
</div>
4852
</div>

0 commit comments

Comments
 (0)