+
{summary}
{(demoUrl || repoUrl) &&
diff --git a/src/lib/__tests__/appwrite-service.test.ts b/src/lib/__tests__/appwrite-service.test.ts
new file mode 100644
index 0000000..c691e8d
--- /dev/null
+++ b/src/lib/__tests__/appwrite-service.test.ts
@@ -0,0 +1,175 @@
+import { describe, it, expect, vi } from 'vitest';
+import { getBlogTemplates, createBlogPost, updateBlogPost, deleteBlogPost, createProject, updateProject, deleteProject, createWorkExperience, updateWorkExperience, deleteWorkExperience, createLegalDocument, updateLegalDocument, deleteLegalDocument } from '../appwrite-service';
+
+describe('AppWrite Service', () => {
+ describe('getBlogTemplates', () => {
+ it('should return an array of blog templates', async () => {
+ const templates = await getBlogTemplates();
+
+ expect(Array.isArray(templates)).toBe(true);
+ expect(templates.length).toBeGreaterThan(0);
+
+ // Check that each template has the expected properties
+ templates.forEach(template => {
+ expect(template).toHaveProperty('id');
+ expect(template).toHaveProperty('name');
+ expect(template).toHaveProperty('slug');
+ });
+ });
+
+ it('should return the correct default templates', async () => {
+ const templates = await getBlogTemplates();
+
+ // Should contain default, feature and news templates
+ const templateIds = templates.map(t => t.id);
+ expect(templateIds).toContain('default');
+ expect(templateIds).toContain('feature');
+ expect(templateIds).toContain('news');
+ });
+ });
+
+ describe('createBlogPost', () => {
+ it('should create a new blog post with valid data', async () => {
+ const postData = {
+ title: "Test Blog Post",
+ summary: "Test summary",
+ date: new Date(),
+ tags: ["test", "blog"],
+ draft: false,
+ content: "Test content",
+ template: "default",
+ featured: false
+ };
+
+ // Mock the database call
+ const mockResponse = {
+ $id: "test-id",
+ ...postData
+ };
+
+ // This test would require mocking the databases.createDocument call
+ expect(typeof createBlogPost).toBe('function');
+ });
+ });
+
+ describe('updateBlogPost', () => {
+ it('should update an existing blog post', async () => {
+ const postData = {
+ title: "Updated Blog Post",
+ content: "Updated content"
+ };
+
+ // Mock the database call
+ expect(typeof updateBlogPost).toBe('function');
+ });
+ });
+
+ describe('deleteBlogPost', () => {
+ it('should delete a blog post by ID', async () => {
+ // Mock the database call
+ expect(typeof deleteBlogPost).toBe('function');
+ });
+ });
+
+ describe('createProject', () => {
+ it('should create a new project with valid data', async () => {
+ const projectData = {
+ title: "Test Project",
+ summary: "Test summary",
+ date: new Date(),
+ tags: ["test", "project"],
+ draft: false,
+ content: "Test content",
+ demoUrl: "https://example.com/demo",
+ repoUrl: "https://example.com/repo"
+ };
+
+ // Mock the database call
+ expect(typeof createProject).toBe('function');
+ });
+ });
+
+ describe('updateProject', () => {
+ it('should update an existing project', async () => {
+ const projectData = {
+ title: "Updated Project",
+ content: "Updated content"
+ };
+
+ // Mock the database call
+ expect(typeof updateProject).toBe('function');
+ });
+ });
+
+ describe('deleteProject', () => {
+ it('should delete a project by ID', async () => {
+ // Mock the database call
+ expect(typeof deleteProject).toBe('function');
+ });
+ });
+
+ describe('createWorkExperience', () => {
+ it('should create a new work experience with valid data', async () => {
+ const workData = {
+ company: "Test Company",
+ role: "Test Role",
+ dateStart: new Date(),
+ dateEnd: new Date()
+ };
+
+ // Mock the database call
+ expect(typeof createWorkExperience).toBe('function');
+ });
+ });
+
+ describe('updateWorkExperience', () => {
+ it('should update an existing work experience', async () => {
+ const workData = {
+ company: "Updated Company",
+ role: "Updated Role"
+ };
+
+ // Mock the database call
+ expect(typeof updateWorkExperience).toBe('function');
+ });
+ });
+
+ describe('deleteWorkExperience', () => {
+ it('should delete a work experience by ID', async () => {
+ // Mock the database call
+ expect(typeof deleteWorkExperience).toBe('function');
+ });
+ });
+
+ describe('createLegalDocument', () => {
+ it('should create a new legal document with valid data', async () => {
+ const docData = {
+ title: "Test Legal Document",
+ date: new Date(),
+ content: "Test content"
+ };
+
+ // Mock the database call
+ expect(typeof createLegalDocument).toBe('function');
+ });
+ });
+
+ describe('updateLegalDocument', () => {
+ it('should update an existing legal document', async () => {
+ const docData = {
+ title: "Updated Legal Document",
+ content: "Updated content"
+ };
+
+ // Mock the database call
+ expect(typeof updateLegalDocument).toBe('function');
+ });
+ });
+
+ describe('deleteLegalDocument', () => {
+ it('should delete a legal document by ID', async () => {
+ // Mock the database call
+ expect(typeof deleteLegalDocument).toBe('function');
+ });
+ });
+});
diff --git a/src/lib/appwrite-service.ts b/src/lib/appwrite-service.ts
new file mode 100644
index 0000000..860f9b9
--- /dev/null
+++ b/src/lib/appwrite-service.ts
@@ -0,0 +1,396 @@
+import type { Models, } from "appwrite";
+import { Query } from "appwrite";
+import { databases, } from "./appwrite"; // Import the already initialized databases instances
+import { remark } from "remark";
+import remarkRehype from "remark-rehype";
+import rehypeStringify from "rehype-stringify";
+
+
+// We're using the storage instance from appwrite.ts which is properly initialized
+// This file only contains service functions and types
+
+/**
+ * Convert markdown content to HTML
+ */
+export function convertMarkdownToHTML(markdown: string): string {
+ if (!markdown) return "";
+
+ try {
+ const file = remark()
+ .use(remarkRehype)
+ .use(rehypeStringify)
+ .processSync(markdown);
+
+ return file.toString();
+ } catch (error) {
+ console.error("Error converting markdown to HTML:", error);
+ return markdown; // Return raw markdown if conversion fails
+ }
+}
+
+
+// Types for our collections
+export type BlogPost = Models.Document & {
+ title: string;
+ summary: string;
+ date: Date;
+ tags: string[];
+ draft: boolean;
+ content: string;
+ contentHtml?: string; // HTML version of the content
+ image?: string; // File ID for the featured image
+ template: string; // e.g., "default", "feature", "news"
+ featured: boolean;
+};
+
+
+export type Project = Models.Document & {
+ title: string;
+ summary: string;
+ date: Date;
+ tags: string[];
+ draft: boolean;
+ demoUrl?: string;
+ repoUrl?: string;
+ content: string;
+ contentHtml?: string; // HTML version of the content
+ image?: string; // File ID for the featured image
+};
+
+
+export type WorkExperience = Models.Document & {
+ company: string;
+ role: string;
+ dateStart: Date;
+ content: string;
+ contentHtml?: string; // HTML version of the content
+ dateEnd: Date | string;
+};
+
+export type LegalDocument = Models.Document & {
+ title: string;
+ date: Date;
+ content: string;
+ contentHtml?: string; // HTML version of the content
+};
+
+
+// Define a unified type for search results
+export type SearchEntry = BlogPost | Project;
+
+// Collection IDs - these should be configured based on your Appwrite setup
+
+let blogCollection = '', projectsCollection = '', workCollection = '', legalCollection = '', databaseID = '';
+
+// Check if we're in a server environment (SSR)
+if (typeof window === 'undefined') {
+ // Server-side: use environment variables directly
+ blogCollection = process?.env?.VITE_APPWRITE_BLOG_COLLECTION_ID || 'blog';
+ projectsCollection = process?.env?.VITE_APPWRITE_PROJECTS_COLLECTION_ID || "projects";
+ workCollection = process?.env?.VITE_APPWRITE_WORK_COLLECTION_ID || "work";
+ legalCollection = process?.env?.VITE_APPWRITE_LEGAL_COLLECTION_ID || "legal";
+ databaseID = process.env.VITE_APPWRITE_DATABASE_ID || "main";
+} else {
+ blogCollection = import.meta.env.PUBLIC_APPWRITE_BLOG_COLLECTION_ID || 'blog';
+ projectsCollection = import.meta.env.PUBLIC_APPWRITE_PROJECTS_COLLECTION_ID || "projects";
+ workCollection = import.meta.env.PUBLIC_APPWRITE_WORK_COLLECTION_ID || "work";
+ legalCollection = import.meta.env.PUBLIC_APPWRITE_LEGAL_COLLECTION_ID || "legal";
+ databaseID = import.meta.env.PUBLIC_APPWRITE_DATABASE_ID || "main";
+}
+
+/**
+ * Get blog posts from Appwrite database
+ */
+export async function getBlogPosts(): Promise
{
+ try {
+ const response = await databases.listDocuments(
+ databaseID,
+ blogCollection
+ );
+
+ // Convert markdown content to HTML for each post
+ const postsWithHtml = response.documents.map(post => ({
+ ...post,
+ contentHtml: convertMarkdownToHTML(post.content)
+ }));
+
+ return postsWithHtml;
+ } catch (error) {
+ console.error("Error fetching blog posts:", error);
+ throw new Error("Failed to fetch blog posts");
+ }
+}
+
+
+/**
+ * Get paginated blog posts from Appwrite database
+ */
+export async function getBlogPostsPaginated(page: number, limit: number): Promise<{ posts: BlogPost[], total: number }> {
+ try {
+ // For Appwrite SDK, the correct way to call listDocuments with pagination
+ const response = await databases.listDocuments(
+ databaseID,
+ blogCollection,
+ [
+ // Only fetch published posts (not drafts)
+ Query.equal("draft", false),
+ Query.orderDesc('date')
+ ]
+ );
+
+ // Apply pagination manually since Appwrite SDK might not support offset/limit directly in this version
+ const paginatedPosts = response.documents.slice((page - 1) * limit, page * limit);
+
+ // Convert markdown content to HTML for each post
+ const postsWithHtml = paginatedPosts.map(post => ({
+ ...post,
+ contentHtml: convertMarkdownToHTML(post.content)
+ }));
+
+ return {
+ posts: postsWithHtml,
+ total: response.total
+ };
+ } catch (error) {
+ console.error("Error fetching paginated blog posts:", error);
+ throw new Error("Failed to fetch paginated blog posts");
+ }
+}
+
+
+/**
+ * Get a specific blog post by ID
+ */
+export async function getBlogPostById(id: string): Promise {
+ try {
+ const response = await databases.getDocument(
+ databaseID,
+ blogCollection,
+ id
+ );
+
+ // Convert markdown content to HTML
+ return {
+ ...response,
+ contentHtml: convertMarkdownToHTML(response.content)
+ };
+ } catch (error) {
+ console.error("Error fetching blog post:", error);
+ throw new Error("Failed to fetch blog post");
+ }
+}
+
+/**
+ * Get projects from Appwrite database
+ */
+export async function getProjects(): Promise {
+ try {
+ const response = await databases.listDocuments(
+ databaseID,
+ projectsCollection,
+ [
+ // Only fetch published projects (not drafts)
+ Query.equal("draft", false),
+ Query.orderDesc('date')
+ ]
+ );
+
+ // Convert markdown content to HTML for each project
+ const projectsWithHtml = response.documents.map(project => ({
+ ...project,
+ contentHtml: convertMarkdownToHTML(project.content)
+ }));
+
+ return projectsWithHtml;
+ } catch (error) {
+ console.error("Error fetching projects:", error);
+ throw new Error("Failed to fetch projects");
+ }
+}
+
+
+/**
+ * Get paginated projects from Appwrite database
+ */
+export async function getProjectsPaginated(page: number, limit: number): Promise<{ posts: Project[], total: number }> {
+ try {
+ const response = await databases.listDocuments(
+ databaseID,
+ projectsCollection,
+ [
+ // Only fetch published projects (not drafts)
+ Query.equal("draft", false),
+ Query.orderDesc('date')
+ ]
+ );
+
+ // Apply pagination manually since Appwrite SDK might not support offset/limit directly in this version
+ const paginatedPosts = response.documents.slice((page - 1) * limit, page * limit);
+
+ // Convert markdown content to HTML for each project
+ const projectsWithHtml = paginatedPosts.map(project => ({
+ ...project,
+ contentHtml: convertMarkdownToHTML(project.content)
+ }));
+
+ return {
+ posts: projectsWithHtml,
+ total: response.total
+ };
+ } catch (error) {
+ console.error("Error fetching paginated projects:", error);
+ throw new Error("Failed to fetch paginated projects");
+ }
+}
+
+
+/**
+ * Get a specific project by ID
+ */
+export async function getProjectById(id: string): Promise {
+ try {
+ const response = await databases.getDocument(
+ databaseID,
+ projectsCollection,
+ id
+ );
+
+ // Convert markdown content to HTML
+ return {
+ ...response,
+ contentHtml: convertMarkdownToHTML(response.content)
+ };
+ } catch (error) {
+ console.error("Error fetching project:", error);
+ throw new Error("Failed to fetch project");
+ }
+}
+
+
+/**
+ * Get work experiences from Appwrite database
+ */
+export async function getWorkExperiences(): Promise {
+ try {
+ const response = await databases.listDocuments(
+ databaseID,
+ workCollection
+ );
+
+ // Convert markdown content to HTML for each project
+ return response.documents.map(work => ({
+ ...work,
+ contentHtml: convertMarkdownToHTML(work.content)
+ }));
+ } catch (error) {
+ console.error("Error fetching work experiences:", error);
+ throw new Error("Failed to fetch work experiences");
+ }
+}
+
+/**
+ * Get legal documents from Appwrite database
+ */
+export async function getLegalDocuments(): Promise {
+ try {
+ const response = await databases.listDocuments(
+ databaseID,
+ workCollection
+ );
+
+ return response.documents;
+ } catch (error) {
+ console.error("Error fetching legal documents:", error);
+ throw new Error("Failed to fetch legal documents");
+ }
+}
+
+/**
+ * Perform a search across blog posts and projects using Appwrite SDK
+ */
+export async function searchContent(query: string): Promise<{ posts: BlogPost[], projects: Project[] }> {
+ try {
+ // Search in blog collection for the query term
+ const blogResponse = await databases.listDocuments(
+ databaseID,
+ blogCollection,
+ [
+ Query.and([
+ Query.equal("draft", false),
+ Query.or([
+ Query.search("title", query),
+ Query.search("summary", query),
+ Query.search("content", query)
+ ])
+ ]),
+ Query.orderDesc('date')
+ ]
+ );
+
+ // Search in projects collection for the query term
+ const projectResponse = await databases.listDocuments(
+ databaseID,
+ projectsCollection,
+ [
+ Query.and([
+ Query.equal("draft", false),
+ Query.or([
+ Query.search("title", query),
+ Query.search("summary", query),
+ Query.search("content", query)
+ ])
+ ]),
+ Query.orderDesc('date')
+ ]
+ );
+
+ // Convert markdown content to HTML for blog posts
+ const blogPostsWithHtml = blogResponse.documents.map(post => ({
+ ...post,
+ contentHtml: convertMarkdownToHTML(post.content)
+ }));
+
+ // Convert markdown content to HTML for projects
+ const projectsWithHtml = projectResponse.documents.map(project => ({
+ ...project,
+ contentHtml: convertMarkdownToHTML(project.content)
+ }));
+
+ return {
+ posts: blogPostsWithHtml,
+ projects: projectsWithHtml
+ };
+ } catch (error) {
+ console.error("Error performing search:", error);
+ // More specific error handling for Appwrite errors
+ if (error instanceof Error) {
+ throw new Error(`Search failed: ${error.message}`);
+ }
+ throw new Error("Search failed due to an unknown error");
+ }
+}
+
+// Remove the duplicate function - keep only the original searchContent function
+// The original searchContent function is already correctly implemented and should be used
+
+
+/**
+ * Get a public URL for a file
+ */
+export function getFileUrl(bucketId: string, fileId: string): string {
+ return `${process.env.VITE_APPWRITE_ENDPOINT}/storage/buckets/${bucketId}/files/${fileId}/view?project=${process.env.VITE_APPWRITE_PROJECT_ID}`;
+}
+
+/**
+ * Get a preview URL for a file (thumb or preview)
+ */
+export function getFilePreviewUrl(bucketId: string, fileId: string, type: "thumb" | "preview"): string {
+ return `${process.env.VITE_APPWRITE_ENDPOINT}/storage/buckets/${bucketId}/files/${fileId}/view?project=${process.env.VITE_APPWRITE_PROJECT_ID}&mode=${type}`;
+}
+
+/**
+ * Get a download URL for a file
+ */
+export function getFileDownloadUrl(bucketId: string, fileId: string): string {
+ return `${process.env.VITE_APPWRITE_ENDPOINT}/storage/buckets/${bucketId}/files/${fileId}/download?project=${process.env.VITE_APPWRITE_PROJECT_ID}`;
+}
diff --git a/src/lib/appwrite.ts b/src/lib/appwrite.ts
new file mode 100644
index 0000000..da4a9b8
--- /dev/null
+++ b/src/lib/appwrite.ts
@@ -0,0 +1,32 @@
+import { Client, Databases } from "appwrite";
+
+const client = new Client();
+
+// Check if we're in a server environment (SSR)
+if (typeof window === 'undefined') {
+ // Server-side: use environment variables directly
+ const endpoint = process.env.VITE_APPWRITE_ENDPOINT;
+ const projectId = process.env.VITE_APPWRITE_PROJECT_ID;
+
+ if (!endpoint || !projectId) {
+ throw new Error('Appwrite configuration missing in server environment');
+ }
+
+ client
+ .setEndpoint(endpoint) // Your Appwrite endpoint
+ .setProject(projectId); // Your Project ID
+} else {
+ // Client-side: use import.meta.env (need to prefix with PUBLIC_ for Astro to make them available)
+ const endpoint = import.meta.env.PUBLIC_APPWRITE_ENDPOINT;
+ const projectId = import.meta.env.PUBLIC_APPWRITE_PROJECT_ID;
+
+ if (!endpoint || !projectId) {
+ throw new Error('Appwrite configuration missing in client environment');
+ }
+
+ client
+ .setEndpoint(endpoint) // Your Appwrite endpoint
+ .setProject(projectId); // Your Project ID
+}
+
+export const databases = new Databases(client);
diff --git a/src/lib/utils.ts b/src/lib/utils.ts
index 067d9f6..07c9cb3 100644
--- a/src/lib/utils.ts
+++ b/src/lib/utils.ts
@@ -5,7 +5,8 @@ export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs))
}
-export function formatDate(date: Date) {
+export function formatDate(date: Date | string) {
+ if (typeof date === "string") date = new Date(date)
return Intl.DateTimeFormat("en-US", {
month: "short",
day: "2-digit",
diff --git a/src/pages/api/assets/[fileID].ts b/src/pages/api/assets/[fileID].ts
new file mode 100644
index 0000000..685080c
--- /dev/null
+++ b/src/pages/api/assets/[fileID].ts
@@ -0,0 +1,92 @@
+import { type APIRoute } from 'astro';
+import { getFileUrl, getFilePreviewUrl, getFileDownloadUrl } from '../../../lib/appwrite-service.ts';
+
+export const GET: APIRoute = async ({ params, request }) => {
+ const { fileID } = params;
+
+ // Validate that we have a file ID
+ if (!fileID) {
+ return new Response(
+ JSON.stringify({ error: 'File ID is required' }),
+ { status: 400, headers: { 'Content-Type': 'application/json' } }
+ );
+ }
+
+ try {
+ // Get the bucket ID from environment variables
+ const bucketId = process.env.VITE_APPWRITE_BUCKET_ID;
+
+ if (!bucketId) {
+ return new Response(
+ JSON.stringify({ error: 'Bucket ID is not configured' }),
+ { status: 500, headers: { 'Content-Type': 'application/json' } }
+ );
+ }
+
+ // Parse query parameters for preview type
+ const url = new URL(request.url);
+ const type = url.searchParams.get('type') as "thumb" | "preview" | null;
+
+ let fileUrl: string;
+
+ // Determine the appropriate URL based on query parameter or default to view
+ if (type === 'thumb' || type === 'preview') {
+ fileUrl = getFilePreviewUrl(bucketId, fileID, type);
+ } else {
+ // Default to regular view URL
+ fileUrl = getFileUrl(bucketId, fileID);
+ }
+
+ // Return a redirect response to the file URL
+ return new Response(
+ null,
+ {
+ status: 302,
+ headers: {
+ 'Location': fileUrl
+ }
+ }
+ );
+ } catch (error) {
+ console.error('Error fetching file:', error);
+ return new Response(
+ JSON.stringify({ error: 'Failed to fetch file' }),
+ { status: 500, headers: { 'Content-Type': 'application/json' } }
+ );
+ }
+};
+
+// Handle HEAD requests for preflight checks
+export const HEAD: APIRoute = async ({ params }) => {
+ const { fileID } = params;
+
+ if (!fileID) {
+ return new Response(
+ null,
+ { status: 400 }
+ );
+ }
+
+ try {
+ // Get the bucket ID from environment variables
+ const bucketId = process.env.VITE_APPWRITE_BUCKET_ID;
+
+ if (!bucketId) {
+ return new Response(
+ null,
+ { status: 500 }
+ );
+ }
+
+ // For HEAD requests, we just validate that the file URL can be generated
+ // This is a basic check - in production you might want to actually verify
+ // that the file exists on Appwrite
+ const fileUrl = getFileUrl(bucketId, fileID);
+
+ // Return a successful response (we don't actually need to return anything specific for HEAD)
+ return new Response(null, { status: 200 });
+ } catch (error) {
+ console.error('Error checking file:', error);
+ return new Response(null, { status: 500 });
+ }
+};
diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro
index 2342a5d..f841bda 100644
--- a/src/pages/blog/[...slug].astro
+++ b/src/pages/blog/[...slug].astro
@@ -1,24 +1,27 @@
---
-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 { getBlogPostById } from "@lib/appwrite-service"
-// Create the static blog pages
-export async function getStaticPaths() {
- const posts = await getCollection("blog")
- return posts.map((post) => ({
- params: { slug: post.slug },
- props: post,
- }))
-}
// Get the requested post
-type Props = CollectionEntry<"blog">
-const post = Astro.props
-const { title, summary } = post.data
+const slug = Astro.params.slug || ''
+const post = await getBlogPostById(slug)
+ .then(blogPost => {
+ if (blogPost) {
+ return blogPost;
+ }
+ return null;
+ })
+ .catch(error => {
+ console.error("Error fetching blog post:", error);
+ return null;
+ })
+
+const { title, summary } = post || { title: "Post not found", summary: "" }
---
@@ -32,4 +35,4 @@ const { title, summary } = post.data
-
\ No newline at end of file
+
diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro
index 5076e21..8737eb4 100644
--- a/src/pages/blog/index.astro
+++ b/src/pages/blog/index.astro
@@ -1,16 +1,30 @@
---
-import { getCollection } from "astro:content"
import PageLayout from "@layouts/PageLayout.astro"
import TopLayout from "@layouts/TopLayout.astro"
import BottomLayout from "@layouts/BottomLayout.astro"
import Blog from "@components/Blog"
import { BLOG } from "@consts"
+import { getBlogPosts, getBlogPostsPaginated } from "@lib/appwrite-service"
-const posts = (await getCollection("blog"))
- .filter(post => !post.data.draft)
- .sort((a, b) => b.data.date.getTime() - a.data.date.getTime())
+// Get page and limit from URL parameters
+const url = new URL(typeof window !== 'undefined' ? window.location.href : 'http://localhost')
+const pageParam = url.searchParams.get('page') || '1'
+const limitParam = url.searchParams.get('limit') || '10'
+const page = parseInt(pageParam)
+const limit = parseInt(limitParam)
-const tags = [...new Set(posts.flatMap(post => post.data.tags))]
+// Fetch paginated blog posts
+const { posts, total } = await getBlogPostsPaginated(page, limit)
+ .then(result => {
+ return result;
+ })
+ .catch(error => {
+ console.error("Error fetching blog posts:", error);
+ return { posts: [], total: 0 };
+ })
+
+// Get all tags for filtering
+const tags = [...new Set(posts.flatMap(post => post.tags))]
.sort((a, b) => a.localeCompare(b))
---
@@ -26,5 +40,3 @@ const tags = [...new Set(posts.flatMap(post => post.data.tags))]