Skip to content

Commit

Permalink
feat: support rel attribute for social links (#129)
Browse files Browse the repository at this point in the history
Co-authored-by: Yaël Guilloux <yael.guilloux@gmail.com>
  • Loading branch information
jdebarochez and Tahul committed May 16, 2023
1 parent 6584e87 commit ffe2b70
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .starters/default/content/articles/2.configure.md
Expand Up @@ -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'
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion components/SocialIcons.vue
Expand Up @@ -25,14 +25,22 @@ 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>
<!-- eslint-disable-next-line vue/no-multiple-template-root -->
<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"
Expand Down

0 comments on commit ffe2b70

Please sign in to comment.