From 2b3302b80451f318fb05a5e8a7284feb28999e66 Mon Sep 17 00:00:00 2001 From: Chris Swithinbank Date: Fri, 14 Jul 2023 19:15:07 +0200 Subject: Add social link support for LinkedIn, Threads, and Twitch (#336) --- .changeset/cool-beds-invent.md | 5 +++++ docs/src/content/docs/guides/customization.mdx | 6 +----- docs/src/content/docs/reference/configuration.md | 5 ++++- packages/starlight/components/Icons.ts | 6 ++++++ packages/starlight/components/SocialIcons.astro | 5 ++++- packages/starlight/utils/user-config.ts | 18 ++++++++++++------ 6 files changed, 32 insertions(+), 13 deletions(-) create mode 100644 .changeset/cool-beds-invent.md diff --git a/.changeset/cool-beds-invent.md b/.changeset/cool-beds-invent.md new file mode 100644 index 00000000..05416c87 --- /dev/null +++ b/.changeset/cool-beds-invent.md @@ -0,0 +1,5 @@ +--- +"@astrojs/starlight": patch +--- + +Add support for LinkedIn, Threads, and Twitch social icon links diff --git a/docs/src/content/docs/guides/customization.mdx b/docs/src/content/docs/guides/customization.mdx index c711c30c..be11567e 100644 --- a/docs/src/content/docs/guides/customization.mdx +++ b/docs/src/content/docs/guides/customization.mdx @@ -178,7 +178,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 Codeberg, Discord, GitHub, Mastodon, Twitter, and Youtube are supported. +Currently, links to Codeberg, Discord, GitHub, LinkedIn, Mastodon, Threads, Twitch, Twitter, and Youtube are supported. Let us know on GitHub or Discord if you need support for another service! ```js @@ -191,12 +191,8 @@ export default defineConfig({ starlight({ title: 'Docs With Social Links', social: { - codeberg: 'https://codeberg.org/knut/examples', discord: 'https://astro.build/chat', github: 'https://github.com/withastro/starlight', - mastodon: 'https://m.webtoo.ls/@astro', - twitter: 'https://twitter.com/astrodotbuild', - youtube: 'https://youtube.com/@astrodotbuild', }, }), ], diff --git a/docs/src/content/docs/reference/configuration.md b/docs/src/content/docs/reference/configuration.md index 275d9eb8..5f94e9c2 100644 --- a/docs/src/content/docs/reference/configuration.md +++ b/docs/src/content/docs/reference/configuration.md @@ -295,7 +295,7 @@ The default locale will be used to provide fallback content where translations a ### `social` -**type:** `{ codeberg?: string; discord?: string; github?: string; mastodon?: string; twitter?: string; youtube?: string }` +**type:** `Partial>` Optional details about the social media accounts for this site. Adding any of these will display them as icon links in the site header. @@ -305,7 +305,10 @@ starlight({ codeberg: 'https://codeberg.org/knut/examples', discord: 'https://astro.build/chat', github: 'https://github.com/withastro/starlight', + linkedin: 'https://www.linkedin.com/company/astroinc', mastodon: 'https://m.webtoo.ls/@astro', + threads: 'https://www.threads.net/@nmoodev', + twitch: 'https://www.twitch.tv/bholmesdev', twitter: 'https://twitter.com/astrodotbuild', youtube: 'https://youtube.com/@astrodotbuild', }, diff --git a/packages/starlight/components/Icons.ts b/packages/starlight/components/Icons.ts index abb1aec4..dfe941ba 100644 --- a/packages/starlight/components/Icons.ts +++ b/packages/starlight/components/Icons.ts @@ -64,4 +64,10 @@ export const Icons = { '', youtube: '', + threads: + '', + linkedin: + '', + twitch: + '', }; diff --git a/packages/starlight/components/SocialIcons.astro b/packages/starlight/components/SocialIcons.astro index 0e40922e..2dacbc84 100644 --- a/packages/starlight/components/SocialIcons.astro +++ b/packages/starlight/components/SocialIcons.astro @@ -10,7 +10,10 @@ const labels: Record = { twitter: 'Twitter', mastodon: 'Mastodon', codeberg: 'Codeberg', - youtube: 'YouTube', + youtube: 'YouTube', + threads: 'Threads', + linkedin: 'LinkedIn', + twitch: 'Twitch', }; const links = Object.entries(config.social || {}).filter(([, url]) => diff --git a/packages/starlight/utils/user-config.ts b/packages/starlight/utils/user-config.ts index d29c8788..d87d6dd0 100644 --- a/packages/starlight/utils/user-config.ts +++ b/packages/starlight/utils/user-config.ts @@ -53,14 +53,14 @@ const AutoSidebarGroupSchema = SidebarGroupSchema.extend({ directory: z.string(), /** * Whether the autogenerated subgroups should be collapsed by default. - * Defaults to the `AutoSidebarGroup` `collapsed` value. + * Defaults to the `AutoSidebarGroup` `collapsed` value. */ collapsed: z.boolean().optional(), // TODO: not supported by Docusaurus but would be good to have /** How many directories deep to include from this directory in the sidebar. Default: `Infinity`. */ // depth: z.number().optional(), - }) -}) + }), +}); export type AutoSidebarGroup = z.infer; type ManualSidebarGroupInput = z.input & { @@ -96,7 +96,7 @@ const ManualSidebarGroupSchema: z.ZodType< ]) .array() ), -}) +}); const SidebarItemSchema = z.union([ SidebarLinkItemSchema, @@ -139,6 +139,12 @@ const UserConfigSchema = z.object({ codeberg: z.string().url().optional(), /** Link to the Youtube channel for this site, e.g. `'https://www.youtube.com/@astrodotbuild'`. */ youtube: z.string().url().optional(), + /** Link to the Threads profile for this site, e.g. `'https://www.threads.net/@nmoodev'`. */ + threads: z.string().url().optional(), + /** Link to the LinkedIn page for this site, e.g. `'https://www.linkedin.com/company/astroinc'`. */ + linkedin: z.string().url().optional(), + /** Link to the Twitch profile or repository for this site, e.g. `'https://www.twitch.tv/bholmesdev'`. */ + twitch: z.string().url().optional(), }) .optional(), @@ -252,8 +258,8 @@ const UserConfigSchema = z.object({ .default(false) .describe( 'Define if the last update date should be visible in the page footer.' - ), - + ), + /** Define if the previous and next page links should be visible in the page footer. */ pagination: z .boolean() -- cgit