Skip to content

Commit b6a250a

Browse files
committed
Fix merging of default socials
1 parent a79deb1 commit b6a250a

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

packages/starlight-theme-mtasa/index.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
import type { StarlightPlugin } from '@astrojs/starlight/types';
1+
import type { StarlightPlugin, StarlightUserConfig } from '@astrojs/starlight/types';
22

33
const packageName = '@multitheftauto/starlight-theme-mtasa';
44

5+
type SocialLinksSchema = NonNullable<StarlightUserConfig['social']>;
6+
7+
function mergeWithSocialDefaults(social: SocialLinksSchema, defaults: SocialLinksSchema): SocialLinksSchema {
8+
const filtered = defaults.filter(d => !social.some(s => s.label === d.label));
9+
return [...social, ...filtered];
10+
}
11+
512
export default function mtasaStarlightThemePlugin(): StarlightPlugin {
613
return {
714
name: 'starlight-theme-mtasa',
@@ -18,14 +25,13 @@ export default function mtasaStarlightThemePlugin(): StarlightPlugin {
1825
Header: `${packageName}/Header.astro`,
1926
...config.components ?? {},
2027
},
21-
social: [
28+
social: mergeWithSocialDefaults(config.social ?? [], [
2229
{ icon: 'github', label: 'GitHub', href: 'https://github.com/multitheftauto/' },
2330
{ icon: 'discord', label: 'Discord', href: 'https://discord.com/invite/mtasa' },
2431
{ icon: 'youtube', label: 'YouTube', href: 'https://youtube.com/user/mtaqa' },
2532
{ icon: 'twitch', label: 'Twitch', href: 'https://twitch.tv/mtaqa' },
2633
{ icon: 'x.com', label: 'X (Twitter)', href: 'https://x.com/mtaqa' },
27-
...config.social ?? [],
28-
],
34+
]),
2935
})
3036
}
3137
},

packages/starlight-theme-mtasa/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@multitheftauto/starlight-theme-mtasa",
3-
"version": "1.4.0",
3+
"version": "1.4.1",
44
"description": "Starlight theme for Multi Theft Auto",
55
"type": "module",
66
"repository": {

0 commit comments

Comments
 (0)