diff --git a/src/content.config.ts b/src/content.config.ts
deleted file mode 100644
index 833a358..0000000
--- a/src/content.config.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { defineCollection, z } from "astro:content";
-import { glob } from "astro/loaders"; // Not available with legacy API
-
-const slides = defineCollection({
- loader: glob({ pattern: "**/*.md", base: "./src/slides" }),
- schema: z.object({
- title: z.string(),
- description: z.string(),
- authors: z.array(z.string()),
- publishedAt: z.coerce.date(),
- }),
-});
-
-export const collections = { slides };
diff --git a/src/layouts/SlideLayout.astro b/src/layouts/SlideLayout.astro
index e384d33..da7ce8d 100644
--- a/src/layouts/SlideLayout.astro
+++ b/src/layouts/SlideLayout.astro
@@ -5,7 +5,7 @@ export interface Props {
description?: string;
}
import Layout from "./BaseLayout.astro";
-import "@themes/hnrq.scss";
+import "@theme";
const { title, authors, description } = Astro.props;
---
diff --git a/src/pages/[id].astro b/src/pages/[id].astro
index ff652d6..36745f9 100644
--- a/src/pages/[id].astro
+++ b/src/pages/[id].astro
@@ -1,21 +1,17 @@
---
import SlideLayout from "@layouts/SlideLayout.astro";
-import { getCollection, render } from "astro:content";
+import { getSlides } from "@utils/getSlides";
-export const getStaticPaths = async () =>
- (await getCollection("slides")).map((slide) => ({
- params: { id: slide.id },
- props: { slide },
- }));
+export const getStaticPaths = () =>
+ getSlides().map((slide) => ({ params: { id: slide.id }, props: { slide } }));
const { slide } = Astro.props;
-const { Content } = await render(slide);
---
-
+
diff --git a/src/pages/index.astro b/src/pages/index.astro
index 61e8e35..e11e580 100644
--- a/src/pages/index.astro
+++ b/src/pages/index.astro
@@ -1,10 +1,8 @@
---
import Layout from "@layouts/BaseLayout.astro";
-import { getCollection } from "astro:content";
+import { getSlides } from "@utils/getSlides";
-const slides = (await getCollection("slides")).sort((c1, c2) =>
- c1.data.title > c2.data.title ? -1 : 1
-);
+const slides = getSlides().sort((c1, c2) => (c1.title > c2.title ? -1 : 1));
---
@@ -13,21 +11,21 @@ const slides = (await getCollection("slides")).sort((c1, c2) =>
{
slides.map((slide) => (
- {slide.data.title}
- {slide.data.description}
- {slide.data.publishedAt.toLocaleDateString()}
+ {slide.title}
+ {slide.description}
+ {new Date(slide.publishedAt).toLocaleDateString()}
))
}
-
diff --git a/src/slides/flexbox/index.astro b/src/slides/flexbox/index.astro
new file mode 100644
index 0000000..22f83da
--- /dev/null
+++ b/src/slides/flexbox/index.astro
@@ -0,0 +1,92 @@
+---
+export const title = "CSS Flexbox"
+export const authors = ["Henrique Ramos"]
+export const publishedAt = "2025-01-27"
+export const description = "Do you even flex?"
+---
+
+
+ What is Flexbox?
+
+ - One-dimensional layout model
+ - Distributes space along a single direction
+ - Powerful alignment capabilities
+
+
+
+
+ Basic Flexbox Container
+
+
+.container {'{'}
+ display: flex;
+{'}'}
+
+
+
+
+ justify-content
+
+
+.container {'{'}
+ justify-content: space-between;
+{'}'}
+
+
+
+
+ align-items
+
+
+.container {'{'}
+ align-items: center;
+{'}'}
+
+
+
+
+ flex-direction
+
+
+.container {'{'}
+ flex-direction: column;
+{'}'}
+
+
+
+
+
diff --git a/src/slides/statex-gamedev.md b/src/slides/statex-gamedev/index.astro
similarity index 93%
rename from src/slides/statex-gamedev.md
rename to src/slides/statex-gamedev/index.astro
index 0180462..a32da47 100644
--- a/src/slides/statex-gamedev.md
+++ b/src/slides/statex-gamedev/index.astro
@@ -1,8 +1,8 @@
---
-title: "Finite State Machines with XState for Game Development using Three.js"
-authors: ["Henrique Ramos"]
-publishedAt: 2024-12-13
-description: "Using XState Finite State Machines to coordinate character actions in a Three.js game"
+export const title = "Finite State Machines with XState for Game Development using Three.js"
+export const authors = ["Henrique Ramos"]
+export const publishedAt = "2024-12-13"
+export const description = "Using XState Finite State Machines to coordinate character actions in a Three.js game"
---
diff --git a/src/utils/getAstroPages.ts b/src/utils/getAstroPages.ts
new file mode 100644
index 0000000..27732fc
--- /dev/null
+++ b/src/utils/getAstroPages.ts
@@ -0,0 +1,38 @@
+import type { AstroInstance } from "astro";
+
+type Opts> = {
+ files: Record;
+ requiredFields?: string[];
+};
+
+/**
+ * Get all Astro pages from a given path.
+ * @param opts - The options for the function.
+ * @param opts.files - The files to get the Astro pages from. Use import.meta.glob eager: true.
+ * @param opts.requiredFields - The required fields for the Astro pages.
+ * @returns The Astro pages in the root of the given path, or looks for index.astro files in subdirectories (single level).
+ */
+const getAstroPages = & AstroInstance>({
+ files,
+ requiredFields = [],
+}: Opts) =>
+ Object.values(files).map((module) => {
+ if (!requiredFields.every((field) => module[field as keyof T])) {
+ throw new Error(
+ `Missing required fields for ${module.file}: ${requiredFields
+ .filter((field) => !module[field as keyof T])
+ .join(", ")}`,
+ );
+ }
+
+ return {
+ id: (
+ module.file
+ .split("/")
+ .at(module.file.includes("index.astro") ? -2 : -1) ?? ""
+ ).replace(".astro", ""),
+ ...module,
+ };
+ });
+
+export default getAstroPages;
diff --git a/src/utils/getSlides.ts b/src/utils/getSlides.ts
new file mode 100644
index 0000000..6a583d2
--- /dev/null
+++ b/src/utils/getSlides.ts
@@ -0,0 +1,25 @@
+import type { AstroInstance } from "astro";
+import getAstroPages from "./getAstroPages";
+
+type Slide = AstroInstance & {
+ [key: string]: unknown;
+ title: string;
+ description: string;
+ authors: string[];
+ publishedAt: string;
+};
+
+const slideRequiredFields = ["title", "description", "authors", "publishedAt"];
+
+/**
+ * Get all slides from the slides directory.
+ * @returns The slides.
+ */
+export const getSlides = () =>
+ getAstroPages({
+ files: import.meta.glob(
+ ["@slides/**/index.astro", "@slides/*.astro"],
+ { eager: true },
+ ),
+ requiredFields: slideRequiredFields,
+ });