-

+
Hello, I am Quinn Marvin
@@ -96,7 +97,7 @@ const stack = [
Supporting PostgreSQL, MariaDB, MySQL, MongoDB, Redis, and Minio
diff --git a/src/pages/projects/[...slug].astro b/src/pages/projects/[...slug].astro
index c2a53e9..cebcc9a 100644
--- a/src/pages/projects/[...slug].astro
+++ b/src/pages/projects/[...slug].astro
@@ -1,30 +1,67 @@
---
-import { type CollectionEntry, getCollection } from "astro:content"
import PageLayout from "@layouts/PageLayout.astro"
import TopLayout from "@layouts/TopLayout.astro"
import BottomLayout from "@layouts/BottomLayout.astro"
import ArticleTopLayout from "@layouts/ArticleTopLayout.astro"
import ArticleBottomLayout from "@layouts/ArticleBottomLayout.astro"
+import { getProjectById } from "@lib/appwrite-service"
+import type { ProjectCollectionEntry } from "@types/appwrite"
// Create the static projects pages
export async function getStaticPaths() {
- const projects = await getCollection("projects")
- return projects.map((project) => ({
- params: { slug: project.slug },
- props: project,
- }))
+ // This will be replaced with Appwrite data in the future
+ return []
+}
+
+// Helper function to map Appwrite document to CollectionEntry format
+function mapAppwriteProjectToCollectionEntry(project: any): ProjectCollectionEntry {
+ return {
+ id: project.$id,
+ slug: project.$id, // Using ID as slug since we don't have a proper slug field
+ body: project.content,
+ collection: "projects",
+ data: {
+ title: project.title,
+ summary: project.summary,
+ date: new Date(project.date),
+ tags: project.tags,
+ draft: project.draft,
+ demoUrl: project.demoUrl,
+ repoUrl: project.repoUrl,
+ content: project.content
+ },
+ render: async () => {
+ // This is a minimal implementation for the render function that matches the expected structure
+ return {
+ Content: () => {},
+ headings: [],
+ remarkPluginFrontmatter: {}
+ };
+ }
+ };
}
// Get the requested project
-type Props = CollectionEntry<"projects">
-const project = Astro.props
-const { title, summary } = project.data
+const slug = Astro.params.slug
+const project = await getProjectById(slug)
+ .then(projectData => {
+ if (projectData) {
+ return mapAppwriteProjectToCollectionEntry(projectData);
+ }
+ return null;
+ })
+ .catch(error => {
+ console.error("Error fetching project:", error);
+ return null;
+ })
+
+const { title, summary } = project?.data || { title: "Project not found", summary: "" }
---
@@ -32,4 +69,4 @@ const { title, summary } = project.data
-
\ No newline at end of file
+
diff --git a/src/pages/projects/index.astro b/src/pages/projects/index.astro
index de671cf..deff56d 100644
--- a/src/pages/projects/index.astro
+++ b/src/pages/projects/index.astro
@@ -1,14 +1,39 @@
---
-import { getCollection } from "astro:content"
import PageLayout from "@layouts/PageLayout.astro"
import TopLayout from "@layouts/TopLayout.astro"
import BottomLayout from "@layouts/BottomLayout.astro"
import Projects from "@components/Projects"
import { PROJECTS } from "@consts"
+import { getProjects } from "@lib/appwrite-service"
+import type { Project } from "@types/appwrite"
-const projects = (await getCollection("projects"))
- .filter(project => !project.data.draft)
- .sort((a, b) => b.data.date.getTime() - a.data.date.getTime())
+// Helper function to map Appwrite project document to CollectionEntry format
+function mapAppwriteProjectToCollectionEntry(project: Project) {
+ return {
+ $id: project.$id,
+ $collectionId: "projects",
+ data: {
+ title: project.title,
+ summary: project.summary,
+ date: new Date(project.date),
+ tags: project.tags,
+ draft: project.draft,
+ demoUrl: project.demoUrl,
+ repoUrl: project.repoUrl,
+ content: project.content,
+ image: project.image
+ }
+ };
+}
+
+const projects = await getProjects()
+ .then(projectList => {
+ return projectList.map(project => mapAppwriteProjectToCollectionEntry(project));
+ })
+ .catch(error => {
+ console.error("Error fetching projects:", error);
+ return [];
+ })
const tags = [...new Set(projects.flatMap(project => project.data.tags))]
.sort((a, b) => a.localeCompare(b))
diff --git a/src/pages/work/index.astro b/src/pages/work/index.astro
index c645d98..74ca571 100644
--- a/src/pages/work/index.astro
+++ b/src/pages/work/index.astro
@@ -1,20 +1,34 @@
---
-import { getCollection } from "astro:content"
import PageLayout from "@layouts/PageLayout.astro"
import TopLayout from "@layouts/TopLayout.astro"
import BottomLayout from "@layouts/BottomLayout.astro"
import { WORK } from "@consts"
+import { getWorkExperiences } from "@lib/appwrite-service"
-const collection = await getCollection("work")
+// Helper function to map Appwrite document to compatible format for work page
+function mapAppwriteWorkToEntry(work: any) {
+ return {
+ id: work.$id,
+ slug: work.$id, // Using ID as slug since we don't have a proper slug field
+ data: {
+ company: work.company,
+ role: work.role,
+ dateStart: new Date(work.dateStart),
+ dateEnd: work.dateEnd,
+ content: work.content // This will be rendered in the component
+ },
+ body: work.content
+ };
+}
-collection.sort((a, b) => new Date(b.data.dateStart).getTime() - new Date(a.data.dateStart).getTime())
-
-const work = await Promise.all(
- collection.map(async (item) => {
- const { Content } = await item.render()
- return { ...item, Content }
+const work = await getWorkExperiences()
+ .then(workList => {
+ return workList.map(mapAppwriteWorkToEntry);
+ })
+ .catch(error => {
+ console.error("Error fetching work experiences:", error);
+ return [];
})
-)
function formatWorkDate(input: Date | string) {
if (typeof input === "string") return input
@@ -49,11 +63,12 @@ function formatWorkDate(input: Date | string) {
{entry.data.role}