@shipsite.dev/core 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/dist/blog.d.ts +29 -0
- package/dist/blog.d.ts.map +1 -0
- package/dist/blog.js +72 -0
- package/dist/blog.js.map +1 -0
- package/dist/config.d.ts +405 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +122 -0
- package/dist/config.js.map +1 -0
- package/dist/content-collections.d.ts +228 -0
- package/dist/content-collections.d.ts.map +1 -0
- package/dist/content-collections.js +58 -0
- package/dist/content-collections.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/mdx.d.ts +20 -0
- package/dist/mdx.d.ts.map +1 -0
- package/dist/mdx.js +53 -0
- package/dist/mdx.js.map +1 -0
- package/dist/middleware.d.ts +15 -0
- package/dist/middleware.d.ts.map +1 -0
- package/dist/middleware.js +70 -0
- package/dist/middleware.js.map +1 -0
- package/dist/pages.d.ts +16 -0
- package/dist/pages.d.ts.map +1 -0
- package/dist/pages.js +119 -0
- package/dist/pages.js.map +1 -0
- package/dist/sitemap.d.ts +3 -0
- package/dist/sitemap.d.ts.map +1 -0
- package/dist/sitemap.js +65 -0
- package/dist/sitemap.js.map +1 -0
- package/dist/theme.d.ts +28 -0
- package/dist/theme.d.ts.map +1 -0
- package/dist/theme.js +184 -0
- package/dist/theme.js.map +1 -0
- package/package.json +73 -0
- package/src/generate-slug-map.mjs +82 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const sitePages: import("@content-collections/core").Collection<"sitePages", z.ZodObject<{
|
|
3
|
+
content: z.ZodString;
|
|
4
|
+
title: z.ZodString;
|
|
5
|
+
description: z.ZodString;
|
|
6
|
+
category: z.ZodOptional<z.ZodString>;
|
|
7
|
+
date: z.ZodOptional<z.ZodString>;
|
|
8
|
+
image: z.ZodOptional<z.ZodString>;
|
|
9
|
+
readingTime: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
featured: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
author: z.ZodOptional<z.ZodString>;
|
|
12
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
13
|
+
}, "strip", z.ZodTypeAny, {
|
|
14
|
+
title: string;
|
|
15
|
+
content: string;
|
|
16
|
+
description: string;
|
|
17
|
+
date?: string | undefined;
|
|
18
|
+
slug?: string | undefined;
|
|
19
|
+
image?: string | undefined;
|
|
20
|
+
category?: string | undefined;
|
|
21
|
+
readingTime?: number | undefined;
|
|
22
|
+
featured?: boolean | undefined;
|
|
23
|
+
author?: string | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
title: string;
|
|
26
|
+
content: string;
|
|
27
|
+
description: string;
|
|
28
|
+
date?: string | undefined;
|
|
29
|
+
slug?: string | undefined;
|
|
30
|
+
image?: string | undefined;
|
|
31
|
+
category?: string | undefined;
|
|
32
|
+
readingTime?: number | undefined;
|
|
33
|
+
featured?: boolean | undefined;
|
|
34
|
+
author?: string | undefined;
|
|
35
|
+
}>, "frontmatter", import("@content-collections/core").Schema<"frontmatter", z.ZodObject<{
|
|
36
|
+
content: z.ZodString;
|
|
37
|
+
title: z.ZodString;
|
|
38
|
+
description: z.ZodString;
|
|
39
|
+
category: z.ZodOptional<z.ZodString>;
|
|
40
|
+
date: z.ZodOptional<z.ZodString>;
|
|
41
|
+
image: z.ZodOptional<z.ZodString>;
|
|
42
|
+
readingTime: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
featured: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
+
author: z.ZodOptional<z.ZodString>;
|
|
45
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
46
|
+
}, "strip", z.ZodTypeAny, {
|
|
47
|
+
title: string;
|
|
48
|
+
content: string;
|
|
49
|
+
description: string;
|
|
50
|
+
date?: string | undefined;
|
|
51
|
+
slug?: string | undefined;
|
|
52
|
+
image?: string | undefined;
|
|
53
|
+
category?: string | undefined;
|
|
54
|
+
readingTime?: number | undefined;
|
|
55
|
+
featured?: boolean | undefined;
|
|
56
|
+
author?: string | undefined;
|
|
57
|
+
}, {
|
|
58
|
+
title: string;
|
|
59
|
+
content: string;
|
|
60
|
+
description: string;
|
|
61
|
+
date?: string | undefined;
|
|
62
|
+
slug?: string | undefined;
|
|
63
|
+
image?: string | undefined;
|
|
64
|
+
category?: string | undefined;
|
|
65
|
+
readingTime?: number | undefined;
|
|
66
|
+
featured?: boolean | undefined;
|
|
67
|
+
author?: string | undefined;
|
|
68
|
+
}>>, {
|
|
69
|
+
locale: string;
|
|
70
|
+
contentFolder: string;
|
|
71
|
+
contentId: string;
|
|
72
|
+
kind: string;
|
|
73
|
+
excerpt: string;
|
|
74
|
+
body: {
|
|
75
|
+
raw: string;
|
|
76
|
+
};
|
|
77
|
+
title: string;
|
|
78
|
+
content: string;
|
|
79
|
+
description: string;
|
|
80
|
+
date?: string | undefined;
|
|
81
|
+
slug?: string | undefined;
|
|
82
|
+
image?: string | undefined;
|
|
83
|
+
category?: string | undefined;
|
|
84
|
+
readingTime?: number | undefined;
|
|
85
|
+
featured?: boolean | undefined;
|
|
86
|
+
author?: string | undefined;
|
|
87
|
+
_meta: import("@content-collections/core").Meta;
|
|
88
|
+
}, {
|
|
89
|
+
locale: string;
|
|
90
|
+
contentFolder: string;
|
|
91
|
+
contentId: string;
|
|
92
|
+
kind: string;
|
|
93
|
+
excerpt: string;
|
|
94
|
+
body: {
|
|
95
|
+
raw: string;
|
|
96
|
+
};
|
|
97
|
+
title: string;
|
|
98
|
+
content: string;
|
|
99
|
+
description: string;
|
|
100
|
+
date?: string | undefined;
|
|
101
|
+
slug?: string | undefined;
|
|
102
|
+
image?: string | undefined;
|
|
103
|
+
category?: string | undefined;
|
|
104
|
+
readingTime?: number | undefined;
|
|
105
|
+
featured?: boolean | undefined;
|
|
106
|
+
author?: string | undefined;
|
|
107
|
+
_meta: {
|
|
108
|
+
filePath: string;
|
|
109
|
+
fileName: string;
|
|
110
|
+
directory: string;
|
|
111
|
+
path: string;
|
|
112
|
+
extension: string;
|
|
113
|
+
};
|
|
114
|
+
}>;
|
|
115
|
+
export declare function createContentCollectionsConfig(): import("@content-collections/core").ConfigurationWithContent<import("@content-collections/core").Collection<"sitePages", z.ZodObject<{
|
|
116
|
+
content: z.ZodString;
|
|
117
|
+
title: z.ZodString;
|
|
118
|
+
description: z.ZodString;
|
|
119
|
+
category: z.ZodOptional<z.ZodString>;
|
|
120
|
+
date: z.ZodOptional<z.ZodString>;
|
|
121
|
+
image: z.ZodOptional<z.ZodString>;
|
|
122
|
+
readingTime: z.ZodOptional<z.ZodNumber>;
|
|
123
|
+
featured: z.ZodOptional<z.ZodBoolean>;
|
|
124
|
+
author: z.ZodOptional<z.ZodString>;
|
|
125
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
126
|
+
}, "strip", z.ZodTypeAny, {
|
|
127
|
+
title: string;
|
|
128
|
+
content: string;
|
|
129
|
+
description: string;
|
|
130
|
+
date?: string | undefined;
|
|
131
|
+
slug?: string | undefined;
|
|
132
|
+
image?: string | undefined;
|
|
133
|
+
category?: string | undefined;
|
|
134
|
+
readingTime?: number | undefined;
|
|
135
|
+
featured?: boolean | undefined;
|
|
136
|
+
author?: string | undefined;
|
|
137
|
+
}, {
|
|
138
|
+
title: string;
|
|
139
|
+
content: string;
|
|
140
|
+
description: string;
|
|
141
|
+
date?: string | undefined;
|
|
142
|
+
slug?: string | undefined;
|
|
143
|
+
image?: string | undefined;
|
|
144
|
+
category?: string | undefined;
|
|
145
|
+
readingTime?: number | undefined;
|
|
146
|
+
featured?: boolean | undefined;
|
|
147
|
+
author?: string | undefined;
|
|
148
|
+
}>, "frontmatter", import("@content-collections/core").Schema<"frontmatter", z.ZodObject<{
|
|
149
|
+
content: z.ZodString;
|
|
150
|
+
title: z.ZodString;
|
|
151
|
+
description: z.ZodString;
|
|
152
|
+
category: z.ZodOptional<z.ZodString>;
|
|
153
|
+
date: z.ZodOptional<z.ZodString>;
|
|
154
|
+
image: z.ZodOptional<z.ZodString>;
|
|
155
|
+
readingTime: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
featured: z.ZodOptional<z.ZodBoolean>;
|
|
157
|
+
author: z.ZodOptional<z.ZodString>;
|
|
158
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
159
|
+
}, "strip", z.ZodTypeAny, {
|
|
160
|
+
title: string;
|
|
161
|
+
content: string;
|
|
162
|
+
description: string;
|
|
163
|
+
date?: string | undefined;
|
|
164
|
+
slug?: string | undefined;
|
|
165
|
+
image?: string | undefined;
|
|
166
|
+
category?: string | undefined;
|
|
167
|
+
readingTime?: number | undefined;
|
|
168
|
+
featured?: boolean | undefined;
|
|
169
|
+
author?: string | undefined;
|
|
170
|
+
}, {
|
|
171
|
+
title: string;
|
|
172
|
+
content: string;
|
|
173
|
+
description: string;
|
|
174
|
+
date?: string | undefined;
|
|
175
|
+
slug?: string | undefined;
|
|
176
|
+
image?: string | undefined;
|
|
177
|
+
category?: string | undefined;
|
|
178
|
+
readingTime?: number | undefined;
|
|
179
|
+
featured?: boolean | undefined;
|
|
180
|
+
author?: string | undefined;
|
|
181
|
+
}>>, {
|
|
182
|
+
locale: string;
|
|
183
|
+
contentFolder: string;
|
|
184
|
+
contentId: string;
|
|
185
|
+
kind: string;
|
|
186
|
+
excerpt: string;
|
|
187
|
+
body: {
|
|
188
|
+
raw: string;
|
|
189
|
+
};
|
|
190
|
+
title: string;
|
|
191
|
+
content: string;
|
|
192
|
+
description: string;
|
|
193
|
+
date?: string | undefined;
|
|
194
|
+
slug?: string | undefined;
|
|
195
|
+
image?: string | undefined;
|
|
196
|
+
category?: string | undefined;
|
|
197
|
+
readingTime?: number | undefined;
|
|
198
|
+
featured?: boolean | undefined;
|
|
199
|
+
author?: string | undefined;
|
|
200
|
+
_meta: import("@content-collections/core").Meta;
|
|
201
|
+
}, {
|
|
202
|
+
locale: string;
|
|
203
|
+
contentFolder: string;
|
|
204
|
+
contentId: string;
|
|
205
|
+
kind: string;
|
|
206
|
+
excerpt: string;
|
|
207
|
+
body: {
|
|
208
|
+
raw: string;
|
|
209
|
+
};
|
|
210
|
+
title: string;
|
|
211
|
+
content: string;
|
|
212
|
+
description: string;
|
|
213
|
+
date?: string | undefined;
|
|
214
|
+
slug?: string | undefined;
|
|
215
|
+
image?: string | undefined;
|
|
216
|
+
category?: string | undefined;
|
|
217
|
+
readingTime?: number | undefined;
|
|
218
|
+
featured?: boolean | undefined;
|
|
219
|
+
author?: string | undefined;
|
|
220
|
+
_meta: {
|
|
221
|
+
filePath: string;
|
|
222
|
+
fileName: string;
|
|
223
|
+
directory: string;
|
|
224
|
+
path: string;
|
|
225
|
+
extension: string;
|
|
226
|
+
};
|
|
227
|
+
}>[]>;
|
|
228
|
+
//# sourceMappingURL=content-collections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-collections.d.ts","sourceRoot":"","sources":["../src/content-collections.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmDpB,CAAC;AAEH,wBAAgB,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAI7C"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { defineCollection, defineConfig } from '@content-collections/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const sitePages = defineCollection({
|
|
4
|
+
name: 'sitePages',
|
|
5
|
+
directory: 'content',
|
|
6
|
+
include: '**/*.mdx',
|
|
7
|
+
schema: z.object({
|
|
8
|
+
content: z.string(),
|
|
9
|
+
title: z.string(),
|
|
10
|
+
description: z.string(),
|
|
11
|
+
category: z.string().optional(),
|
|
12
|
+
date: z.string().optional(),
|
|
13
|
+
image: z.string().optional(),
|
|
14
|
+
readingTime: z.number().optional(),
|
|
15
|
+
featured: z.boolean().optional(),
|
|
16
|
+
author: z.string().optional(),
|
|
17
|
+
slug: z.string().optional(),
|
|
18
|
+
}),
|
|
19
|
+
transform: (doc) => {
|
|
20
|
+
const locale = doc._meta.fileName.replace(/\.mdx$/, '');
|
|
21
|
+
const contentFolder = doc._meta.directory;
|
|
22
|
+
const contentId = doc._meta.path.replace(/\.mdx$/, '');
|
|
23
|
+
const path = doc._meta.directory;
|
|
24
|
+
let kind;
|
|
25
|
+
if (path.startsWith('blog/')) {
|
|
26
|
+
kind = path.split('/').length > 1 ? 'blog-article' : 'blog-index';
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
kind = 'page';
|
|
30
|
+
}
|
|
31
|
+
// Extract excerpt from BlogIntro component
|
|
32
|
+
const raw = doc.content;
|
|
33
|
+
const match = raw.match(/<BlogIntro>\s*([\s\S]*?)\s*<\/BlogIntro>/);
|
|
34
|
+
const excerpt = match
|
|
35
|
+
? match[1]
|
|
36
|
+
.replace(/\*\*(.*?)\*\*/g, '$1')
|
|
37
|
+
.replace(/\[(.*?)\]\(.*?\)/g, '$1')
|
|
38
|
+
.replace(/[*_~`]/g, '')
|
|
39
|
+
.replace(/\n+/g, ' ')
|
|
40
|
+
.trim()
|
|
41
|
+
: '';
|
|
42
|
+
return {
|
|
43
|
+
...doc,
|
|
44
|
+
locale,
|
|
45
|
+
contentFolder,
|
|
46
|
+
contentId,
|
|
47
|
+
kind,
|
|
48
|
+
excerpt,
|
|
49
|
+
body: { raw: doc.content },
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
export function createContentCollectionsConfig() {
|
|
54
|
+
return defineConfig({
|
|
55
|
+
content: [sitePages],
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=content-collections.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content-collections.js","sourceRoot":"","sources":["../src/content-collections.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,SAAS,GAAG,gBAAgB,CAAC;IACxC,IAAI,EAAE,WAAW;IACjB,SAAS,EAAE,SAAS;IACpB,OAAO,EAAE,UAAU;IACnB,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;QACf,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;QACnB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;QACjB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;QACvB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC/B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC3B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC5B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAClC,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;QAChC,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;QAC7B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;KAC5B,CAAC;IACF,SAAS,EAAE,CAAC,GAAG,EAAE,EAAE;QACjB,MAAM,MAAM,GAAG,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QACxD,MAAM,aAAa,GAAG,GAAG,CAAC,KAAK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0,0 +1,8 @@
|
|
|
1
|
+
export * from './config';
|
|
2
|
+
export * from './pages';
|
|
3
|
+
export * from './mdx';
|
|
4
|
+
export * from './blog';
|
|
5
|
+
export * from './theme';
|
|
6
|
+
export { default as sitemap } from './sitemap';
|
|
7
|
+
export { createShipSiteMiddleware, middlewareConfig } from './middleware';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @shipsite.dev/core
|
|
2
|
+
export * from './config';
|
|
3
|
+
export * from './pages';
|
|
4
|
+
export * from './mdx';
|
|
5
|
+
export * from './blog';
|
|
6
|
+
export * from './theme';
|
|
7
|
+
export { default as sitemap } from './sitemap';
|
|
8
|
+
export { createShipSiteMiddleware, middlewareConfig } from './middleware';
|
|
9
|
+
// Note: content-collections exports are available via '@shipsite.dev/core/content-collections'
|
|
10
|
+
// They are NOT re-exported here to avoid pulling @content-collections/core into the Next.js bundle
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qBAAqB;AACrB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAC;AAC/C,OAAO,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAC1E,+FAA+F;AAC/F,mGAAmG"}
|
package/dist/mdx.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type React from 'react';
|
|
2
|
+
export interface PageFrontmatter {
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
category?: string;
|
|
6
|
+
date?: string;
|
|
7
|
+
dateModified?: string;
|
|
8
|
+
image?: string;
|
|
9
|
+
readingTime?: number;
|
|
10
|
+
wordCount?: number;
|
|
11
|
+
featured?: boolean;
|
|
12
|
+
author?: string;
|
|
13
|
+
}
|
|
14
|
+
export declare function getPageContent(pageName: string, locale: string, components?: Record<string, unknown>): Promise<{
|
|
15
|
+
content: React.ReactElement<unknown, string | React.JSXElementConstructor<any>>;
|
|
16
|
+
frontmatter: PageFrontmatter;
|
|
17
|
+
}>;
|
|
18
|
+
export declare function getAvailablePages(): string[];
|
|
19
|
+
export declare function getAvailableLocales(pageName: string): string[];
|
|
20
|
+
//# sourceMappingURL=mdx.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdx.d.ts","sourceRoot":"","sources":["../src/mdx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,cAAc,CAClC,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,UAAU,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAM;;;GA0DzC;AAED,wBAAgB,iBAAiB,IAAI,MAAM,EAAE,CAI5C;AAED,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,EAAE,CAI9D"}
|
package/dist/mdx.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { compileMDX } from 'next-mdx-remote/rsc';
|
|
2
|
+
import { allSitePages } from 'content-collections';
|
|
3
|
+
export async function getPageContent(pageName, locale, components = {}) {
|
|
4
|
+
const page = allSitePages.find((doc) => doc.contentFolder === pageName && doc.locale === locale);
|
|
5
|
+
if (!page) {
|
|
6
|
+
throw new Error(`MDX content not found: ${pageName}/${locale}`);
|
|
7
|
+
}
|
|
8
|
+
const allComponents = { ...components };
|
|
9
|
+
// Inject contentFolder so wrapper components can resolve their own metadata
|
|
10
|
+
const contentFolderInjections = {
|
|
11
|
+
'blog/': 'BlogArticle',
|
|
12
|
+
};
|
|
13
|
+
for (const [prefix, componentName] of Object.entries(contentFolderInjections)) {
|
|
14
|
+
const isNested = pageName.startsWith(prefix) && pageName !== prefix.slice(0, -1);
|
|
15
|
+
if (isNested) {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
const Orig = components[componentName];
|
|
18
|
+
if (Orig) {
|
|
19
|
+
allComponents[componentName] = async (props) => Orig({ ...props, contentFolder: pageName });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const { content } = await compileMDX({
|
|
24
|
+
source: page.body.raw,
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
components: allComponents,
|
|
27
|
+
options: {
|
|
28
|
+
parseFrontmatter: false,
|
|
29
|
+
blockJS: false,
|
|
30
|
+
blockDangerousJS: false,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
const frontmatter = {
|
|
34
|
+
title: page.title,
|
|
35
|
+
description: page.description,
|
|
36
|
+
category: page.category || undefined,
|
|
37
|
+
date: page.date || undefined,
|
|
38
|
+
image: page.image || undefined,
|
|
39
|
+
readingTime: page.readingTime || undefined,
|
|
40
|
+
featured: page.featured || undefined,
|
|
41
|
+
author: page.author || undefined,
|
|
42
|
+
};
|
|
43
|
+
return { content, frontmatter };
|
|
44
|
+
}
|
|
45
|
+
export function getAvailablePages() {
|
|
46
|
+
return Array.from(new Set(allSitePages.map((page) => page.contentFolder).filter(Boolean)));
|
|
47
|
+
}
|
|
48
|
+
export function getAvailableLocales(pageName) {
|
|
49
|
+
return allSitePages
|
|
50
|
+
.filter((page) => page.contentFolder === pageName)
|
|
51
|
+
.map((page) => page.locale);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=mdx.js.map
|
package/dist/mdx.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mdx.js","sourceRoot":"","sources":["../src/mdx.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAenD,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,QAAgB,EAChB,MAAc,EACd,aAAsC,EAAE;IAExC,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAC5B,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa,KAAK,QAAQ,IAAI,GAAG,CAAC,MAAM,KAAK,MAAM,CACjE,CAAC;IAEF,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,MAAM,IAAI,KAAK,CAAC,0BAA0B,QAAQ,IAAI,MAAM,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,MAAM,aAAa,GAAG,EAAE,GAAG,UAAU,EAAE,CAAC;IAExC,4EAA4E;IAC5E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,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS;KACjC,CAAC;IAEF,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,KAAK,CAAC,IAAI,CACf,IAAI,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CACxE,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,QAAgB;IAClD,OAAO,YAAY;SAChB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,aAAa,KAAK,QAAQ,CAAC;SACjD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
+
/**
|
|
3
|
+
* Create ShipSite middleware.
|
|
4
|
+
* Must be called with the slug-map and locale config.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createShipSiteMiddleware(options: {
|
|
7
|
+
locales: string[];
|
|
8
|
+
defaultLocale: string;
|
|
9
|
+
localePrefix: 'as-needed' | 'always' | 'never';
|
|
10
|
+
slugMap: Record<string, Record<string, string>>;
|
|
11
|
+
}): (request: NextRequest) => NextResponse<unknown>;
|
|
12
|
+
export declare const middlewareConfig: {
|
|
13
|
+
matcher: string[];
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=middleware.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIxD;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE;IAChD,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,WAAW,GAAG,QAAQ,GAAG,OAAO,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACjD,IAwB4B,SAAS,WAAW,2BA4ChD;AAED,eAAO,MAAM,gBAAgB;;CAE5B,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { NextResponse } from 'next/server';
|
|
2
|
+
import createMiddleware from 'next-intl/middleware';
|
|
3
|
+
import { defineRouting } from 'next-intl/routing';
|
|
4
|
+
/**
|
|
5
|
+
* Create ShipSite middleware.
|
|
6
|
+
* Must be called with the slug-map and locale config.
|
|
7
|
+
*/
|
|
8
|
+
export function createShipSiteMiddleware(options) {
|
|
9
|
+
const { locales, defaultLocale, localePrefix, slugMap } = options;
|
|
10
|
+
const routing = defineRouting({
|
|
11
|
+
locales,
|
|
12
|
+
defaultLocale,
|
|
13
|
+
localePrefix,
|
|
14
|
+
});
|
|
15
|
+
const intlMiddleware = createMiddleware(routing);
|
|
16
|
+
const nonDefaultLocales = locales.filter((l) => l !== defaultLocale);
|
|
17
|
+
const localePattern = new RegExp(`^/(${nonDefaultLocales.join('|')})(/.*)?$`);
|
|
18
|
+
function remapSlug(locale, enSlug) {
|
|
19
|
+
const entry = slugMap[enSlug];
|
|
20
|
+
if (entry?.[locale] && entry[locale] !== enSlug) {
|
|
21
|
+
return `/${locale}/${entry[locale]}`;
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return function middleware(request) {
|
|
26
|
+
const { pathname } = request.nextUrl;
|
|
27
|
+
// Case 1: Direct visit with EN slug under a non-default locale prefix
|
|
28
|
+
const localeMatch = pathname.match(localePattern);
|
|
29
|
+
if (localeMatch) {
|
|
30
|
+
const locale = localeMatch[1];
|
|
31
|
+
const slug = (localeMatch[2] || '').replace(/^\//, '');
|
|
32
|
+
const corrected = remapSlug(locale, slug);
|
|
33
|
+
if (corrected) {
|
|
34
|
+
const url = request.nextUrl.clone();
|
|
35
|
+
url.pathname = corrected;
|
|
36
|
+
return NextResponse.redirect(url, 308);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
// Run next-intl middleware
|
|
40
|
+
const response = intlMiddleware(request);
|
|
41
|
+
// Case 2: next-intl redirected to /{locale}/{en-slug} — correct the slug
|
|
42
|
+
const status = response.status;
|
|
43
|
+
if (status === 307 || status === 308) {
|
|
44
|
+
const location = response.headers.get('location');
|
|
45
|
+
if (location) {
|
|
46
|
+
try {
|
|
47
|
+
const url = new URL(location, request.url);
|
|
48
|
+
const redirectMatch = url.pathname.match(localePattern);
|
|
49
|
+
if (redirectMatch) {
|
|
50
|
+
const locale = redirectMatch[1];
|
|
51
|
+
const slug = (redirectMatch[2] || '').replace(/^\//, '');
|
|
52
|
+
const corrected = remapSlug(locale, slug);
|
|
53
|
+
if (corrected) {
|
|
54
|
+
url.pathname = corrected;
|
|
55
|
+
return NextResponse.redirect(url, 308);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
catch {
|
|
60
|
+
// Invalid URL — let the original redirect pass through
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return response;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
export const middlewareConfig = {
|
|
68
|
+
matcher: ['/((?!api|_next|_vercel|.*\\..*).*)'],
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sourceRoot":"","sources":["../src/middleware.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,YAAY,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,gBAAgB,MAAM,sBAAsB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,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BAAC,MAAM,CAAC;oBACP,uDAAuD;gBACzD,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,OAAO,EAAE,CAAC,oCAAoC,CAAC;CAChD,CAAC"}
|
package/dist/pages.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type PageConfig } from './config';
|
|
2
|
+
export declare function getAllPages(): PageConfig[];
|
|
3
|
+
export declare function getPageBySlug(slug: string, locale: string): PageConfig | undefined;
|
|
4
|
+
export declare function pageExists(slug: string, locale: string): boolean;
|
|
5
|
+
export declare function generateAllStaticParams(): {
|
|
6
|
+
locale: string;
|
|
7
|
+
slug?: string[];
|
|
8
|
+
}[];
|
|
9
|
+
export declare function getPagesByType(type: string): PageConfig[];
|
|
10
|
+
export declare function isNoIndexPage(page: PageConfig): boolean;
|
|
11
|
+
export declare function buildCanonicalUrl(locale: string, slug: string): string;
|
|
12
|
+
export declare function resolvePageHref(enSlug: string, locale: string): string;
|
|
13
|
+
export declare function generateNavLinks(locale: string): Record<string, string>;
|
|
14
|
+
export declare function generateAlternatePathMap(): Record<string, Record<string, string>>;
|
|
15
|
+
export declare function getAlternateUrls(page: PageConfig): Record<string, string>;
|
|
16
|
+
//# sourceMappingURL=pages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages.d.ts","sourceRoot":"","sources":["../src/pages.ts"],"names":[],"mappings":"AACA,OAAO,EAA2C,KAAK,UAAU,EAAE,MAAM,UAAU,CAAC;AAiBpF,wBAAgB,WAAW,IAAI,UAAU,EAAE,CAE1C;AAED,wBAAgB,aAAa,CAC3B,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,UAAU,GAAG,SAAS,CAgBxB;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAEhE;AAED,wBAAgB,uBAAuB,IAAI;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,EAAE,CAmBF;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,EAAE,CAEzD;AAKD,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAEvD;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAKtE;AAED,wBAAgB,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAsBtE;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMvE;AAED,wBAAgB,wBAAwB,IAAI,MAAM,CAChD,MAAM,EACN,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CACvB,CAkBA;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAgBzE"}
|
package/dist/pages.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { allSitePages } from 'content-collections';
|
|
2
|
+
import { getConfig, getSiteUrl, getDefaultLocale } from './config';
|
|
3
|
+
/**
|
|
4
|
+
* Resolve the full URL slug for a content-collections doc.
|
|
5
|
+
*/
|
|
6
|
+
function resolveDocSlug(doc, fallbackSlug) {
|
|
7
|
+
if (!doc.slug)
|
|
8
|
+
return fallbackSlug;
|
|
9
|
+
if (doc.slug.includes('/'))
|
|
10
|
+
return doc.slug;
|
|
11
|
+
const folderParts = doc.contentFolder.split('/');
|
|
12
|
+
const prefix = folderParts.length > 1 ? folderParts.slice(0, -1).join('/') + '/' : '';
|
|
13
|
+
return prefix + doc.slug;
|
|
14
|
+
}
|
|
15
|
+
export function getAllPages() {
|
|
16
|
+
return getConfig().pages;
|
|
17
|
+
}
|
|
18
|
+
export function getPageBySlug(slug, locale) {
|
|
19
|
+
const pages = getConfig().pages;
|
|
20
|
+
const direct = pages.find((p) => p.slug === slug);
|
|
21
|
+
if (direct)
|
|
22
|
+
return direct;
|
|
23
|
+
for (const doc of allSitePages) {
|
|
24
|
+
if (doc.locale !== locale || !doc.slug)
|
|
25
|
+
continue;
|
|
26
|
+
const page = pages.find((p) => p.content === doc.contentFolder);
|
|
27
|
+
const fullSlug = resolveDocSlug(doc, page?.slug ?? '');
|
|
28
|
+
if (fullSlug === slug) {
|
|
29
|
+
return page;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
export function pageExists(slug, locale) {
|
|
35
|
+
return !!getPageBySlug(slug, locale);
|
|
36
|
+
}
|
|
37
|
+
export function generateAllStaticParams() {
|
|
38
|
+
const pages = getAllPages();
|
|
39
|
+
const defaultLocale = getDefaultLocale();
|
|
40
|
+
return pages.flatMap((page) => {
|
|
41
|
+
const pageLocales = page.locales || [defaultLocale];
|
|
42
|
+
return pageLocales.map((locale) => {
|
|
43
|
+
const doc = allSitePages.find((d) => d.contentFolder === page.content && d.locale === locale);
|
|
44
|
+
const resolvedSlug = doc ? resolveDocSlug(doc, page.slug) : page.slug;
|
|
45
|
+
return {
|
|
46
|
+
locale,
|
|
47
|
+
slug: resolvedSlug ? resolvedSlug.split('/') : undefined,
|
|
48
|
+
};
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export function getPagesByType(type) {
|
|
53
|
+
return getConfig().pages.filter((p) => p.type === type);
|
|
54
|
+
}
|
|
55
|
+
const noIndexTypes = new Set(['legal']);
|
|
56
|
+
const noIndexSlugs = new Set(['thank-you']);
|
|
57
|
+
export function isNoIndexPage(page) {
|
|
58
|
+
return noIndexTypes.has(page.type) || noIndexSlugs.has(page.slug);
|
|
59
|
+
}
|
|
60
|
+
export function buildCanonicalUrl(locale, slug) {
|
|
61
|
+
const defaultLocale = getDefaultLocale();
|
|
62
|
+
const prefix = locale === defaultLocale ? '' : `/${locale}`;
|
|
63
|
+
const path = slug ? `/${slug}` : '';
|
|
64
|
+
return `${getSiteUrl()}${prefix}${path}`;
|
|
65
|
+
}
|
|
66
|
+
export function resolvePageHref(enSlug, locale) {
|
|
67
|
+
const pages = getConfig().pages;
|
|
68
|
+
const defaultLocale = getDefaultLocale();
|
|
69
|
+
const page = pages.find((p) => p.slug === enSlug);
|
|
70
|
+
if (!page) {
|
|
71
|
+
return enSlug ? `/${enSlug}` : '/';
|
|
72
|
+
}
|
|
73
|
+
const pageLocales = page.locales || [defaultLocale];
|
|
74
|
+
if (!pageLocales.includes(locale)) {
|
|
75
|
+
return enSlug ? `/${enSlug}` : '/';
|
|
76
|
+
}
|
|
77
|
+
const doc = allSitePages.find((d) => d.contentFolder === page.content && d.locale === locale);
|
|
78
|
+
const resolvedSlug = doc ? resolveDocSlug(doc, page.slug) : page.slug;
|
|
79
|
+
const localePrefix = locale === defaultLocale ? '' : `/${locale}`;
|
|
80
|
+
return resolvedSlug
|
|
81
|
+
? `${localePrefix}/${resolvedSlug}`
|
|
82
|
+
: localePrefix || '/';
|
|
83
|
+
}
|
|
84
|
+
export function generateNavLinks(locale) {
|
|
85
|
+
const links = {};
|
|
86
|
+
for (const page of getConfig().pages) {
|
|
87
|
+
links[page.slug] = resolvePageHref(page.slug, locale);
|
|
88
|
+
}
|
|
89
|
+
return links;
|
|
90
|
+
}
|
|
91
|
+
export function generateAlternatePathMap() {
|
|
92
|
+
const map = {};
|
|
93
|
+
const defaultLocale = getDefaultLocale();
|
|
94
|
+
for (const page of getConfig().pages) {
|
|
95
|
+
const pageLocales = page.locales || [defaultLocale];
|
|
96
|
+
const alternates = {};
|
|
97
|
+
for (const locale of pageLocales) {
|
|
98
|
+
alternates[locale] = resolvePageHref(page.slug, locale);
|
|
99
|
+
}
|
|
100
|
+
for (const href of Object.values(alternates)) {
|
|
101
|
+
map[href] = alternates;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return map;
|
|
105
|
+
}
|
|
106
|
+
export function getAlternateUrls(page) {
|
|
107
|
+
const languages = {};
|
|
108
|
+
const defaultLocale = getDefaultLocale();
|
|
109
|
+
const pageLocales = page.locales || [defaultLocale];
|
|
110
|
+
for (const loc of pageLocales) {
|
|
111
|
+
const doc = allSitePages.find((d) => d.contentFolder === page.content && d.locale === loc);
|
|
112
|
+
const resolvedSlug = doc ? resolveDocSlug(doc, page.slug) : page.slug;
|
|
113
|
+
languages[loc] = buildCanonicalUrl(loc, resolvedSlug);
|
|
114
|
+
}
|
|
115
|
+
languages['x-default'] =
|
|
116
|
+
languages[defaultLocale] || buildCanonicalUrl(defaultLocale, page.slug);
|
|
117
|
+
return languages;
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=pages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pages.js","sourceRoot":"","sources":["../src/pages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,gBAAgB,EAAmB,MAAM,UAAU,CAAC;AAEpF;;GAEG;AACH,SAAS,cAAc,CACrB,GAA6C,EAC7C,YAAoB;IAEpB,IAAI,CAAC,GAAG,CAAC,IAAI;QAAE,OAAO,YAAY,CAAC;IACnC,IAAI,GAAG,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC,IAAI,CAAC;IAC5C,MAAM,WAAW,GAAG,GAAG,CAAC,aAAa,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACjD,MAAM,MAAM,GACV,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,G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