mirror of
https://github.com/khairul169/code-share.git
synced 2026-10-24 11:53:58 +07:00
feat: add personal project list, add project settings, etc
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { ucfirst } from "~/lib/utils";
|
||||
|
||||
export const visibilityList = ["public", "private", "unlisted"].map(
|
||||
(value) => ({
|
||||
value,
|
||||
label: ucfirst(value),
|
||||
})
|
||||
);
|
||||
|
||||
export const cssPreprocessorList = [
|
||||
{
|
||||
label: "None",
|
||||
value: "",
|
||||
},
|
||||
{
|
||||
label: "PostCSS",
|
||||
value: "postcss",
|
||||
},
|
||||
];
|
||||
|
||||
export const jsTranspilerList = [
|
||||
{
|
||||
label: "None",
|
||||
value: "",
|
||||
},
|
||||
{
|
||||
label: "SWC",
|
||||
value: "swc",
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,35 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const projectSettingsSchema = z
|
||||
.object({
|
||||
title: z.string().min(6),
|
||||
// slug: z.string().min(8),
|
||||
visibility: z.enum(["public", "private", "unlisted"]),
|
||||
|
||||
settings: z.object({
|
||||
css: z.object({
|
||||
preprocessor: z.enum(["", "postcss"]).optional().nullable(),
|
||||
tailwindcss: z.boolean().optional().nullable(),
|
||||
}),
|
||||
|
||||
js: z.object({
|
||||
transpiler: z.enum(["", "swc"]).optional().nullable(),
|
||||
packages: z
|
||||
.object({ name: z.string().min(1), url: z.string().min(1).url() })
|
||||
.array(),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
.superRefine((val, ctx) => {
|
||||
const { settings } = val;
|
||||
|
||||
if (settings.css.tailwindcss && settings.css.preprocessor !== "postcss") {
|
||||
ctx.addIssue({
|
||||
code: z.ZodIssueCode.custom,
|
||||
message: "Preprocessor need to be set to PostCSS to use tailwindcss.",
|
||||
path: ["settings.css.preprocessor"],
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
export type ProjectSettingsSchema = z.infer<typeof projectSettingsSchema>;
|
||||
Reference in New Issue
Block a user