Appwrite migration WIP
This commit is contained in:
1 parent
89c5e065de
commit
7e3b5b7a55
18 files changed
+990
-134
No files matched your search
@@ -1,34 +1,34 @@
|
||||
import { formatDate } from "@lib/utils"
|
||||
import type { CollectionEntry } from "astro:content"
|
||||
import type { BlogPost, Project } from "@lib/appwrite-service"
|
||||
|
||||
type Props = {
|
||||
entry: CollectionEntry<"blog"> | CollectionEntry<"projects">
|
||||
entry: BlogPost | Project
|
||||
pill?: boolean
|
||||
}
|
||||
|
||||
export default function ArrowCard({entry, pill}: Props) {
|
||||
return (
|
||||
<a href={`/${entry.collection}/${entry.slug}`} class="group p-4 gap-3 flex items-center border rounded-lg hover:bg-black/5 hover:dark:bg-white/10 border-black/15 dark:border-white/20 transition-colors duration-300 ease-in-out">
|
||||
<a href={`/${entry.$collectionId === 'blog' ? 'blog' : 'projects'}/${entry.$id}`} class="group p-4 gap-3 flex items-center border rounded-lg hover:bg-black/5 hover:dark:bg-white/10 border-black/15 dark:border-white/20 transition-colors duration-300 ease-in-out">
|
||||
<div class="w-full group-hover:text-black group-hover:dark:text-white blend">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
{pill &&
|
||||
<div class="text-sm capitalize px-2 py-0.5 rounded-full border border-black/15 dark:border-white/20 bg-spaghetti-yellow/20 dark:bg-spaghetti-yellow/20 text-spaghetti-brown">
|
||||
{entry.collection === "blog" ? "post" : "project"}
|
||||
{entry.$collectionId === "blog" ? "post" : "project"}
|
||||
</div>
|
||||
}
|
||||
<div class="text-sm uppercase">
|
||||
{formatDate(entry.data.date)}
|
||||
{formatDate(entry.date)}
|
||||
</div>
|
||||
</div>
|
||||
<div class="font-semibold mt-3 text-spaghetti-brown">
|
||||
{entry.data.title}
|
||||
{entry.title}
|
||||
</div>
|
||||
|
||||
<div class="text-sm line-clamp-2 text-spaghetti-brown">
|
||||
{entry.data.summary}
|
||||
{entry.summary}
|
||||
</div>
|
||||
<ul class="flex flex-wrap mt-2 gap-1">
|
||||
{entry.data.tags.map((tag:string) => ( // this line has an error; Parameter 'tag' implicitly has an 'any' type.ts(7006)
|
||||
{entry.tags.map((tag:string) => (
|
||||
<li class="text-xs uppercase py-0.5 px-1 rounded bg-spaghetti-yellow/20 dark:bg-spaghetti-yellow/20 text-spaghetti-brown">
|
||||
{tag}
|
||||
</li>
|
||||
|
||||
@@ -27,7 +27,7 @@ import { storage } from "@lib/appwrite"
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
|
||||
<div class="flex flex-col items-center sm:items-start">
|
||||
<a href="/" class="flex gap-1 w-fit font-semibold text-current hover:text-black dark:hover:text-white transition-colors duration-300 ease-in-out">
|
||||
<img src="/favicon.svg" alt="Logo" class="size-6" />
|
||||
<img src="/api/assets/689d265e0036955a618d" alt="Logo" class="size-6" />
|
||||
{SITE.TITLE}
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
---
|
||||
import { SITE, LINKS } from "@consts"
|
||||
import { cn } from "@lib/utils"
|
||||
import { getFileUrl } from "@lib/appwrite-service";
|
||||
const { pathname } = Astro.url
|
||||
const subpath = pathname.match(/[^/]+/g)
|
||||
import Container from "@components/Container.astro"
|
||||
@@ -11,7 +12,7 @@ import Container from "@components/Container.astro"
|
||||
<div class="relative h-full w-full">
|
||||
<div class="absolute left-0 top-1/2 -translate-y-1/2 flex gap-1 font-semibold">
|
||||
<a href="/" class="flex gap-1 text-current hover:text-spaghetti-brown dark:hover:text-spaghetti-brown transition-colors duration-300 ease-in-out">
|
||||
<img src="/api/image-proxy/689cda7900102e12abf2/689d265e0036955a618d" alt="Logo" class="size-6" />
|
||||
<img src='/api/assets/689d265e0036955a618d' alt="Logo" class="size-6" />
|
||||
<div>
|
||||
{SITE.TITLE}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
import { Client, Databases, Storage } from "appwrite";
|
||||
import type { Models } from "appwrite";
|
||||
import { databases, storage } from "./appwrite"; // Import the already initialized databases and storage instances
|
||||
|
||||
// We're using the storage instance from appwrite.ts which is properly initialized
|
||||
// This file only contains service functions and types
|
||||
|
||||
// Types for our collections
|
||||
export type BlogPost = Models.Document & {
|
||||
title: string;
|
||||
summary: string;
|
||||
date: Date;
|
||||
tags: string[];
|
||||
draft: boolean;
|
||||
content: string;
|
||||
image?: string; // File ID for the featured image
|
||||
};
|
||||
|
||||
export type Project = Models.Document & {
|
||||
title: string;
|
||||
summary: string;
|
||||
date: Date;
|
||||
tags: string[];
|
||||
draft: boolean;
|
||||
demoUrl?: string;
|
||||
repoUrl?: string;
|
||||
content: string;
|
||||
image?: string; // File ID for the featured image
|
||||
};
|
||||
|
||||
export type WorkExperience = Models.Document & {
|
||||
company: string;
|
||||
role: string;
|
||||
dateStart: Date;
|
||||
dateEnd: Date | string;
|
||||
};
|
||||
|
||||
export type LegalDocument = Models.Document & {
|
||||
title: string;
|
||||
date: Date;
|
||||
content: string;
|
||||
};
|
||||
|
||||
// Collection IDs - these should be configured based on your Appwrite setup
|
||||
const BLOG_COLLECTION_ID = process.env.VITE_APPWRITE_BLOG_COLLECTION_ID || "blog";
|
||||
const PROJECTS_COLLECTION_ID = process.env.VITE_APPWRITE_PROJECTS_COLLECTION_ID || "project";
|
||||
const WORK_COLLECTION_ID = process.env.VITE_APPWRITE_WORK_COLLECTION_ID || "work";
|
||||
const LEGAL_COLLECTION_ID = process.env.VITE_APPWRITE_LEGAL_COLLECTION_ID || "legal";
|
||||
|
||||
// Database ID - should be configured based on your Appwrite setup
|
||||
const DATABASE_ID = process.env.VITE_APPWRITE_DATABASE_ID || "main";
|
||||
|
||||
|
||||
/**
|
||||
* Get blog posts from Appwrite database
|
||||
*/
|
||||
export async function getBlogPosts(): Promise<BlogPost[]> {
|
||||
try {
|
||||
const response = await databases.listDocuments<BlogPost>(
|
||||
DATABASE_ID,
|
||||
BLOG_COLLECTION_ID,
|
||||
[
|
||||
// Only fetch published posts (not drafts)
|
||||
// This filter will need to be adjusted based on how you store draft status
|
||||
// For now, we'll fetch all and filter client-side or in Appwrite queries
|
||||
]
|
||||
);
|
||||
|
||||
return response.documents;
|
||||
} catch (error) {
|
||||
console.error("Error fetching blog posts:", error);
|
||||
throw new Error("Failed to fetch blog posts");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific blog post by ID
|
||||
*/
|
||||
export async function getBlogPostById(id: string): Promise<BlogPost> {
|
||||
try {
|
||||
const response = await databases.getDocument<BlogPost>(
|
||||
DATABASE_ID,
|
||||
BLOG_COLLECTION_ID,
|
||||
id
|
||||
);
|
||||
|
||||
return response;
|
||||
} 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<Project[]> {
|
||||
try {
|
||||
const response = await databases.listDocuments<Project>(
|
||||
DATABASE_ID,
|
||||
PROJECTS_COLLECTION_ID,
|
||||
[
|
||||
// Only fetch published projects (not drafts)
|
||||
]
|
||||
);
|
||||
|
||||
return response.documents;
|
||||
} catch (error) {
|
||||
console.error("Error fetching projects:", error);
|
||||
throw new Error("Failed to fetch projects");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific project by ID
|
||||
*/
|
||||
export async function getProjectById(id: string): Promise<Project> {
|
||||
try {
|
||||
const response = await databases.getDocument<Project>(
|
||||
DATABASE_ID,
|
||||
PROJECTS_COLLECTION_ID,
|
||||
id
|
||||
);
|
||||
|
||||
return response;
|
||||
} 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<WorkExperience[]> {
|
||||
try {
|
||||
const response = await databases.listDocuments<WorkExperience>(
|
||||
DATABASE_ID,
|
||||
WORK_COLLECTION_ID
|
||||
);
|
||||
|
||||
return response.documents;
|
||||
} 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<LegalDocument[]> {
|
||||
try {
|
||||
const response = await databases.listDocuments<LegalDocument>(
|
||||
DATABASE_ID,
|
||||
LEGAL_COLLECTION_ID
|
||||
);
|
||||
|
||||
return response.documents;
|
||||
} catch (error) {
|
||||
console.error("Error fetching legal documents:", error);
|
||||
throw new Error("Failed to fetch legal documents");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a specific legal document by ID
|
||||
*/
|
||||
+20
-5
@@ -1,18 +1,33 @@
|
||||
import { Client, Storage } from "appwrite";
|
||||
import { Client, Storage, 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(process.env.APPWRITE_ENDPOINT!) // Your Appwrite endpoint
|
||||
.setProject(process.env.APPWRITE_PROJECT_ID!); // Your Project ID
|
||||
.setEndpoint(endpoint) // Your Appwrite endpoint
|
||||
.setProject(projectId); // Your Project ID
|
||||
} else {
|
||||
// Client-side: use import.meta.env
|
||||
const endpoint = import.meta.env.VITE_APPWRITE_ENDPOINT;
|
||||
const projectId = import.meta.env.VITE_APPWRITE_PROJECT_ID;
|
||||
|
||||
if (!endpoint || !projectId) {
|
||||
throw new Error('Appwrite configuration missing in client environment');
|
||||
}
|
||||
|
||||
client
|
||||
.setEndpoint(import.meta.env.APPWRITE_ENDPOINT) // Your Appwrite endpoint
|
||||
.setProject(import.meta.env.APPWRITE_PROJECT_ID); // Your Project ID
|
||||
.setEndpoint(endpoint) // Your Appwrite endpoint
|
||||
.setProject(projectId); // Your Project ID
|
||||
}
|
||||
|
||||
export const storage = new Storage(client);
|
||||
export const databases = new Databases(client);
|
||||
@@ -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 });
|
||||
}
|
||||
};
|
||||
@@ -1,60 +0,0 @@
|
||||
import type { APIRoute } from "astro";
|
||||
|
||||
export const GET: APIRoute = async ({ params, request }) => {
|
||||
// Get the bucket ID and file ID from the URL parameters
|
||||
const { bucketId, fileId } = params;
|
||||
|
||||
// Validate that we have required parameters
|
||||
if (!bucketId || !fileId) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "Missing bucketId or fileId" }),
|
||||
{ status: 400, headers: { "Content-Type": "application/json" } }
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
// Get the Appwrite endpoint and project ID from environment variables
|
||||
const endpoint = process.env.APPWRITE_ENDPOINT;
|
||||
const projectId = process.env.APPWRITE_PROJECT_ID;
|
||||
|
||||
if (!endpoint || !projectId) {
|
||||
return new Response(
|
||||
JSON.stringify({ error: "Appwrite configuration missing" }),
|
||||
{ status: 500, headers: { "Content-Type": "application/json" } }
|
||||
);
|
||||
}
|
||||
|
||||
// Construct the Appwrite storage URL
|
||||
const appwriteUrl = `${endpoint}/v1/storage/buckets/${bucketId}/files/${fileId}/view?project=${projectId}`;
|
||||
|
||||
// Fetch the image from Appwrite storage
|
||||
const response = await fetch(appwriteUrl, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Accept": "image/*"
|
||||
}
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch image: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
|
||||
// Get the image content type
|
||||
const contentType = response.headers.get("content-type") || "image/jpeg";
|
||||
|
||||
// Return the image with proper headers
|
||||
return new Response(response.body, {
|
||||
status: 200,
|
||||
headers: {
|
||||
"Content-Type": contentType,
|
||||
"Cache-Control": "public, max-age=3600", // Cache for 1 hour
|
||||
}
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error proxying image from Appwrite:", error);
|
||||
return new Response(
|
||||
JSON.stringify({ error: "Failed to fetch image" }),
|
||||
{ status: 500, headers: { "Content-Type": "application/json" } }
|
||||
);
|
||||
}
|
||||
};
|
||||
@@ -1,24 +1,59 @@
|
||||
---
|
||||
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"
|
||||
import type { BlogCollectionEntry } from "@types/appwrite"
|
||||
|
||||
// Create the static blog pages
|
||||
export async function getStaticPaths() {
|
||||
const posts = await getCollection("blog")
|
||||
return posts.map((post) => ({
|
||||
params: { slug: post.slug },
|
||||
props: post,
|
||||
}))
|
||||
// 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.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.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
|
||||
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 mapAppwriteBlogToCollectionEntry(blogPost);
|
||||
}
|
||||
return null;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error fetching blog post:", error);
|
||||
return null;
|
||||
})
|
||||
|
||||
const { title, summary } = post?.data || { title: "Post not found", summary: "" }
|
||||
---
|
||||
|
||||
<PageLayout title={title} description={summary}>
|
||||
@@ -32,4 +67,4 @@ const { title, summary } = post.data
|
||||
<ArticleBottomLayout entry={post} />
|
||||
</div>
|
||||
</BottomLayout>
|
||||
</PageLayout>
|
||||
</PageLayout>
|
||||
@@ -1,16 +1,22 @@
|
||||
---
|
||||
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 } from "@lib/appwrite-service"
|
||||
import type { BlogPost } from "@types/appwrite"
|
||||
|
||||
const posts = (await getCollection("blog"))
|
||||
.filter(post => !post.data.draft)
|
||||
.sort((a, b) => b.data.date.getTime() - a.data.date.getTime())
|
||||
const posts = await getBlogPosts()
|
||||
.then(blogPosts => {
|
||||
return blogPosts;
|
||||
})
|
||||
.catch(error => {
|
||||
console.error("Error fetching blog posts:", error);
|
||||
return [];
|
||||
})
|
||||
|
||||
const tags = [...new Set(posts.flatMap(post => post.data.tags))]
|
||||
const tags = [...new Set(posts.flatMap(post => post.tags))]
|
||||
.sort((a, b) => a.localeCompare(b))
|
||||
---
|
||||
|
||||
@@ -26,5 +32,3 @@ const tags = [...new Set(posts.flatMap(post => post.data.tags))]
|
||||
</div>
|
||||
</BottomLayout>
|
||||
</PageLayout>
|
||||
|
||||
|
||||
+14
-12
@@ -1,5 +1,5 @@
|
||||
---
|
||||
import { getCollection } from "astro:content"
|
||||
import { getBlogPosts, getProjects } from "@lib/appwrite-service";
|
||||
import PageLayout from "@layouts/PageLayout.astro"
|
||||
import ArrowCard from "@components/ArrowCard"
|
||||
import StackCard from "@components/StackCard.astro"
|
||||
@@ -7,14 +7,15 @@ import { SITE, SOCIALS } from "@consts"
|
||||
import TwinklingStars from "@components/TwinklingStars.astro"
|
||||
import MeteorShower from "@components/MeteorShower.astro"
|
||||
|
||||
const posts = (await getCollection("blog"))
|
||||
.filter(post => !post.data.draft)
|
||||
.sort((a, b) => b.data.date.getTime() - a.data.date.getTime())
|
||||
// Fetch blog posts and projects from Appwrite
|
||||
const posts = (await getBlogPosts())
|
||||
.filter(post => !post.draft)
|
||||
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
|
||||
.slice(0,3)
|
||||
|
||||
const projects = (await getCollection("projects"))
|
||||
.filter(project => !project.data.draft)
|
||||
.sort((a, b) => b.data.date.getTime() - a.data.date.getTime())
|
||||
const projects = (await getProjects())
|
||||
.filter(project => !project.draft)
|
||||
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime())
|
||||
.slice(0,3)
|
||||
|
||||
const stack = [
|
||||
@@ -57,7 +58,7 @@ const stack = [
|
||||
<div id='stars3' class='fixed inset-0'></div>
|
||||
</div>
|
||||
|
||||
<!-- Dark Theme: Twinkling Stars / Metors -->
|
||||
<!-- Dark Theme: Twinkling Stars / Meteor Shower -->
|
||||
<div id="galaxy" class="fixed inset-0">
|
||||
<div class="hidden dark:block">
|
||||
<TwinklingStars/>
|
||||
@@ -79,7 +80,7 @@ const stack = [
|
||||
<div class="animate absolute h-full w-full flex items-center justify-center">
|
||||
<div class='relative w-full h-full flex items-center justify-center'>
|
||||
<div class='p-5 text-center'>
|
||||
<img src="/api/image-proxy/689cda7900102e12abf2/689d27a400194d326f69" alt="Quinn Marvin" class="rounded-full w-32 h-32 mx-auto mb-4 border-4 border-spaghetti-red" />
|
||||
<img src='/api/assets/689d27a400194d326f69' alt="Quinn Marvin" class="rounded-full w-32 h-32 mx-auto mb-4 border-4 border-spaghetti-red" />
|
||||
<p class='animated text-lg md:text-xl lg:text-2xl font-semibold opacity-75 text-spaghetti-brown'>
|
||||
Hello, I am Quinn Marvin
|
||||
</p>
|
||||
@@ -96,7 +97,7 @@ const stack = [
|
||||
Supporting PostgreSQL, MariaDB, MySQL, MongoDB, Redis, and Minio
|
||||
</p>
|
||||
<div id="ctaButtons" class='animated flex flex-wrap gap-4 justify-center mt-5'>
|
||||
<a href='/blog' class='py-2 px-4 rounded truncate text-xs md:text-sm lg:text-base bg-spaghetti-red dark:bg-spaghetti-red text-white dark:text-white hover:opacity-75 blend'>
|
||||
<a href='/blog' class='py-2 px-4 rounded truncate text-xs md:text-sm lg:text-base bg-spaghetti-red dark:bg-spaghetti-red text-spaghetti-brown dark:text-spaghetti-brown hover:opacity-75 blend'>
|
||||
Read my blog
|
||||
</a>
|
||||
<a href='/work' class='py-2 px-4 truncate rounded text-xs md:text-sm lg:text-base border border-spaghetti-yellow/50 dark:border-spaghetti-yellow/50 hover:bg-spaghetti-yellow/20 hover:dark:bg-spaghetti-yellow/20 blend text-spaghetti-brown dark:text-spaghetti-brown'>
|
||||
@@ -153,7 +154,7 @@ const stack = [
|
||||
Website build with
|
||||
</p>
|
||||
<div class="flex flex-wrap items-center gap-2 mt-5">
|
||||
{stack.map(item => (
|
||||
{stack.map((item) => (
|
||||
<StackCard
|
||||
text={item.text}
|
||||
icon={item.icon}
|
||||
@@ -205,7 +206,7 @@ const stack = [
|
||||
Reach out to me via email or on social media.
|
||||
</p>
|
||||
<div class="grid grid-cols-4 gap-y-2 mt-4 auto-cols-min">
|
||||
{SOCIALS.map(social => (
|
||||
{SOCIALS.map((social) => (
|
||||
<div class="col-span-1 flex items-center gap-1">
|
||||
<span class="whitespace-nowrap truncate">
|
||||
{social.NAME}
|
||||
@@ -219,6 +220,7 @@ const stack = [
|
||||
</a>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
@@ -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: "" }
|
||||
---
|
||||
|
||||
<PageLayout title={title} description={summary}>
|
||||
<TopLayout>
|
||||
<div class="animate">
|
||||
<ArticleTopLayout entry={project} />
|
||||
<ArticleTopLayout entry={project}/>
|
||||
</div>
|
||||
</TopLayout>
|
||||
<BottomLayout>
|
||||
@@ -32,4 +69,4 @@ const { title, summary } = project.data
|
||||
<ArticleBottomLayout entry={project} />
|
||||
</div>
|
||||
</BottomLayout>
|
||||
</PageLayout>
|
||||
</PageLayout>
|
||||
@@ -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))
|
||||
|
||||
+25
-10
@@ -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}
|
||||
</div>
|
||||
<article class="prose dark:prose-invert">
|
||||
<entry.Content />
|
||||
{entry.body}
|
||||
</article>
|
||||
</li>
|
||||
))
|
||||
}
|
||||
</ul>
|
||||
|
||||
</BottomLayout>
|
||||
</PageLayout>
|
||||
@@ -0,0 +1,81 @@
|
||||
import type { Models } from "appwrite";
|
||||
import type { CollectionEntry } from "astro:content";
|
||||
|
||||
// Types for our collections that match Appwrite document structure
|
||||
export type BlogPost = Models.Document & {
|
||||
title: string;
|
||||
summary: string;
|
||||
date: Date;
|
||||
tags: string[];
|
||||
draft: boolean;
|
||||
content: string;
|
||||
image?: string; // File ID for the featured image
|
||||
};
|
||||
|
||||
export type Project = Models.Document & {
|
||||
title: string;
|
||||
summary: string;
|
||||
date: Date;
|
||||
tags: string[];
|
||||
draft: boolean;
|
||||
demoUrl?: string;
|
||||
repoUrl?: string;
|
||||
content: string;
|
||||
image?: string; // File ID for the featured image
|
||||
};
|
||||
|
||||
export type WorkExperience = Models.Document & {
|
||||
company: string;
|
||||
role: string;
|
||||
dateStart: Date;
|
||||
dateEnd: Date | string;
|
||||
};
|
||||
|
||||
export type LegalDocument = Models.Document & {
|
||||
title: string;
|
||||
date: Date;
|
||||
content: string;
|
||||
};
|
||||
|
||||
// Define the proper CollectionEntry format for blog and projects
|
||||
export type BlogCollectionEntry = CollectionEntry<"blog"> & {
|
||||
id: string;
|
||||
slug: string;
|
||||
body: string;
|
||||
collection: "blog";
|
||||
data: {
|
||||
title: string;
|
||||
summary: string;
|
||||
date: Date;
|
||||
tags: string[];
|
||||
draft: boolean;
|
||||
content: string;
|
||||
};
|
||||
render: () => Promise<{
|
||||
Content: () => any;
|
||||
headings: any[];
|
||||
remarkPluginFrontmatter: any;
|
||||
}>;
|
||||
};
|
||||
|
||||
export type ProjectCollectionEntry = CollectionEntry<"projects"> & {
|
||||
id: string;
|
||||
slug: string;
|
||||
body: string;
|
||||
collection: "projects";
|
||||
data: {
|
||||
title: string;
|
||||
summary: string;
|
||||
date: Date;
|
||||
tags: string[];
|
||||
draft: boolean;
|
||||
demoUrl?: string;
|
||||
repoUrl?: string;
|
||||
content: string;
|
||||
};
|
||||
render: () => Promise<{
|
||||
Content: () => any;
|
||||
headings: any[];
|
||||
remarkPluginFrontmatter: any;
|
||||
}>;
|
||||
};
|
||||
Reference in new issue
Block a user