Skip to content

Commit

Permalink
docs: refactor social links configuration reference (withastro#869)
Browse files Browse the repository at this point in the history
* docs: refactor social links configuration reference

* docs: update supported link icons wording

Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>

* chore: add changes from withastro#881

* chore: fix eof newline

---------

Co-authored-by: Chris Swithinbank <swithinbank@gmail.com>
  • Loading branch information
HiDeoo and delucis committed Oct 15, 2023
1 parent b4f649c commit ce9a739
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 28 deletions.
7 changes: 7 additions & 0 deletions docs/src/components/social-links-type.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
import { socialLinks } from '../../../packages/starlight/schemas/social';
const socials = [...socialLinks].sort((a, b) => a.localeCompare(b, 'en'));
---

<code>{`Partial<Record<${socials.map((social) => `'${social}'`).join(' | ')}, string>>`}</code>
2 changes: 1 addition & 1 deletion docs/src/content/docs/guides/customization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ defineConfig({

Starlight has built-in support for adding links to your social media accounts to the site header via the [`social`](/reference/configuration/#social) option in the Starlight integration.

Currently, links to Bitbucket, Codeberg, CodePen, Discord, Email, Facebook, GitHub, GitLab, Gitter, Instagram, LinkedIn, Mastodon, Microsoft Teams, Patreon, Reddit, an RSS feed, Stack Overflow, Telegram, Threads, Twitch, Twitter, X, and Youtube are supported.
You can find a full list of supported link icons in the [Configuration Reference](/reference/configuration/#social).
Let us know on GitHub or Discord if you need support for another service!

```js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ interface BadgeConfig {

### `locales`

**type:** <code>{ \[dir: string\]: [LocaleConfig](#localeconfig) }</code>
**type:** <code>\{ \[dir: string\]: [LocaleConfig](#localeconfig) \}</code>

[Configure internationalization (i18n)](/guides/i18n/) for your site by setting which `locales` are supported.

Expand Down Expand Up @@ -308,7 +308,9 @@ The default locale will be used to provide fallback content where translations a

### `social`

**type:** `Partial<Record<'bitbucket' | 'codeberg' | 'codePen' | 'discord' | 'email' | 'facebook' | 'github' | 'gitlab' | 'gitter' | 'instagram' | 'linkedin' | 'mastodon' | 'microsoftTeams' | 'patreon' | 'reddit' | 'rss' | 'stackOverflow' | 'telegram' | 'threads' | 'twitch' | 'twitter' | 'x.com' | 'youtube', string>>`
import SocialLinksType from '../../../components/social-links-type.astro';

**type:** <SocialLinksType />

Optional details about the social media accounts for this site. Adding any of these will display them as icon links in the site header.

Expand Down
52 changes: 27 additions & 25 deletions packages/starlight/schemas/social.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import { z } from 'astro/zod';

export const socialLinks = [
'twitter',
'mastodon',
'github',
'gitlab',
'bitbucket',
'discord',
'gitter',
'codeberg',
'codePen',
'youtube',
'threads',
'linkedin',
'twitch',
'microsoftTeams',
'instagram',
'stackOverflow',
'x.com',
'telegram',
'rss',
'facebook',
'email',
'reddit',
'patreon',
] as const;

export const SocialLinksSchema = () =>
z
.record(
z.enum([
'twitter',
'mastodon',
'github',
'gitlab',
'bitbucket',
'discord',
'gitter',
'codeberg',
'codePen',
'youtube',
'threads',
'linkedin',
'twitch',
'microsoftTeams',
'instagram',
'stackOverflow',
'x.com',
'telegram',
'rss',
'facebook',
'email',
'reddit',
'patreon',
]),
z.enum(socialLinks),
// Link to the respective social profile for this site
z.string().url()
)
Expand Down

0 comments on commit ce9a739

Please sign in to comment.