-
-
Notifications
You must be signed in to change notification settings - Fork 445
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show social icon links in header (#35)
- Loading branch information
Showing
7 changed files
with
78 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@astrojs/starlight': patch | ||
--- | ||
|
||
Add support for social media links in the site header. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--- | ||
import config from 'virtual:starlight/user-config'; | ||
import Icon from './Icon.astro'; | ||
type Platform = keyof NonNullable<typeof config.social>; | ||
const labels: Record<Platform, string> = { | ||
github: 'GitHub', | ||
discord: 'Discord', | ||
twitter: 'Twitter', | ||
mastodon: 'Mastodon', | ||
}; | ||
const links = Object.entries(config.social || {}).filter(([, url]) => | ||
Boolean(url) | ||
) as [platform: Platform, url: string][]; | ||
--- | ||
|
||
{ | ||
links.length > 0 && ( | ||
<> | ||
{links.map(([platform, url]) => ( | ||
<a href={url} rel="me"> | ||
<span class="sr-only">{labels[platform]}</span> | ||
<Icon name={platform} /> | ||
</a> | ||
))} | ||
<div class="divider" /> | ||
</> | ||
) | ||
} | ||
|
||
<style> | ||
a { | ||
color: var(--sl-color-text-accent); | ||
} | ||
a:hover { | ||
opacity: 0.66; | ||
} | ||
.divider { | ||
height: 2rem; | ||
border-inline-end: 1px solid var(--sl-color-gray-5); | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters