feat: support rel attribute for social links (#129)

Co-authored-by: Yaël Guilloux <yael.guilloux@gmail.com>
This commit is contained in:
Jean De BarochezandYaël Guilloux authored and GitHub committed 2023-05-16 17:17:47 +02:00
1 parent 6584e87155
commit ffe2b706dc
2 files changed
+15 -1

No files matched your search

@@ -60,6 +60,12 @@ export default defineAppConfig({
icon: 'uil:linkedin',
label: 'LinkedIn',
href: 'https://www.linkedin.com/company/nuxtlabs'
},
mastodon: {
icon: 'simple-icons:mastodon',
label: 'Mastodon',
href: 'https://m.webtoo.ls/@nuxt',
rel: 'me'
}
}
}
+9 -1
View File
@@ -25,6 +25,14 @@ const icons = computed<any>(() => {
})
.filter(Boolean)
})
const getRel = (icon:any) => {
const base = ['noopener', 'noreferrer']
if (icon.rel) {
base.push(icon.rel)
}
return base.join(' ')
}
</script>
<template>
@@ -32,7 +40,7 @@ const icons = computed<any>(() => {
<NuxtLink
v-for="icon in icons"
:key="icon.label"
rel="noopener noreferrer"
:rel="getRel(icon)"
:title="icon.label"
:aria-label="icon.label"
:href="icon.href"