From 1c281f220d91918270f7115966d71b8e791f6c7e Mon Sep 17 00:00:00 2001 From: Henrique Ramos Date: Wed, 26 Feb 2025 21:03:48 -0300 Subject: [PATCH] chore: use arktype infer to create Slide type --- src/utils/getSlides.ts | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/utils/getSlides.ts b/src/utils/getSlides.ts index cbb924a..528bf52 100644 --- a/src/utils/getSlides.ts +++ b/src/utils/getSlides.ts @@ -2,14 +2,9 @@ import type { AstroInstance } from "astro"; import getAstroPages from "./getAstroPages"; import { type } from "arktype"; -type Slide = AstroInstance & { - [key: string]: unknown; - title: string; - description: string; - authors: string[]; - publishedAt: string; - draft?: boolean; -}; +const schema = type({ title: "string", description: "string", authors: "string[]", publishedAt: "string" }); + +type Slide = AstroInstance & typeof schema.infer & { [key: string]: unknown }; /** /** @@ -22,10 +17,5 @@ export const getSlides = () => ["@slides/**/index.astro", "@slides/*.astro"], { eager: true }, ), - schema: type({ - title: "string", - description: "string", - authors: "string[]", - publishedAt: "string", - }), + schema, });