@monza-editor/astro 0.1.0
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/.astro/content-assets.mjs +1 -0
- package/.astro/content-modules.mjs +1 -0
- package/.astro/content.d.ts +199 -0
- package/.astro/types.d.ts +2 -0
- package/LICENSE +21 -0
- package/package.json +28 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default new Map();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default new Map();
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
declare module 'astro:content' {
|
|
2
|
+
export interface RenderResult {
|
|
3
|
+
Content: import('astro/runtime/server/index.js').AstroComponentFactory;
|
|
4
|
+
headings: import('astro').MarkdownHeading[];
|
|
5
|
+
remarkPluginFrontmatter: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
interface Render {
|
|
8
|
+
'.md': Promise<RenderResult>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface RenderedContent {
|
|
12
|
+
html: string;
|
|
13
|
+
metadata?: {
|
|
14
|
+
imagePaths: Array<string>;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
declare module 'astro:content' {
|
|
21
|
+
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
|
|
22
|
+
|
|
23
|
+
export type CollectionKey = keyof AnyEntryMap;
|
|
24
|
+
export type CollectionEntry<C extends CollectionKey> = Flatten<AnyEntryMap[C]>;
|
|
25
|
+
|
|
26
|
+
export type ContentCollectionKey = keyof ContentEntryMap;
|
|
27
|
+
export type DataCollectionKey = keyof DataEntryMap;
|
|
28
|
+
|
|
29
|
+
type AllValuesOf<T> = T extends any ? T[keyof T] : never;
|
|
30
|
+
type ValidContentEntrySlug<C extends keyof ContentEntryMap> = AllValuesOf<
|
|
31
|
+
ContentEntryMap[C]
|
|
32
|
+
>['slug'];
|
|
33
|
+
|
|
34
|
+
export type ReferenceDataEntry<
|
|
35
|
+
C extends CollectionKey,
|
|
36
|
+
E extends keyof DataEntryMap[C] = string,
|
|
37
|
+
> = {
|
|
38
|
+
collection: C;
|
|
39
|
+
id: E;
|
|
40
|
+
};
|
|
41
|
+
export type ReferenceContentEntry<
|
|
42
|
+
C extends keyof ContentEntryMap,
|
|
43
|
+
E extends ValidContentEntrySlug<C> | (string & {}) = string,
|
|
44
|
+
> = {
|
|
45
|
+
collection: C;
|
|
46
|
+
slug: E;
|
|
47
|
+
};
|
|
48
|
+
export type ReferenceLiveEntry<C extends keyof LiveContentConfig['collections']> = {
|
|
49
|
+
collection: C;
|
|
50
|
+
id: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/** @deprecated Use `getEntry` instead. */
|
|
54
|
+
export function getEntryBySlug<
|
|
55
|
+
C extends keyof ContentEntryMap,
|
|
56
|
+
E extends ValidContentEntrySlug<C> | (string & {}),
|
|
57
|
+
>(
|
|
58
|
+
collection: C,
|
|
59
|
+
// Note that this has to accept a regular string too, for SSR
|
|
60
|
+
entrySlug: E,
|
|
61
|
+
): E extends ValidContentEntrySlug<C>
|
|
62
|
+
? Promise<CollectionEntry<C>>
|
|
63
|
+
: Promise<CollectionEntry<C> | undefined>;
|
|
64
|
+
|
|
65
|
+
/** @deprecated Use `getEntry` instead. */
|
|
66
|
+
export function getDataEntryById<C extends keyof DataEntryMap, E extends keyof DataEntryMap[C]>(
|
|
67
|
+
collection: C,
|
|
68
|
+
entryId: E,
|
|
69
|
+
): Promise<CollectionEntry<C>>;
|
|
70
|
+
|
|
71
|
+
export function getCollection<C extends keyof AnyEntryMap, E extends CollectionEntry<C>>(
|
|
72
|
+
collection: C,
|
|
73
|
+
filter?: (entry: CollectionEntry<C>) => entry is E,
|
|
74
|
+
): Promise<E[]>;
|
|
75
|
+
export function getCollection<C extends keyof AnyEntryMap>(
|
|
76
|
+
collection: C,
|
|
77
|
+
filter?: (entry: CollectionEntry<C>) => unknown,
|
|
78
|
+
): Promise<CollectionEntry<C>[]>;
|
|
79
|
+
|
|
80
|
+
export function getLiveCollection<C extends keyof LiveContentConfig['collections']>(
|
|
81
|
+
collection: C,
|
|
82
|
+
filter?: LiveLoaderCollectionFilterType<C>,
|
|
83
|
+
): Promise<
|
|
84
|
+
import('astro').LiveDataCollectionResult<LiveLoaderDataType<C>, LiveLoaderErrorType<C>>
|
|
85
|
+
>;
|
|
86
|
+
|
|
87
|
+
export function getEntry<
|
|
88
|
+
C extends keyof ContentEntryMap,
|
|
89
|
+
E extends ValidContentEntrySlug<C> | (string & {}),
|
|
90
|
+
>(
|
|
91
|
+
entry: ReferenceContentEntry<C, E>,
|
|
92
|
+
): E extends ValidContentEntrySlug<C>
|
|
93
|
+
? Promise<CollectionEntry<C>>
|
|
94
|
+
: Promise<CollectionEntry<C> | undefined>;
|
|
95
|
+
export function getEntry<
|
|
96
|
+
C extends keyof DataEntryMap,
|
|
97
|
+
E extends keyof DataEntryMap[C] | (string & {}),
|
|
98
|
+
>(
|
|
99
|
+
entry: ReferenceDataEntry<C, E>,
|
|
100
|
+
): E extends keyof DataEntryMap[C]
|
|
101
|
+
? Promise<DataEntryMap[C][E]>
|
|
102
|
+
: Promise<CollectionEntry<C> | undefined>;
|
|
103
|
+
export function getEntry<
|
|
104
|
+
C extends keyof ContentEntryMap,
|
|
105
|
+
E extends ValidContentEntrySlug<C> | (string & {}),
|
|
106
|
+
>(
|
|
107
|
+
collection: C,
|
|
108
|
+
slug: E,
|
|
109
|
+
): E extends ValidContentEntrySlug<C>
|
|
110
|
+
? Promise<CollectionEntry<C>>
|
|
111
|
+
: Promise<CollectionEntry<C> | undefined>;
|
|
112
|
+
export function getEntry<
|
|
113
|
+
C extends keyof DataEntryMap,
|
|
114
|
+
E extends keyof DataEntryMap[C] | (string & {}),
|
|
115
|
+
>(
|
|
116
|
+
collection: C,
|
|
117
|
+
id: E,
|
|
118
|
+
): E extends keyof DataEntryMap[C]
|
|
119
|
+
? string extends keyof DataEntryMap[C]
|
|
120
|
+
? Promise<DataEntryMap[C][E]> | undefined
|
|
121
|
+
: Promise<DataEntryMap[C][E]>
|
|
122
|
+
: Promise<CollectionEntry<C> | undefined>;
|
|
123
|
+
export function getLiveEntry<C extends keyof LiveContentConfig['collections']>(
|
|
124
|
+
collection: C,
|
|
125
|
+
filter: string | LiveLoaderEntryFilterType<C>,
|
|
126
|
+
): Promise<import('astro').LiveDataEntryResult<LiveLoaderDataType<C>, LiveLoaderErrorType<C>>>;
|
|
127
|
+
|
|
128
|
+
/** Resolve an array of entry references from the same collection */
|
|
129
|
+
export function getEntries<C extends keyof ContentEntryMap>(
|
|
130
|
+
entries: ReferenceContentEntry<C, ValidContentEntrySlug<C>>[],
|
|
131
|
+
): Promise<CollectionEntry<C>[]>;
|
|
132
|
+
export function getEntries<C extends keyof DataEntryMap>(
|
|
133
|
+
entries: ReferenceDataEntry<C, keyof DataEntryMap[C]>[],
|
|
134
|
+
): Promise<CollectionEntry<C>[]>;
|
|
135
|
+
|
|
136
|
+
export function render<C extends keyof AnyEntryMap>(
|
|
137
|
+
entry: AnyEntryMap[C][string],
|
|
138
|
+
): Promise<RenderResult>;
|
|
139
|
+
|
|
140
|
+
export function reference<C extends keyof AnyEntryMap>(
|
|
141
|
+
collection: C,
|
|
142
|
+
): import('astro/zod').ZodEffects<
|
|
143
|
+
import('astro/zod').ZodString,
|
|
144
|
+
C extends keyof ContentEntryMap
|
|
145
|
+
? ReferenceContentEntry<C, ValidContentEntrySlug<C>>
|
|
146
|
+
: ReferenceDataEntry<C, keyof DataEntryMap[C]>
|
|
147
|
+
>;
|
|
148
|
+
// Allow generic `string` to avoid excessive type errors in the config
|
|
149
|
+
// if `dev` is not running to update as you edit.
|
|
150
|
+
// Invalid collection names will be caught at build time.
|
|
151
|
+
export function reference<C extends string>(
|
|
152
|
+
collection: C,
|
|
153
|
+
): import('astro/zod').ZodEffects<import('astro/zod').ZodString, never>;
|
|
154
|
+
|
|
155
|
+
type ReturnTypeOrOriginal<T> = T extends (...args: any[]) => infer R ? R : T;
|
|
156
|
+
type InferEntrySchema<C extends keyof AnyEntryMap> = import('astro/zod').infer<
|
|
157
|
+
ReturnTypeOrOriginal<Required<ContentConfig['collections'][C]>['schema']>
|
|
158
|
+
>;
|
|
159
|
+
|
|
160
|
+
type ContentEntryMap = {
|
|
161
|
+
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
type DataEntryMap = {
|
|
165
|
+
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
type AnyEntryMap = ContentEntryMap & DataEntryMap;
|
|
169
|
+
|
|
170
|
+
type ExtractLoaderTypes<T> = T extends import('astro/loaders').LiveLoader<
|
|
171
|
+
infer TData,
|
|
172
|
+
infer TEntryFilter,
|
|
173
|
+
infer TCollectionFilter,
|
|
174
|
+
infer TError
|
|
175
|
+
>
|
|
176
|
+
? { data: TData; entryFilter: TEntryFilter; collectionFilter: TCollectionFilter; error: TError }
|
|
177
|
+
: { data: never; entryFilter: never; collectionFilter: never; error: never };
|
|
178
|
+
type ExtractDataType<T> = ExtractLoaderTypes<T>['data'];
|
|
179
|
+
type ExtractEntryFilterType<T> = ExtractLoaderTypes<T>['entryFilter'];
|
|
180
|
+
type ExtractCollectionFilterType<T> = ExtractLoaderTypes<T>['collectionFilter'];
|
|
181
|
+
type ExtractErrorType<T> = ExtractLoaderTypes<T>['error'];
|
|
182
|
+
|
|
183
|
+
type LiveLoaderDataType<C extends keyof LiveContentConfig['collections']> =
|
|
184
|
+
LiveContentConfig['collections'][C]['schema'] extends undefined
|
|
185
|
+
? ExtractDataType<LiveContentConfig['collections'][C]['loader']>
|
|
186
|
+
: import('astro/zod').infer<
|
|
187
|
+
Exclude<LiveContentConfig['collections'][C]['schema'], undefined>
|
|
188
|
+
>;
|
|
189
|
+
type LiveLoaderEntryFilterType<C extends keyof LiveContentConfig['collections']> =
|
|
190
|
+
ExtractEntryFilterType<LiveContentConfig['collections'][C]['loader']>;
|
|
191
|
+
type LiveLoaderCollectionFilterType<C extends keyof LiveContentConfig['collections']> =
|
|
192
|
+
ExtractCollectionFilterType<LiveContentConfig['collections'][C]['loader']>;
|
|
193
|
+
type LiveLoaderErrorType<C extends keyof LiveContentConfig['collections']> = ExtractErrorType<
|
|
194
|
+
LiveContentConfig['collections'][C]['loader']
|
|
195
|
+
>;
|
|
196
|
+
|
|
197
|
+
export type ContentConfig = typeof import("../src/content.config.mjs");
|
|
198
|
+
export type LiveContentConfig = never;
|
|
199
|
+
}
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Yota Toyama
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@monza-editor/astro",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Astro component of Monza editor",
|
|
5
|
+
"repository": "https://github.com/raviqqe/monza-editor",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"publishConfig": {
|
|
8
|
+
"provenance": true
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"default": "./src/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"shiki": "^3.9.2",
|
|
18
|
+
"monza-editor": "0.3.5"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@raviqqe/tsconfig": "^2.0.1",
|
|
22
|
+
"astro": "^5.13.2",
|
|
23
|
+
"typescript": "^5.9.2"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"build": "astro build"
|
|
27
|
+
}
|
|
28
|
+
}
|