@astrojs/starlight 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/components/Header.astro +3 -0
- package/components/Icons.ts +7 -1
- package/components/SocialIcons.astro +44 -0
- package/package.json +1 -1
- package/schema.ts +1 -1
- package/utils/user-config.ts +10 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.0.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#35](https://github.com/withastro/starlight/pull/35) [`ea999c4`](https://github.com/withastro/starlight/commit/ea999c4afa0e72da5a5510d30a7bc13380e10a4a) Thanks [@delucis](https://github.com/delucis)! - Add support for social media links in the site header.
|
|
8
|
+
|
|
9
|
+
- [#33](https://github.com/withastro/starlight/pull/33) [`833393a`](https://github.com/withastro/starlight/commit/833393a1cd8fc83a3b9c6055cfb8d160ab40a40c) Thanks [@MoustaphaDev](https://github.com/MoustaphaDev)! - Import zod from `astro/zod` to fix an issue related to importing the `astro:content` virtual module
|
|
10
|
+
|
|
3
11
|
## 0.0.1
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/components/Header.astro
CHANGED
|
@@ -3,6 +3,7 @@ import config from 'virtual:starlight/user-config';
|
|
|
3
3
|
import LanguageSelect from './LanguageSelect.astro';
|
|
4
4
|
import Search from './Search.astro';
|
|
5
5
|
import ThemeSelect from './ThemeSelect.astro';
|
|
6
|
+
import SocialIcons from './SocialIcons.astro';
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
8
9
|
locale: string | undefined;
|
|
@@ -13,6 +14,7 @@ interface Props {
|
|
|
13
14
|
<a href={import.meta.env.BASE_URL} class="site-title">{config.title}</a>
|
|
14
15
|
<Search />
|
|
15
16
|
<div class="hidden md:flex right-group">
|
|
17
|
+
<SocialIcons />
|
|
16
18
|
<ThemeSelect />
|
|
17
19
|
<LanguageSelect locale={Astro.props.locale} />
|
|
18
20
|
</div>
|
|
@@ -37,6 +39,7 @@ interface Props {
|
|
|
37
39
|
|
|
38
40
|
.right-group {
|
|
39
41
|
gap: 1rem;
|
|
42
|
+
align-items: center;
|
|
40
43
|
}
|
|
41
44
|
|
|
42
45
|
@media (min-width: 50rem) {
|
package/components/Icons.ts
CHANGED
|
@@ -39,5 +39,11 @@ export const Icons = {
|
|
|
39
39
|
'list-format':
|
|
40
40
|
'<path d="M3.71 16.29C3.6149 16.199 3.50276 16.1276 3.38 16.08C3.13654 15.98 2.86346 15.98 2.62 16.08C2.49725 16.1276 2.38511 16.199 2.29 16.29C2.19896 16.3851 2.1276 16.4972 2.08 16.62C2.00342 16.8021 1.9825 17.0028 2.01988 17.1968C2.05725 17.3908 2.15125 17.5694 2.29 17.71C2.3872 17.7983 2.49882 17.8694 2.62 17.92C2.7397 17.9729 2.86913 18.0002 3 18.0002C3.13087 18.0002 3.2603 17.9729 3.38 17.92C3.50119 17.8694 3.6128 17.7983 3.71 17.71C3.84876 17.5694 3.94276 17.3908 3.98013 17.1968C4.01751 17.0028 3.99658 16.8021 3.92 16.62C3.87241 16.4972 3.80104 16.3851 3.71 16.29ZM7 8H21C21.2652 8 21.5196 7.89464 21.7071 7.70711C21.8946 7.51957 22 7.26522 22 7C22 6.73478 21.8946 6.48043 21.7071 6.29289C21.5196 6.10536 21.2652 6 21 6H7C6.73479 6 6.48043 6.10536 6.2929 6.29289C6.10536 6.48043 6 6.73478 6 7C6 7.26522 6.10536 7.51957 6.2929 7.70711C6.48043 7.89464 6.73479 8 7 8ZM3.71 11.29C3.56938 11.1512 3.39081 11.0572 3.19682 11.0199C3.00283 10.9825 2.80211 11.0034 2.62 11.08C2.49882 11.1306 2.3872 11.2017 2.29 11.29C2.19896 11.3851 2.1276 11.4972 2.08 11.62C2.0271 11.7397 1.99977 11.8691 1.99977 12C1.99977 12.1309 2.0271 12.2603 2.08 12.38C2.13065 12.5012 2.20167 12.6128 2.29 12.71C2.3872 12.7983 2.49882 12.8694 2.62 12.92C2.7397 12.9729 2.86913 13.0002 3 13.0002C3.13087 13.0002 3.2603 12.9729 3.38 12.92C3.50119 12.8694 3.6128 12.7983 3.71 12.71C3.79833 12.6128 3.86936 12.5012 3.92 12.38C3.97291 12.2603 4.00024 12.1309 4.00024 12C4.00024 11.8691 3.97291 11.7397 3.92 11.62C3.87241 11.4972 3.80104 11.3851 3.71 11.29ZM21 11H7C6.73479 11 6.48043 11.1054 6.2929 11.2929C6.10536 11.4804 6 11.7348 6 12C6 12.2652 6.10536 12.5196 6.2929 12.7071C6.48043 12.8946 6.73479 13 7 13H21C21.2652 13 21.5196 12.8946 21.7071 12.7071C21.8946 12.5196 22 12.2652 22 12C22 11.7348 21.8946 11.4804 21.7071 11.2929C21.5196 11.1054 21.2652 11 21 11ZM3.71 6.29C3.6149 6.19896 3.50276 6.12759 3.38 6.08C3.19789 6.00342 2.99718 5.9825 2.80319 6.01987C2.6092 6.05725 2.43063 6.15124 2.29 6.29C2.20167 6.3872 2.13065 6.49882 2.08 6.62C2.0271 6.7397 1.99977 6.86913 1.99977 7C1.99977 7.13087 2.0271 7.2603 2.08 7.38C2.13065 7.50119 2.20167 7.6128 2.29 7.71C2.3872 7.79833 2.49882 7.86936 2.62 7.92C2.80211 7.99658 3.00283 8.0175 3.19682 7.98013C3.39081 7.94275 3.56938 7.84876 3.71 7.71C3.79833 7.6128 3.86936 7.50119 3.92 7.38C3.97291 7.2603 4.00024 7.13087 4.00024 7C4.00024 6.86913 3.97291 6.7397 3.92 6.62C3.86936 6.49882 3.79833 6.3872 3.71 6.29ZM21 16H7C6.73479 16 6.48043 16.1054 6.2929 16.2929C6.10536 16.4804 6 16.7348 6 17C6 17.2652 6.10536 17.5196 6.2929 17.7071C6.48043 17.8946 6.73479 18 7 18H21C21.2652 18 21.5196 17.8946 21.7071 17.7071C21.8946 17.5196 22 17.2652 22 17C22 16.7348 21.8946 16.4804 21.7071 16.2929C21.5196 16.1054 21.2652 16 21 16Z"></path>',
|
|
41
41
|
github:
|
|
42
|
-
'<path d="M12
|
|
42
|
+
'<path d="M12 .3a12 12 0 0 0-3.8 23.38c.6.12.83-.26.83-.57L9 21.07c-3.34.72-4.04-1.61-4.04-1.61-.55-1.39-1.34-1.76-1.34-1.76-1.08-.74.09-.73.09-.73 1.2.09 1.83 1.24 1.83 1.24 1.08 1.83 2.81 1.3 3.5 1 .1-.78.42-1.31.76-1.61-2.67-.3-5.47-1.33-5.47-5.93 0-1.31.47-2.38 1.24-3.22-.14-.3-.54-1.52.1-3.18 0 0 1-.32 3.3 1.23a11.5 11.5 0 0 1 6 0c2.28-1.55 3.29-1.23 3.29-1.23.64 1.66.24 2.88.12 3.18a4.65 4.65 0 0 1 1.23 3.22c0 4.61-2.8 5.63-5.48 5.92.42.36.81 1.1.81 2.22l-.01 3.29c0 .31.2.69.82.57A12 12 0 0 0 12 .3Z"/>',
|
|
43
|
+
discord:
|
|
44
|
+
'<path d="M20.32 4.37a19.8 19.8 0 0 0-4.93-1.51 13.78 13.78 0 0 0-.64 1.28 18.27 18.27 0 0 0-5.5 0 12.64 12.64 0 0 0-.64-1.28h-.05A19.74 19.74 0 0 0 3.64 4.4 20.26 20.26 0 0 0 .11 18.09l.02.02a19.9 19.9 0 0 0 6.04 3.03l.04-.02a14.24 14.24 0 0 0 1.23-2.03.08.08 0 0 0-.05-.07 13.1 13.1 0 0 1-1.9-.92.08.08 0 0 1 .02-.1 10.2 10.2 0 0 0 .41-.31h.04a14.2 14.2 0 0 0 12.1 0l.04.01a9.63 9.63 0 0 0 .4.32.08.08 0 0 1-.03.1 12.29 12.29 0 0 1-1.9.91.08.08 0 0 0-.02.1 15.97 15.97 0 0 0 1.27 2.01h.04a19.84 19.84 0 0 0 6.03-3.05v-.03a20.12 20.12 0 0 0-3.57-13.69ZM8.02 15.33c-1.18 0-2.16-1.08-2.16-2.42 0-1.33.96-2.42 2.16-2.42 1.21 0 2.18 1.1 2.16 2.42 0 1.34-.96 2.42-2.16 2.42Zm7.97 0c-1.18 0-2.15-1.08-2.15-2.42 0-1.33.95-2.42 2.15-2.42 1.22 0 2.18 1.1 2.16 2.42 0 1.34-.94 2.42-2.16 2.42Z"/>',
|
|
45
|
+
twitter:
|
|
46
|
+
'<path d="M24 4.4a10 10 0 0 1-2.83.78 5.05 5.05 0 0 0 2.17-2.79 9.7 9.7 0 0 1-3.13 1.23 4.89 4.89 0 0 0-5.94-1.03 5 5 0 0 0-2.17 2.38 5.15 5.15 0 0 0-.3 3.25c-1.95-.1-3.86-.63-5.61-1.53a14.04 14.04 0 0 1-4.52-3.74 5.2 5.2 0 0 0-.09 4.91c.39.74.94 1.35 1.61 1.82a4.77 4.77 0 0 1-2.23-.63v.06c0 1.16.4 2.29 1.12 3.18a4.9 4.9 0 0 0 2.84 1.74c-.73.22-1.5.26-2.24.12a4.89 4.89 0 0 0 4.59 3.49A9.78 9.78 0 0 1 0 19.73 13.65 13.65 0 0 0 7.55 22a13.63 13.63 0 0 0 9.96-4.16A14.26 14.26 0 0 0 21.6 7.65V7c.94-.72 1.75-1.6 2.4-2.6Z"/>',
|
|
47
|
+
mastodon:
|
|
48
|
+
'<path d="M16.45 17.77c2.77-.33 5.18-2.03 5.49-3.58.47-2.45.44-5.97.44-5.97 0-4.77-3.15-6.17-3.15-6.17-1.58-.72-4.3-1.03-7.13-1.05h-.07c-2.83.02-5.55.33-7.13 1.05 0 0-3.14 1.4-3.14 6.17v.91c-.01.88-.02 1.86 0 2.88.12 4.67.87 9.27 5.2 10.4 2 .53 3.72.64 5.1.57 2.51-.14 3.92-.9 3.92-.9l-.08-1.8s-1.8.56-3.8.5c-2-.08-4.1-.22-4.43-2.66a4.97 4.97 0 0 1-.04-.68s1.96.48 4.44.59c1.51.07 2.94-.09 4.38-.26Zm2.22-3.4h-2.3v-5.6c0-1.19-.5-1.79-1.5-1.79-1.1 0-1.66.71-1.66 2.12v3.07h-2.3V9.1c0-1.4-.55-2.12-1.65-2.12-1 0-1.5.6-1.5 1.78v5.61h-2.3V8.6c0-1.18.3-2.12.9-2.81a3.17 3.17 0 0 1 2.47-1.05c1.18 0 2.07.45 2.66 1.35l.57.96.58-.96a2.97 2.97 0 0 1 2.66-1.35c1.01 0 1.83.36 2.46 1.05.6.7.9 1.63.9 2.81v5.78Z"/>',
|
|
43
49
|
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
import config from 'virtual:starlight/user-config';
|
|
3
|
+
import Icon from './Icon.astro';
|
|
4
|
+
|
|
5
|
+
type Platform = keyof NonNullable<typeof config.social>;
|
|
6
|
+
|
|
7
|
+
const labels: Record<Platform, string> = {
|
|
8
|
+
github: 'GitHub',
|
|
9
|
+
discord: 'Discord',
|
|
10
|
+
twitter: 'Twitter',
|
|
11
|
+
mastodon: 'Mastodon',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const links = Object.entries(config.social || {}).filter(([, url]) =>
|
|
15
|
+
Boolean(url)
|
|
16
|
+
) as [platform: Platform, url: string][];
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
{
|
|
20
|
+
links.length > 0 && (
|
|
21
|
+
<>
|
|
22
|
+
{links.map(([platform, url]) => (
|
|
23
|
+
<a href={url} rel="me">
|
|
24
|
+
<span class="sr-only">{labels[platform]}</span>
|
|
25
|
+
<Icon name={platform} />
|
|
26
|
+
</a>
|
|
27
|
+
))}
|
|
28
|
+
<div class="divider" />
|
|
29
|
+
</>
|
|
30
|
+
)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
<style>
|
|
34
|
+
a {
|
|
35
|
+
color: var(--sl-color-text-accent);
|
|
36
|
+
}
|
|
37
|
+
a:hover {
|
|
38
|
+
opacity: 0.66;
|
|
39
|
+
}
|
|
40
|
+
.divider {
|
|
41
|
+
height: 2rem;
|
|
42
|
+
border-inline-end: 1px solid var(--sl-color-gray-5);
|
|
43
|
+
}
|
|
44
|
+
</style>
|
package/package.json
CHANGED
package/schema.ts
CHANGED
package/utils/user-config.ts
CHANGED
|
@@ -84,7 +84,7 @@ const SidebarGroupSchema: z.ZodType<
|
|
|
84
84
|
ManualSidebarGroup | z.infer<typeof AutoSidebarGroupSchema>
|
|
85
85
|
> = z.union([ManualSidebarGroupSchema, AutoSidebarGroupSchema]);
|
|
86
86
|
|
|
87
|
-
const
|
|
87
|
+
const UserConfigSchema = z.object({
|
|
88
88
|
/** Title for your website. Will be used in metadata and as browser tab title. */
|
|
89
89
|
title: z
|
|
90
90
|
.string()
|
|
@@ -103,8 +103,14 @@ const StarlightUserConfigSchema = z.object({
|
|
|
103
103
|
/** Optional details about the social media accounts for this site. */
|
|
104
104
|
social: z
|
|
105
105
|
.object({
|
|
106
|
-
/**
|
|
107
|
-
twitter: z.string().optional(),
|
|
106
|
+
/** Link to the main Twitter profile for this site, e.g. `'https://twitter.com/astrodotbuild'`. */
|
|
107
|
+
twitter: z.string().url().optional(),
|
|
108
|
+
/** Link to the main Mastodon profile for this site, e.g. `'https://m.webtoo.ls/@astro'`. */
|
|
109
|
+
mastodon: z.string().url().optional(),
|
|
110
|
+
/** Link to the main GitHub org or repo for this site, e.g. `'https://github.com/withastro/starlight'`. */
|
|
111
|
+
github: z.string().url().optional(),
|
|
112
|
+
/** Link to the Discord server for this site, e.g. `'https://astro.build/chat'`. */
|
|
113
|
+
discord: z.string().url().optional(),
|
|
108
114
|
})
|
|
109
115
|
.optional(),
|
|
110
116
|
|
|
@@ -202,7 +208,7 @@ const StarlightUserConfigSchema = z.object({
|
|
|
202
208
|
customCss: z.string().array().optional().default([]),
|
|
203
209
|
});
|
|
204
210
|
|
|
205
|
-
export const StarlightConfigSchema =
|
|
211
|
+
export const StarlightConfigSchema = UserConfigSchema.strict().transform(
|
|
206
212
|
({ locales, defaultLocale, ...config }, ctx) => {
|
|
207
213
|
if (locales !== undefined && Object.keys(locales).length > 1) {
|
|
208
214
|
// This is a multilingual site (more than one locale configured).
|