From ea999c4afa0e72da5a5510d30a7bc13380e10a4a Mon Sep 17 00:00:00 2001
From: Chris Swithinbank
Date: Tue, 9 May 2023 23:01:41 +0200
Subject: Show social icon links in header (#35)
---
.changeset/large-planets-think.md | 5 +++
docs/astro.config.mjs | 4 +++
docs/src/content/docs/reference/configuration.md | 8 +++--
packages/starlight/components/Header.astro | 3 ++
packages/starlight/components/Icons.ts | 8 ++++-
packages/starlight/components/SocialIcons.astro | 44 ++++++++++++++++++++++++
packages/starlight/utils/user-config.ts | 14 +++++---
7 files changed, 78 insertions(+), 8 deletions(-)
create mode 100644 .changeset/large-planets-think.md
create mode 100644 packages/starlight/components/SocialIcons.astro
diff --git a/.changeset/large-planets-think.md b/.changeset/large-planets-think.md
new file mode 100644
index 00000000..cb66db5d
--- /dev/null
+++ b/.changeset/large-planets-think.md
@@ -0,0 +1,5 @@
+---
+'@astrojs/starlight': patch
+---
+
+Add support for social media links in the site header.
diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs
index d7ff460a..41223fe0 100644
--- a/docs/astro.config.mjs
+++ b/docs/astro.config.mjs
@@ -9,6 +9,10 @@ export default defineConfig({
editLink: {
baseUrl: 'https://github.com/withastro/starlight/edit/main/docs/',
},
+ social: {
+ github: 'https://github.com/withastro/starlight',
+ discord: 'https://astro.build/chat',
+ },
locales: {
root: {
label: 'English',
diff --git a/docs/src/content/docs/reference/configuration.md b/docs/src/content/docs/reference/configuration.md
index 22f84107..d58b6f11 100644
--- a/docs/src/content/docs/reference/configuration.md
+++ b/docs/src/content/docs/reference/configuration.md
@@ -191,13 +191,15 @@ The default locale will be used to provide fallback content where translations a
### `social`
-Optional details about the social media accounts for this site.
+Optional details about the social media accounts for this site. Adding any of these will display them as icon links in the site header.
```js
starlight({
social: {
- // Main Twitter handle for this site
- twitter: 'astrodotbuild',
+ discord: 'https://astro.build/chat',
+ github: 'https://github.com/withastro/starlight',
+ mastodon: 'https://m.webtoo.ls/@astro',
+ twitter: 'https://twitter.com/astrodotbuild',
},
});
```
diff --git a/packages/starlight/components/Header.astro b/packages/starlight/components/Header.astro
index f35e9e79..7547c30e 100644
--- a/packages/starlight/components/Header.astro
+++ b/packages/starlight/components/Header.astro
@@ -3,6 +3,7 @@ import config from 'virtual:starlight/user-config';
import LanguageSelect from './LanguageSelect.astro';
import Search from './Search.astro';
import ThemeSelect from './ThemeSelect.astro';
+import SocialIcons from './SocialIcons.astro';
interface Props {
locale: string | undefined;
@@ -13,6 +14,7 @@ interface Props {
{config.title}