chore: add draft flag

This commit is contained in:
Henrique Ramos 2025-02-03 11:32:13 -03:00
parent be2a96ac22
commit 32af9bde3d
2 changed files with 22 additions and 13 deletions

View File

@ -3,6 +3,7 @@ export const title = "CSS Flexbox";
export const authors = ["Henrique Ramos"]; export const authors = ["Henrique Ramos"];
export const publishedAt = "2025-01-27"; export const publishedAt = "2025-01-27";
export const description = "Do you even flex?"; export const description = "Do you even flex?";
export const draft = true;
--- ---
<section> <section>

View File

@ -6,6 +6,10 @@ type Opts<T extends Record<string, unknown>> = {
schema: type; schema: type;
}; };
const astroPageType = type({
"draft?": "boolean",
});
/** /**
* Get all Astro pages from a given path. * Get all Astro pages from a given path.
* @param opts - The options for the function. * @param opts - The options for the function.
@ -17,10 +21,14 @@ const getAstroPages = <T extends Record<string, unknown> & AstroInstance>({
files, files,
schema, schema,
}: Opts<T>) => }: Opts<T>) =>
Object.values(files).map((module) => { Object.values(files)
const validate = schema(module); .filter(({ draft }) => !draft)
.map((module) => {
const validate = schema.and(astroPageType)(module);
if (validate instanceof type.errors) if (validate instanceof type.errors)
return console.error(`Invalid module${module.file}: ${validate.summary}`); return console.error(
`Invalid module${module.file}: ${validate.summary}`,
);
return { return {
id: ( id: (