feat(theme): add custom label for social links (#2466)

Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
pull/2486/head
Agustin Banchio 2 years ago committed by GitHub
parent 7a2bde357d
commit c995b9f61d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -214,7 +214,9 @@ export default {
icon: {
svg: '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>Dribbble</title><path d="M12...6.38z"/></svg>'
},
link: '...'
link: '...',
// You can include a custom label for accessibility too (optional but recommended):
ariaLabel: 'cool link'
}
]
}
@ -225,6 +227,7 @@ export default {
interface SocialLink {
icon: SocialLinkIcon
link: string
ariaLabel?: string
}
type SocialLinkIcon =

@ -6,6 +6,7 @@ import { icons } from '../support/socialIcons'
const props = defineProps<{
icon: DefaultTheme.SocialLinkIcon
link: string
ariaLabel?: string
}>()
const svg = computed(() => {
@ -18,7 +19,7 @@ const svg = computed(() => {
<a
class="VPSocialLink"
:href="link"
:aria-label="typeof icon === 'string' ? icon : ''"
:aria-label="ariaLabel ?? (typeof icon === 'string' ? icon : '')"
target="_blank"
rel="noopener"
v-html="svg"

@ -10,10 +10,11 @@ defineProps<{
<template>
<div class="VPSocialLinks">
<VPSocialLink
v-for="{ link, icon } in links"
v-for="{ link, icon, ariaLabel } in links"
:key="link"
:icon="icon"
:link="link"
:ariaLabel="ariaLabel"
/>
</div>
</template>

@ -251,6 +251,7 @@ export namespace DefaultTheme {
export interface SocialLink {
icon: SocialLinkIcon
link: string
ariaLabel?: string
}
export type SocialLinkIcon =

Loading…
Cancel
Save