@astrojs/starlight 0.41.4 → 0.41.6
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 +12 -0
- package/components-internals/Icons.ts +2 -0
- package/package.json +1 -1
- package/schema.ts +2 -1
- package/utils/zodDeepMerge.ts +33 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.41.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#4102](https://github.com/withastro/starlight/pull/4102) [`f1dddc0`](https://github.com/withastro/starlight/commit/f1dddc057dc2b52092058f39679a5790b9cf0a38) Thanks [@delucis](https://github.com/delucis)! - Adds 1 new icon: `forgejo`
|
|
8
|
+
|
|
9
|
+
## 0.41.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#4095](https://github.com/withastro/starlight/pull/4095) [`bb06434`](https://github.com/withastro/starlight/commit/bb06434a1bc199b59f9d7953d0e41c6c287b1aa2) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes a regression when using a union to [extend](https://starlight.astro.build/reference/frontmatter/#extend) Starlight’s `docsSchema()`.
|
|
14
|
+
|
|
3
15
|
## 0.41.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -105,6 +105,8 @@ export const BuiltInIcons = {
|
|
|
105
105
|
'<path d="m22.63 9.8-.03-.09-3-7.81a.78.78 0 0 0-.76-.5.8.8 0 0 0-.46.18.8.8 0 0 0-.26.4L16.1 8.17H7.9l-2-6.19a.79.79 0 0 0-1.5-.08l-3 7.81-.02.08a5.56 5.56 0 0 0 1.84 6.43h.01l.03.02 4.56 3.42 2.26 1.7 1.37 1.05a.92.92 0 0 0 1.12 0l1.38-1.04 2.25-1.71 4.6-3.44a5.56 5.56 0 0 0 1.84-6.43Z"/>',
|
|
106
106
|
bitbucket:
|
|
107
107
|
'<path d="M1 1.5a.8.8 0 0 0-.7.9l3.2 19.3c0 .5.5.8 1 .8h15.2c.4 0 .7-.2.8-.6l3.2-19.5a.7.7 0 0 0-.8-.9H1zm13.4 14H9.6l-1.3-7h7.3l-1.2 7z"/>',
|
|
108
|
+
forgejo:
|
|
109
|
+
'<path d="M16.8 0a2.9 2.9 0 1 1-2.6 4.3H13a4.3 4.3 0 0 0-4.3 4.2v2.1a7 7 0 0 1 4.2-1.4h1.4a2.9 2.9 0 0 1 5.5 1.4 2.9 2.9 0 0 1-5.5 1.5H13a4.3 4.3 0 0 0-4.3 4.2v2.3A2.9 2.9 0 0 1 7.2 24a2.9 2.9 0 0 1-1.4-5.4v-10a7 7 0 0 1 7-7.1h1.4A3 3 0 0 1 16.8 0M7.2 20a1.2 1.2 0 1 0 0 2.3 1.2 1.2 0 0 0 0-2.4m9.6-10.5a1.2 1.2 0 1 0 0 2.4 1.2 1.2 0 0 0 0-2.4m0-7.7a1.2 1.2 0 1 0 0 2.4 1.2 1.2 0 0 0 0-2.4"/>',
|
|
108
110
|
codePen:
|
|
109
111
|
'<path d="M23.5 7.5 12.5.2a1 1 0 0 0-1 0L.4 7.5a1 1 0 0 0-.5.8v7.4c0 .3.2.6.5.8l11 7.3c.3.3.7.3 1 0l11-7.3c.3-.2.5-.5.5-.8V8.3a1 1 0 0 0-.5-.8zM13 3l8.1 5.3-3.6 2.5-4.5-3V3zm-2 0v4.8l-4.5 3-3.6-2.5 8-5.3zm-9 7.3L4.7 12l-2.5 1.7v-3.4zM11 21l-8.1-5.3 3.6-2.5 4.5 3V21zm1-6.6L8.4 12 12 9.6l3.6 2.4-3.6 2.4zm1 6.6v-4.8l4.5-3 3.6 2.5-8 5.3zm9-7.3L19.3 12l2.5-1.7v3.4z"/>',
|
|
110
112
|
farcaster:
|
package/package.json
CHANGED
package/schema.ts
CHANGED
|
@@ -115,7 +115,8 @@ const StarlightFrontmatterSchema = (context: SchemaContext) =>
|
|
|
115
115
|
type DefaultSchema = ReturnType<typeof StarlightFrontmatterSchema>;
|
|
116
116
|
|
|
117
117
|
/** Base subset of Zod types that we support passing to the `extend` option. */
|
|
118
|
-
type
|
|
118
|
+
type BaseObjectSchema = z.ZodObject<z.ZodRawShape, z.core.$ZodObjectConfig>;
|
|
119
|
+
type BaseSchema = BaseObjectSchema | z.ZodUnion<readonly BaseObjectSchema[]>;
|
|
119
120
|
|
|
120
121
|
/** Type that extends Starlight’s default schema with an optional, user-defined schema. */
|
|
121
122
|
type ExtendedSchema<T extends BaseSchema = never> = [T] extends [never]
|
package/utils/zodDeepMerge.ts
CHANGED
|
@@ -10,17 +10,19 @@ export type DeepMergedSchema<Default extends z.core.$ZodType, User extends z.cor
|
|
|
10
10
|
? z.ZodDefault<DeepMergedSchema<UnwrappedSchema<Default>, WrappedSchema>>
|
|
11
11
|
: User extends z.ZodPrefault<infer WrappedSchema extends z.core.$ZodType>
|
|
12
12
|
? z.ZodPrefault<DeepMergedSchema<UnwrappedSchema<Default>, WrappedSchema>>
|
|
13
|
-
:
|
|
14
|
-
?
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
infer DefaultItemSchema extends z.core.$ZodType
|
|
19
|
-
>
|
|
20
|
-
? User extends z.ZodArray<infer UserItemSchema extends z.core.$ZodType>
|
|
21
|
-
? z.ZodArray<DeepMergedSchema<DefaultItemSchema, UserItemSchema>>
|
|
13
|
+
: User extends z.ZodUnion<infer Users extends readonly z.core.$ZodType[]>
|
|
14
|
+
? z.ZodUnion<DeepMergedUnionMembers<UnwrappedSchema<Default>, Users>>
|
|
15
|
+
: UnwrappedSchema<Default> extends z.ZodObject<infer DefaultShape>
|
|
16
|
+
? User extends z.ZodObject<infer UserShape, infer UserConfig>
|
|
17
|
+
? z.ZodObject<DeepMergedShape<DefaultShape, UserShape>, UserConfig>
|
|
22
18
|
: User
|
|
23
|
-
:
|
|
19
|
+
: UnwrappedSchema<Default> extends z.ZodArray<
|
|
20
|
+
infer DefaultItemSchema extends z.core.$ZodType
|
|
21
|
+
>
|
|
22
|
+
? User extends z.ZodArray<infer UserItemSchema extends z.core.$ZodType>
|
|
23
|
+
? z.ZodArray<DeepMergedSchema<DefaultItemSchema, UserItemSchema>>
|
|
24
|
+
: User
|
|
25
|
+
: User;
|
|
24
26
|
|
|
25
27
|
/** Type-level equivalent of {@link unwrapSchema}. */
|
|
26
28
|
type UnwrappedSchema<T extends z.core.$ZodType> =
|
|
@@ -48,6 +50,16 @@ type DeepMergedShape<Default extends z.ZodRawShape, User extends z.ZodRawShape>
|
|
|
48
50
|
: never;
|
|
49
51
|
};
|
|
50
52
|
|
|
53
|
+
/** Merged union schemas where each union member is deep-merged with the default schema. */
|
|
54
|
+
type DeepMergedUnionMembers<
|
|
55
|
+
Default extends z.core.$ZodType,
|
|
56
|
+
Users extends readonly z.core.$ZodType[],
|
|
57
|
+
> = {
|
|
58
|
+
[Key in keyof Users]: Users[Key] extends z.core.$ZodType
|
|
59
|
+
? DeepMergedSchema<Default, Users[Key]>
|
|
60
|
+
: Users[Key];
|
|
61
|
+
};
|
|
62
|
+
|
|
51
63
|
export function deepMergeSchemas(defaultSchema: z.ZodType, userSchema: z.ZodType): z.ZodType {
|
|
52
64
|
const unwrappedDefaultSchema = unwrapSchema(defaultSchema);
|
|
53
65
|
|
|
@@ -58,6 +70,13 @@ export function deepMergeSchemas(defaultSchema: z.ZodType, userSchema: z.ZodType
|
|
|
58
70
|
} as Parameters<typeof userSchema.clone>[0]);
|
|
59
71
|
}
|
|
60
72
|
|
|
73
|
+
if (isZodUnion(userSchema)) {
|
|
74
|
+
return userSchema.clone({
|
|
75
|
+
...userSchema._zod.def,
|
|
76
|
+
options: userSchema.options.map((schema) => deepMergeSchemas(unwrappedDefaultSchema, schema)),
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
61
80
|
if (isZodObject(unwrappedDefaultSchema) && isZodObject(userSchema)) {
|
|
62
81
|
const shape: z.core.$ZodLooseShape = { ...unwrappedDefaultSchema.shape };
|
|
63
82
|
|
|
@@ -119,3 +138,7 @@ function isZodObject(schema: z.ZodType): schema is z.ZodObject<z.ZodRawShape> {
|
|
|
119
138
|
function isZodArray(schema: z.ZodType): schema is z.ZodArray<z.ZodType> {
|
|
120
139
|
return schema._zod.def.type === 'array';
|
|
121
140
|
}
|
|
141
|
+
|
|
142
|
+
function isZodUnion(schema: z.ZodType): schema is z.ZodUnion<readonly z.ZodType[]> {
|
|
143
|
+
return schema._zod.def.type === 'union';
|
|
144
|
+
}
|