Skip to content

Commit ffe2b70

Browse files
jdebarochezTahul
andauthored
feat: support rel attribute for social links (#129)
Co-authored-by: Yaël Guilloux <yael.guilloux@gmail.com>
1 parent 6584e87 commit ffe2b70

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

.starters/default/content/articles/2.configure.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ export default defineAppConfig({
6060
icon: 'uil:linkedin',
6161
label: 'LinkedIn',
6262
href: 'https://www.linkedin.com/company/nuxtlabs'
63+
},
64+
mastodon: {
65+
icon: 'simple-icons:mastodon',
66+
label: 'Mastodon',
67+
href: 'https://m.webtoo.ls/@nuxt',
68+
rel: 'me'
6369
}
6470
}
6571
}

components/SocialIcons.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,22 @@ const icons = computed<any>(() => {
2525
})
2626
.filter(Boolean)
2727
})
28+
29+
const getRel = (icon:any) => {
30+
const base = ['noopener', 'noreferrer']
31+
if (icon.rel) {
32+
base.push(icon.rel)
33+
}
34+
return base.join(' ')
35+
}
2836
</script>
2937

3038
<template>
3139
<!-- eslint-disable-next-line vue/no-multiple-template-root -->
3240
<NuxtLink
3341
v-for="icon in icons"
3442
:key="icon.label"
35-
rel="noopener noreferrer"
43+
:rel="getRel(icon)"
3644
:title="icon.label"
3745
:aria-label="icon.label"
3846
:href="icon.href"

0 commit comments

Comments
 (0)