chore: use arktype infer to create Slide type

This commit is contained in:
Henrique Ramos 2025-02-26 21:03:48 -03:00
parent 967ad59394
commit 1c281f220d

View File

@ -2,14 +2,9 @@ import type { AstroInstance } from "astro";
import getAstroPages from "./getAstroPages"; import getAstroPages from "./getAstroPages";
import { type } from "arktype"; import { type } from "arktype";
type Slide = AstroInstance & { const schema = type({ title: "string", description: "string", authors: "string[]", publishedAt: "string" });
[key: string]: unknown;
title: string; type Slide = AstroInstance & typeof schema.infer & { [key: string]: unknown };
description: string;
authors: string[];
publishedAt: string;
draft?: boolean;
};
/** /**
/** /**
@ -22,10 +17,5 @@ export const getSlides = () =>
["@slides/**/index.astro", "@slides/*.astro"], ["@slides/**/index.astro", "@slides/*.astro"],
{ eager: true }, { eager: true },
), ),
schema: type({ schema,
title: "string",
description: "string",
authors: "string[]",
publishedAt: "string",
}),
}); });