Repository navigation
Social links: Add option to set target (e.g. _blank) and title attribute (tooltip on hover) #3715
coliff
started this conversation in
Feature Requests
Replies: 2 comments
|
Until this gets native support, you can work around it today by overriding the Create a custom component at ---
import Default from "@astrojs/starlight/components/SocialIcons.astro";
---
<Default {...Astro.props}><slot /></Default>
<script>
// Add title attributes and target=_blank to social links
document.querySelectorAll(".social-icons a").forEach((link) => {
const label = link.getAttribute("aria-label");
if (label) {
link.setAttribute("title", label);
}
link.setAttribute("target", "_blank");
link.setAttribute("rel", "noopener noreferrer");
});
</script>Then register the override in your starlight({
// ...your config
components: {
SocialIcons: "./src/components/SocialIcons.astro",
},
})This leverages the fact that Starlight already sets The |
0 replies
|
Hi! As @manimovassagh noted this can be done via overrides. Here are two previous duplicates for this conversation:
These also explain why we don’t open links in a new tab. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
What version of
starlightare you using?0.37.6
What is your idea?
Social links in navbar may have icons which a user doesn't recognize, would be good if they showed the name on hover as a tooltip. Having option to open links in a new tab would be good too.
Why is this feature necessary?
mentioned above
Do you have examples of this feature in other projects?
No response
Participation
All reactions