Refactor Keystatic configuration and update turbo.json
The keystatic.config.ts has been again refactor with new field validations and a new dedicated function to get collections. The "turbo.json" file is also updated with a new "ui" field. The refactor aims to streamline the collection generation, and the "ui" field in "turbo.json" enhances its configuration capabilities.
This commit is contained in:
@@ -17,7 +17,9 @@ const local = z.object({
|
||||
|
||||
const cloud = z.object({
|
||||
kind: z.literal('cloud'),
|
||||
project: z.string(),
|
||||
project: z.string().min(1),
|
||||
branchPrefix: z.string().optional(),
|
||||
pathPrefix: z.string().optional(),
|
||||
}) satisfies ZodOutputFor<CloudConfig['storage']>;
|
||||
|
||||
const github = z.object({
|
||||
@@ -26,6 +28,8 @@ const github = z.object({
|
||||
branchPrefix: z.string().optional(),
|
||||
pathPrefix: z.string().optional(),
|
||||
githubToken: z.string({
|
||||
description:
|
||||
'The GitHub token to use for authentication with the GitHub API',
|
||||
required_error: 'Please provide a GitHub token',
|
||||
}),
|
||||
}) satisfies ZodOutputFor<GitHubConfig['storage']>;
|
||||
@@ -82,9 +86,21 @@ function createKeyStaticConfig(path = '') {
|
||||
path += '/';
|
||||
}
|
||||
|
||||
const cloud = {
|
||||
project: storage.kind === 'cloud' ? storage.project : '',
|
||||
};
|
||||
|
||||
const collections = getKeystaticCollections(path);
|
||||
|
||||
return config({
|
||||
storage,
|
||||
collections: {
|
||||
cloud,
|
||||
collections,
|
||||
});
|
||||
}
|
||||
|
||||
function getKeystaticCollections(path: string) {
|
||||
return {
|
||||
posts: collection({
|
||||
label: 'Posts',
|
||||
slugField: 'title',
|
||||
@@ -135,6 +151,5 @@ function createKeyStaticConfig(path = '') {
|
||||
tags: fields.array(fields.text({ label: 'Tag' })),
|
||||
},
|
||||
}),
|
||||
},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
"globalDependencies": [
|
||||
"**/.env"
|
||||
],
|
||||
"ui": "stream",
|
||||
"globalEnv": [
|
||||
"STRIPE_SECRET_KEY",
|
||||
"STRIPE_WEBHOOK_SECRET",
|
||||
|
||||
Reference in New Issue
Block a user