Refactor layouts to use Appwrite data types and implement search/pagination features

This commit is contained in:
spaghet committed 2025-08-21 13:50:56 -04:00
1 parent 03a79e2f79
commit 7997eccb12
15 files changed
+504 -257

No files matched your search

+3 -35
View File
@@ -5,46 +5,14 @@ import BottomLayout from "@layouts/BottomLayout.astro"
import ArticleTopLayout from "@layouts/ArticleTopLayout.astro"
import ArticleBottomLayout from "@layouts/ArticleBottomLayout.astro"
import { getBlogPostById } from "@lib/appwrite-service"
import type { BlogCollectionEntry } from "@types/appwrite"
// Create the static blog pages
export async function getStaticPaths() {
// This will be replaced with Appwrite data in the future
return []
}
// Helper function to map Appwrite document to CollectionEntry format
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.contentHtml || post.content, // Use converted HTML content
collection: "blog",
data: {
title: post.title,
summary: post.summary,
date: new Date(post.date),
tags: JSON.parse(post.tags),
draft: post.draft,
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
return {
Content: () => {},
headings: [],
remarkPluginFrontmatter: {}
};
}
};
}
// Get the requested post
const slug = Astro.params.slug
const slug = Astro.params.slug || ''
const post = await getBlogPostById(slug)
.then(blogPost => {
if (blogPost) {
return mapAppwriteBlogToCollectionEntry(blogPost);
return blogPost;
}
return null;
})
@@ -53,7 +21,7 @@ const post = await getBlogPostById(slug)
return null;
})
const { title, summary } = post?.data || { title: "Post not found", summary: "" }
const { title, summary } = post || { title: "Post not found", summary: "" }
---
<PageLayout title={title} description={summary}>