Migrate content from markdown to Appwrite database

Remove static markdown file dependencies and update all pages/components to fetch data directly from Appwrite collections, while maintaining existing service functions for data retrieval and adding new CRUD operations for projects.
This commit is contained in:
spaghet committed 2025-08-19 10:59:50 -04:00
1 parent 7e3b5b7a55
commit 03a79e2f79
18 files changed
+1990 -5876

No files matched your search

+2 -2
View File
@@ -18,7 +18,7 @@ function mapAppwriteBlogToCollectionEntry(post: any): BlogCollectionEntry {
return {
id: post.$id,
slug: post.$id, // Using ID as slug since we don't have a proper slug field
body: post.content,
body: post.contentHtml || post.content, // Use converted HTML content
collection: "blog",
data: {
title: post.title,
@@ -26,7 +26,7 @@ function mapAppwriteBlogToCollectionEntry(post: any): BlogCollectionEntry {
date: new Date(post.date),
tags: JSON.parse(post.tags),
draft: post.draft,
content: post.content
content: post.contentHtml || post.content // Use converted HTML content
},
render: async () => {
// This is a minimal implementation for the render function that matches the expected structure
+2 -2
View File
@@ -18,7 +18,7 @@ function mapAppwriteProjectToCollectionEntry(project: any): ProjectCollectionEnt
return {
id: project.$id,
slug: project.$id, // Using ID as slug since we don't have a proper slug field
body: project.content,
body: project.contentHtml || project.content, // Use converted HTML content
collection: "projects",
data: {
title: project.title,
@@ -28,7 +28,7 @@ function mapAppwriteProjectToCollectionEntry(project: any): ProjectCollectionEnt
draft: project.draft,
demoUrl: project.demoUrl,
repoUrl: project.repoUrl,
content: project.content
content: project.contentHtml || project.content // Use converted HTML content
},
render: async () => {
// This is a minimal implementation for the render function that matches the expected structure
+52 -8
View File
@@ -1,18 +1,62 @@
---
import { type CollectionEntry, getCollection } from "astro:content"
import { getBlogPosts, getProjects } from "@lib/appwrite-service"
import PageLayout from "@layouts/PageLayout.astro"
import TopLayout from "@layouts/TopLayout.astro"
import BottomLayout from "@layouts/BottomLayout.astro"
import Search from "@components/Search"
import { SEARCH } from "@consts"
import type { BlogPost, Project } from "@lib/appwrite-service"
const posts = (await getCollection("blog"))
.filter(post => !post.data.draft)
// Get all blog posts and projects from Appwrite
const posts = (await getBlogPosts())
.filter(post => !post.draft)
const projects = (await getCollection("projects"))
.filter(post => !post.data.draft)
const projects = (await getProjects())
.filter(project => !project.draft)
const data = [...posts, ...projects] as CollectionEntry<"blog">[]
// Create unified data array for search - need to convert to proper format expected by Search component
const searchData = [
...posts.map(post => ({
id: post.$id,
slug: post.$id,
body: post.contentHtml || post.content,
collection: "blog",
data: {
title: post.title,
summary: post.summary,
date: new Date(post.date),
tags: post.tags,
draft: post.draft,
content: post.contentHtml || post.content
},
render: async () => ({
Content: () => {},
headings: [],
remarkPluginFrontmatter: {}
})
})),
...projects.map(project => ({
id: project.$id,
slug: project.$id,
body: project.contentHtml || 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.contentHtml || project.content
},
render: async () => ({
Content: () => {},
headings: [],
remarkPluginFrontmatter: {}
})
}))
]
---
<PageLayout title={SEARCH.TITLE} description={SEARCH.DESCRIPTION}>
@@ -23,7 +67,7 @@ const data = [...posts, ...projects] as CollectionEntry<"blog">[]
</TopLayout>
<BottomLayout>
<div class="animate">
<Search client:load data={data}/>
<Search client:load data={searchData}/>
</div>
</BottomLayout>
</PageLayout>
</PageLayout>
+1 -1
View File
@@ -31,7 +31,7 @@ const work = await getWorkExperiences()
})
function formatWorkDate(input: Date | string) {
if (typeof input === "string") return input
if (typeof input === "string") input = new Date(input)
const month = input.toLocaleDateString("en-US", {
month: "short",