improve type

This commit is contained in:
ozakione 2024-04-04 18:07:04 +02:00
parent a9d6bcf968
commit 91aa292d26
2 changed files with 2 additions and 6 deletions

View file

@ -87,10 +87,8 @@ export default function pluginContentShowcase(
); );
const sourcePath = path.join(contentPath, relativeSource); const sourcePath = path.join(contentPath, relativeSource);
const data = await fs.readFile(sourcePath, 'utf-8'); const data = await fs.readFile(sourcePath, 'utf-8');
// todo remove as ... because bad practice ? const unsafeData = Yaml.load(data);
const unsafeData = Yaml.load(data) as {[key: string]: unknown};
const showcaseItem = validateShowcaseItem(unsafeData); const showcaseItem = validateShowcaseItem(unsafeData);
validateFrontMatterTags(showcaseItem.tags, createdTagSchema); validateFrontMatterTags(showcaseItem.tags, createdTagSchema);

View file

@ -17,9 +17,7 @@ const showcaseItemSchema = Joi.object({
tags: Joi.array().items(Joi.string()).required(), tags: Joi.array().items(Joi.string()).required(),
}); });
export function validateShowcaseItem(frontMatter: { export function validateShowcaseItem(frontMatter: unknown): ShowcaseItem {
[key: string]: unknown;
}): ShowcaseItem {
return validateFrontMatter(frontMatter, showcaseItemSchema); return validateFrontMatter(frontMatter, showcaseItemSchema);
} }