From 32af9bde3d4db313b9d6bf4a50f6a26dfda0012c Mon Sep 17 00:00:00 2001 From: Henrique Ramos Date: Mon, 3 Feb 2025 11:32:13 -0300 Subject: [PATCH] chore: add draft flag --- src/slides/flexbox/index.astro | 1 + src/utils/getAstroPages.ts | 34 +++++++++++++++++++++------------- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/slides/flexbox/index.astro b/src/slides/flexbox/index.astro index 14ee66c..3c25860 100644 --- a/src/slides/flexbox/index.astro +++ b/src/slides/flexbox/index.astro @@ -3,6 +3,7 @@ export const title = "CSS Flexbox"; export const authors = ["Henrique Ramos"]; export const publishedAt = "2025-01-27"; export const description = "Do you even flex?"; +export const draft = true; ---
diff --git a/src/utils/getAstroPages.ts b/src/utils/getAstroPages.ts index 011114c..74c8783 100644 --- a/src/utils/getAstroPages.ts +++ b/src/utils/getAstroPages.ts @@ -6,6 +6,10 @@ type Opts> = { schema: type; }; +const astroPageType = type({ + "draft?": "boolean", +}); + /** * Get all Astro pages from a given path. * @param opts - The options for the function. @@ -17,19 +21,23 @@ const getAstroPages = & AstroInstance>({ files, schema, }: Opts) => - Object.values(files).map((module) => { - const validate = schema(module); - if (validate instanceof type.errors) - return console.error(`Invalid module${module.file}: ${validate.summary}`); + Object.values(files) + .filter(({ draft }) => !draft) + .map((module) => { + const validate = schema.and(astroPageType)(module); + if (validate instanceof type.errors) + return console.error( + `Invalid module${module.file}: ${validate.summary}`, + ); - return { - id: ( - module.file - .split("/") - .at(module.file.includes("index.astro") ? -2 : -1) ?? "" - ).replace(".astro", ""), - ...module, - }; - }); + return { + id: ( + module.file + .split("/") + .at(module.file.includes("index.astro") ? -2 : -1) ?? "" + ).replace(".astro", ""), + ...module, + }; + }); export default getAstroPages;