feat(overview) : add YouTube video section
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import * as z from "zod";
|
||||
|
||||
import { targetStatOptions } from "@/lib/guides/stats";
|
||||
import { parseYouTubeUrl } from "@/lib/guides/youtube";
|
||||
|
||||
export const guideSectionKinds = ["weapon", "artifact", "constellations", "team"] as const;
|
||||
export type GuideSectionKind = (typeof guideSectionKinds)[number];
|
||||
@@ -14,10 +15,20 @@ export const createGuideSchema = z.strictObject({
|
||||
overview: z.string().trim().max(500),
|
||||
});
|
||||
|
||||
const youtubeUrlSchema = z.string().trim().max(2_048).optional().transform((value, context) => {
|
||||
if (value === undefined) return undefined;
|
||||
if (!value) return null;
|
||||
const video = parseYouTubeUrl(value);
|
||||
if (video) return video.watchUrl;
|
||||
context.addIssue({ code: "custom", message: "กรุณาใส่ลิงก์วิดีโอ YouTube ที่ถูกต้อง" });
|
||||
return z.NEVER;
|
||||
});
|
||||
|
||||
export const updateGuideSchema = z.strictObject({
|
||||
expectedVersion: z.number().int().positive(),
|
||||
coverMediaId: z.string().uuid(),
|
||||
overview: z.string().trim().min(1).max(500),
|
||||
youtubeUrl: youtubeUrlSchema,
|
||||
});
|
||||
|
||||
export const weaponSectionSchema = z.strictObject({
|
||||
|
||||
Reference in New Issue
Block a user