mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-01 10:22:30 +02:00
improve type
This commit is contained in:
parent
a9d6bcf968
commit
91aa292d26
2 changed files with 2 additions and 6 deletions
|
@ -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);
|
||||||
|
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue