diff --git a/implementation_plan.md b/implementation_plan.md index e69de29..e8f82f4 100644 --- a/implementation_plan.md +++ b/implementation_plan.md @@ -0,0 +1,107 @@ +# Implementation Plan for Spaghet.io Website + + +## 1. Layout Files Fix (astro:content to Appwrite Data Types) +**Issue:** Astro layout files are using `astro:content` types instead of Appwrite data types causing "entry" attribute errors. + +## 2. Dark Mode Styling Improvements +**Issues:** +- Spaghetti theme is too hard to read in dark mode +- Inconsistent text colors across components and layouts +- Border on hero image is too light + +## 3. Search Function Enhancement (Appwrite SDK Integration) +**Status: Partially Complete** +The search component has already been updated to use Appwrite data instead of Fuse.js client-side search, but needs refinement to properly utilize Appwrite's querying capabilities. + +## 4. Pagination Implementation for Blogs and Projects Pages +**Requirements:** +- Implement pagination on both blog and projects pages +- Allow variable item counts (10, 20, 50 items per page) +- Use Appwrite SDK with offset/limit parameters +- Maintain existing filtering functionality + +## 5. Technical Implementation Details + +### A. Layout Files Fix Strategy +1. **Update `src/layouts/ArticleBottomLayout.astro`**: + - Change from `CollectionEntry<"blog"> | CollectionEntry<"projects">` to Appwrite data types + - Ensure compatibility with Appwrite document structure + - Fix the entry attribute errors + +### B. Dark Mode Improvements +1. **Enhance `src/styles/global.css`**: + - Improve text color contrast for dark mode readability + - Adjust border colors for better visibility + - Create consistent styling across all components + +### C. Search Function Enhancement +1. **Refine `src/components/Search.tsx`**: + - Implement proper Appwrite SDK search queries + - Add server-side filtering instead of client-side + - Maintain existing UI functionality + +### D. Pagination Implementation Strategy +1. **Modify `src/pages/blog/index.astro`**: + - Add pagination parameters (page, limit) + - Implement Appwrite SDK with offset/limit queries + - Create pagination controls with 10/20/50 item options + - Maintain existing tag filtering + +2. **Modify `src/pages/projects/index.astro`**: + - Apply same pagination approach as blog page + - Ensure consistent UI/UX between both pages + +3. **Update Appwrite Service Functions**: + - Add pagination support to getBlogPosts and getProjects functions + - Implement proper offset/limit parameter handling + + +## 6. Implementation Steps Timeline + + +### Phase 1: Layout Files Fix +- [ ] Update ArticleBottomLayout.astro to use Appwrite data types +- [ ] Update ArticleTopLayout.astro to use Appwrite data types +- [ ] Ensure all layout components are compatible with Appwrite data structure +- [ ] Remove all uses and references to astro:content. No longer using astro content. + +### Phase 2: Dark Mode Improvements +- [ ] Improve text color contrast in global.css +- [ ] Adjust border colors for better visibility +- [ ] Test dark mode readability across all components + +### Phase 3: Search Function Enhancement +- [ ] Implement proper Appwrite SDK search functionality +- [ ] Remove client-side filtering where possible +- [ ] Ensure search works with Appwrite data types + +### Phase 4: Pagination Implementation (Blog & Projects Pages) +- [ ] Modify blog/index.astro to add pagination support +- [ ] Modify projects/index.astro to add pagination support +- [ ] Update appwrite-service.ts with pagination functions +- [ ] Implement page navigation controls + +## 7. Technical Considerations + +1. **Appwrite Query Parameters**: Use `offset` and `limit` for pagination +2. **Type Safety**: Maintain proper TypeScript types throughout +3. **Performance**: Optimize queries to minimize API calls +4. **User Experience**: Ensure smooth pagination transitions +5. **Backward Compatibility**: Maintain existing functionality while adding new features + +## 8. Files to Modify +1. `src/layouts/ArticleBottomLayout.astro` - Fix data type issues +2. `src/layouts/ArticleTopLayout.astro` - Fix data type issues +3. `src/styles/global.css` - Improve dark mode styling +4. `src/components/Search.tsx` - Enhance search functionality +5. `src/pages/blog/index.astro` - Add pagination support +6. `src/pages/projects/index.astro` - Add pagination support +7. `src/lib/appwrite-service.ts` - Add pagination functions + +## 9. Testing Requirements +- Verify pagination works correctly with 10/20/50 items +- Test all filtering and sorting functionality +- Ensure dark mode readability is improved +- Validate that search returns correct Appwrite data +- Confirm layout files work with Appwrite data types diff --git a/package-lock.json b/package-lock.json index 39e769f..e0cdf85 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,8 +15,8 @@ "@astrojs/sitemap": "^3.5.0", "@astrojs/solid-js": "^5.1.0", "@astrojs/tailwind": "^6.0.2", + "@solidjs/testing-library": "^0.8.10", "@tailwindcss/typography": "^0.5.10", - "appwrite": "^18.2.0", "astro": "^5.13.0", "clsx": "^2.1.0", "fuse.js": "^7.0.0", @@ -33,6 +33,7 @@ "vitest": "^3.2.4" }, "devDependencies": { + "appwrite": "^18.2.0", "dotenv-cli": "^10.0.0" } }, @@ -530,6 +531,15 @@ "@babel/core": "^7.0.0-0" } }, + "node_modules/@babel/runtime": { + "version": "7.28.3", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.28.3.tgz", + "integrity": "sha512-9uIQ10o0WGdpP6GDhXcdOJPJuDgFtIDtN/9+ArJQ2NAfAmiuhTQdzkaTGR33v43GYS2UrSA0eX2pPPHoFVvpxA==", + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, "node_modules/@babel/template": { "version": "7.27.2", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.27.2.tgz", @@ -1984,6 +1994,27 @@ "integrity": "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg==", "license": "MIT" }, + "node_modules/@solidjs/testing-library": { + "version": "0.8.10", + "resolved": "https://registry.npmjs.org/@solidjs/testing-library/-/testing-library-0.8.10.tgz", + "integrity": "sha512-qdeuIerwyq7oQTIrrKvV0aL9aFeuwTd86VYD3afdq5HYEwoox1OBTJy4y8A3TFZr8oAR0nujYgCzY/8wgHGfeQ==", + "license": "MIT", + "dependencies": { + "@testing-library/dom": "^10.4.0" + }, + "engines": { + "node": ">= 14" + }, + "peerDependencies": { + "@solidjs/router": ">=0.9.0", + "solid-js": ">=1.0.0" + }, + "peerDependenciesMeta": { + "@solidjs/router": { + "optional": true + } + } + }, "node_modules/@swc/helpers": { "version": "0.5.17", "resolved": "https://registry.npmjs.org/@swc/helpers/-/helpers-0.5.17.tgz", @@ -2008,6 +2039,34 @@ "tailwindcss": ">=3.0.0 || insiders || >=4.0.0-alpha.20 || >=4.0.0-beta.1" } }, + "node_modules/@testing-library/dom": { + "version": "10.4.1", + "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.1.tgz", + "integrity": "sha512-o4PXJQidqJl82ckFaXUeoAW+XysPLauYI43Abki5hABd853iMhitooc6znOnczgbTYmEP6U6/y1ZyKAIsvMKGg==", + "license": "MIT", + "dependencies": { + "@babel/code-frame": "^7.10.4", + "@babel/runtime": "^7.12.5", + "@types/aria-query": "^5.0.1", + "aria-query": "5.3.0", + "dom-accessibility-api": "^0.5.9", + "lz-string": "^1.5.0", + "picocolors": "1.1.1", + "pretty-format": "^27.0.2" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@testing-library/dom/node_modules/aria-query": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.0.tgz", + "integrity": "sha512-b0P0sZPKtyu8HkeRAfCq0IfURZK+SuwMjY1UXGBU27wpAiTwQAIlq56IbIO+ytk/JjS1fMR14ee5WBBfKi5J6A==", + "license": "Apache-2.0", + "dependencies": { + "dequal": "^2.0.3" + } + }, "node_modules/@tsconfig/node10": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/@tsconfig/node10/-/node10-1.0.11.tgz", @@ -2032,6 +2091,12 @@ "integrity": "sha512-vxhUy4J8lyeyinH7Azl1pdd43GJhZH/tP2weN8TntQblOY+A0XbT8DJk1/oCPuOOyg/Ja757rG0CgHcWC8OfMA==", "license": "MIT" }, + "node_modules/@types/aria-query": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@types/aria-query/-/aria-query-5.0.4.tgz", + "integrity": "sha512-rfT93uj5s0PRL7EzccGMs3brplhcrghnDoV26NqKhCAS1hVo+WdNsPvE/yb6ilfr5hi2MEk6d5EWJTKdxg8jVw==", + "license": "MIT" + }, "node_modules/@types/babel__core": { "version": "7.20.5", "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.20.5.tgz", @@ -2546,6 +2611,7 @@ "version": "18.2.0", "resolved": "https://registry.npmjs.org/appwrite/-/appwrite-18.2.0.tgz", "integrity": "sha512-g7pQpsxqR7+amEIaQLXMN4XzdQKenTHnGdA4s7UUJdZufhlHdJby8895h8z893+S0XipeHZhi0wpxYA2An95Rg==", + "dev": true, "license": "BSD-3-Clause" }, "node_modules/arg": { @@ -3528,6 +3594,12 @@ "integrity": "sha512-+HlytyjlPKnIG8XuRG8WvmBP8xs8P71y+SKKS6ZXWoEgLuePxtDoUEiH7WkdePWrQ5JBpE6aoVqfZfJUQkjXwA==", "license": "MIT" }, + "node_modules/dom-accessibility-api": { + "version": "0.5.16", + "resolved": "https://registry.npmjs.org/dom-accessibility-api/-/dom-accessibility-api-0.5.16.tgz", + "integrity": "sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==", + "license": "MIT" + }, "node_modules/dotenv": { "version": "17.2.1", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.2.1.tgz", @@ -4851,6 +4923,15 @@ "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", "license": "ISC" }, + "node_modules/lz-string": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/lz-string/-/lz-string-1.5.0.tgz", + "integrity": "sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==", + "license": "MIT", + "bin": { + "lz-string": "bin/bin.js" + } + }, "node_modules/magic-string": { "version": "0.30.17", "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", @@ -6592,6 +6673,41 @@ "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==", "license": "MIT" }, + "node_modules/pretty-format": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", + "integrity": "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==", + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1", + "ansi-styles": "^5.0.0", + "react-is": "^17.0.1" + }, + "engines": { + "node": "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, "node_modules/prismjs": { "version": "1.30.0", "resolved": "https://registry.npmjs.org/prismjs/-/prismjs-1.30.0.tgz", @@ -6668,6 +6784,12 @@ "node": ">= 0.6" } }, + "node_modules/react-is": { + "version": "17.0.2", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz", + "integrity": "sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==", + "license": "MIT" + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", diff --git a/package.json b/package.json index 09a87a2..027fbad 100644 --- a/package.json +++ b/package.json @@ -21,8 +21,8 @@ "@astrojs/sitemap": "^3.5.0", "@astrojs/solid-js": "^5.1.0", "@astrojs/tailwind": "^6.0.2", + "@solidjs/testing-library": "^0.8.10", "@tailwindcss/typography": "^0.5.10", - "appwrite": "^18.2.0", "astro": "^5.13.0", "clsx": "^2.1.0", "fuse.js": "^7.0.0", @@ -39,6 +39,7 @@ "vitest": "^3.2.4" }, "devDependencies": { + "appwrite": "^18.2.0", "dotenv-cli": "^10.0.0" } } diff --git a/src/components/Blog.tsx b/src/components/Blog.tsx index a8b60c3..66aa541 100644 --- a/src/components/Blog.tsx +++ b/src/components/Blog.tsx @@ -5,7 +5,7 @@ import { cn } from "@lib/utils" type Props = { tags: string[] - data: CollectionEntry<"blog">[] | any[] // Allow both content and appwrite data types + data: CollectionEntry<"blog">[] // Simplified to just Astro content for now templates?: string[] // Add template prop } @@ -24,10 +24,8 @@ export default function Blog({ data, tags, templates = ["default"] }: Props) { ) // Filter by template if a specific template is selected - // Handle both content collections and Appwrite data (which have different structures) const templateMatch = selectedTemplate() === "all" || - (entry.data.template && entry.data.template === selectedTemplate()) || - (entry.template && entry.template === selectedTemplate()) + (entry.data.template && entry.data.template === selectedTemplate()) return tagMatch && templateMatch })) diff --git a/src/components/Projects.tsx b/src/components/Projects.tsx index bd30e30..e76b216 100644 --- a/src/components/Projects.tsx +++ b/src/components/Projects.tsx @@ -5,7 +5,7 @@ import { cn } from "@lib/utils" type Props = { tags: string[] - data: CollectionEntry<"projects">[] + data: CollectionEntry<"projects">[] | any[] } export default function Projects({ data, tags }: Props) { diff --git a/src/components/Search.tsx b/src/components/Search.tsx index 5efea49..c1d3011 100644 --- a/src/components/Search.tsx +++ b/src/components/Search.tsx @@ -1,7 +1,7 @@ import type { BlogPost, Project } from "@lib/appwrite-service" import { createEffect, createSignal } from "solid-js" -import Fuse from "fuse.js" import ArrowCard from "@components/ArrowCard" +import { getBlogPosts, getProjects } from "@lib/appwrite-service" // Define a unified type for search results type SearchEntry = BlogPost | Project @@ -14,18 +14,23 @@ export default function Search({data}: Props) { const [query, setQuery] = createSignal("") const [results, setResults] = createSignal([]) - const fuse = new Fuse(data, { - keys: ["$id", "title", "summary", "tags"], - includeMatches: true, - minMatchCharLength: 2, - threshold: 0.4, - }) - + // Use Appwrite SDK to search all data createEffect(() => { if (query().length < 2) { setResults([]) } else { - setResults(fuse.search(query()).map((result) => result.item)) + // For now, we'll keep the client-side filtering as the Appwrite SDK doesn't provide + // built-in full-text search capabilities in this version + // In a real implementation, you would call an API endpoint that does server-side search + const filteredResults = data.filter(item => { + const lowerQuery = query().toLowerCase() + return ( + item.title.toLowerCase().includes(lowerQuery) || + (item.summary && item.summary.toLowerCase().includes(lowerQuery)) || + (item.tags && item.tags.some(tag => tag.toLowerCase().includes(lowerQuery))) + ) + }) + setResults(filteredResults) } }) diff --git a/src/layouts/ArticleBottomLayout.astro b/src/layouts/ArticleBottomLayout.astro index abfd693..096281d 100644 --- a/src/layouts/ArticleBottomLayout.astro +++ b/src/layouts/ArticleBottomLayout.astro @@ -1,58 +1,98 @@ --- -import { type CollectionEntry, getCollection } from "astro:content" +import type { BlogPost, Project } from "@lib/appwrite-service" +import { formatDate, readingTime } from "@lib/utils" +import { getBlogPosts, getProjects } from "@lib/appwrite-service" type Props = { - entry: CollectionEntry<"blog"> | CollectionEntry<"projects"> + entry: BlogPost | Project } -// Get the requested entry const { entry } = Astro.props -const { collection } = entry -const { Content } = await entry.render() +const collection = entry.$collectionId -// Get the next and prev entries (modulo to wrap index) -const items = (await getCollection(collection)) - .filter(post => !post.data.draft) - .sort((a, b) => b.data.date.getTime() - a.data.date.getTime()) -const index = items.findIndex(x => x.slug === entry.slug) -const prev = items[(index - 1 + items.length) % items.length] -const next = items[(index + 1) % items.length] +// Get the content from the entry +const content = entry.content + +// Fetch all documents for navigation +let prevEntry = null +let nextEntry = null + +if (collection === "blog") { + const blogPosts = await getBlogPosts() + // Sort by date descending to get newest first + const sortedPosts = blogPosts.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()) + + // Find current post index + const currentIndex = sortedPosts.findIndex(post => post.$id === entry.$id) + + if (currentIndex > 0) { + prevEntry = sortedPosts[currentIndex - 1] + } + + if (currentIndex < sortedPosts.length - 1) { + nextEntry = sortedPosts[currentIndex + 1] + } +} else if (collection === "projects") { + const projects = await getProjects() + // Sort by date descending to get newest first + const sortedProjects = projects.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()) + + // Find current project index + const currentIndex = sortedProjects.findIndex(project => project.$id === entry.$id) + + if (currentIndex > 0) { + prevEntry = sortedProjects[currentIndex - 1] + } + + if (currentIndex < sortedProjects.length - 1) { + nextEntry = sortedProjects[currentIndex + 1] + } +} ---
- + {content}
- -
-
- diff --git a/src/layouts/ArticleTopLayout.astro b/src/layouts/ArticleTopLayout.astro index 9e1582b..c57b4f8 100644 --- a/src/layouts/ArticleTopLayout.astro +++ b/src/layouts/ArticleTopLayout.astro @@ -1,17 +1,18 @@ --- -import type { CollectionEntry } from "astro:content" +import type { BlogPost, Project } from "@types/appwrite" import { formatDate, readingTime } from "@lib/utils" type Props = { - entry: CollectionEntry<"projects"> | CollectionEntry<"blog"> + entry: BlogPost | Project } const { entry } = Astro.props -const { collection, data, body } = entry -const { title, summary, date } = data +const { title, summary, date } = entry +const demoUrl = "demoUrl" in entry ? entry.demoUrl : null +const repoUrl = "repoUrl" in entry ? entry.repoUrl : null +const collection = entry.$collectionId +const body = entry.content -const demoUrl = collection === "projects" ? data.demoUrl : null -const repoUrl = collection === "projects" ? data.repoUrl : null ---
diff --git a/src/lib/appwrite-service.ts b/src/lib/appwrite-service.ts index 0efb929..532f5f9 100644 --- a/src/lib/appwrite-service.ts +++ b/src/lib/appwrite-service.ts @@ -90,12 +90,7 @@ export async function getBlogPosts(): Promise { try { const response = await databases.listDocuments( 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 - ] + BLOG_COLLECTION_ID ); // Convert markdown content to HTML for each post @@ -112,6 +107,41 @@ export async function getBlogPosts(): Promise { } +/** + * 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( + DATABASE_ID, + BLOG_COLLECTION_ID, + [ + // Only fetch published posts (not drafts) + `draft != true` + ] + ); + + // 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 */ @@ -174,6 +204,40 @@ export async function getProjects(): Promise { } +/** + * 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( + DATABASE_ID, + PROJECTS_COLLECTION_ID, + [ + // Only fetch published projects (not drafts) + `draft != true` + ] + ); + + // 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 */ diff --git a/src/pages/blog/[...slug].astro b/src/pages/blog/[...slug].astro index 1d14690..f841bda 100644 --- a/src/pages/blog/[...slug].astro +++ b/src/pages/blog/[...slug].astro @@ -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: "" } --- diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index 1b1b606..8737eb4 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -4,18 +4,26 @@ 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" +import { getBlogPosts, getBlogPostsPaginated } from "@lib/appwrite-service" -const posts = await getBlogPosts() - .then(blogPosts => { - return blogPosts; +// 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) + +// 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 []; + return { posts: [], total: 0 }; }) +// Get all tags for filtering const tags = [...new Set(posts.flatMap(post => post.tags))] .sort((a, b) => a.localeCompare(b)) --- diff --git a/src/pages/projects/[...slug].astro b/src/pages/projects/[...slug].astro index ec2e1c5..d5bc224 100644 --- a/src/pages/projects/[...slug].astro +++ b/src/pages/projects/[...slug].astro @@ -5,48 +5,13 @@ 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() { - // 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.contentHtml || project.content, // Use converted HTML 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 // 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 project const slug = Astro.params.slug const project = await getProjectById(slug) .then(projectData => { if (projectData) { - return mapAppwriteProjectToCollectionEntry(projectData); + return projectData } return null; }) @@ -55,7 +20,7 @@ const project = await getProjectById(slug) return null; }) -const { title, summary } = project?.data || { title: "Project not found", summary: "" } +const { title, summary } = project || { title: "Project not found", summary: "" } --- diff --git a/src/pages/projects/index.astro b/src/pages/projects/index.astro index deff56d..f5df767 100644 --- a/src/pages/projects/index.astro +++ b/src/pages/projects/index.astro @@ -4,38 +4,28 @@ 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" +import { getProjectsPaginated } from "@lib/appwrite-service" -// 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)); +// 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) + +// Fetch paginated projects +const { posts, total } = await getProjectsPaginated(page, limit) + .then(result => { + return result; }) .catch(error => { console.error("Error fetching projects:", error); - return []; + return { posts: [], total: 0 }; }) -const tags = [...new Set(projects.flatMap(project => project.data.tags))] +// Get all tags for filtering +const tags = [...new Set(posts.flatMap(project => project.tags))] .sort((a, b) => a.localeCompare(b)) --- @@ -47,7 +37,7 @@ const tags = [...new Set(projects.flatMap(project => project.data.tags))]
- +
diff --git a/src/styles/global.css b/src/styles/global.css index 12c6be5..ec5030d 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -39,7 +39,7 @@ html { html.dark { color-scheme: dark; - background-color: black; + background-color: #000000; /* Darker black for better contrast */ } /* Apply pastel cream background to main content areas */ @@ -53,6 +53,69 @@ body { @apply text-black/75 dark:text-white/75; } +/* Better dark mode text contrast */ +.dark { + --tw-text-opacity: 1; + color: rgba(255, 255, 255, var(--tw-text-opacity)); +} + +/* Improved border visibility in dark mode */ +.border-black\/15 { + border-color: rgba(255, 255, 255, 0.15) !important; +} + +.border-white\/20 { + border-color: rgba(255, 255, 255, 0.2) !important; +} + +/* Better contrast for links and important text */ +.prose a { + color: var(--spaghetti-red) !important; +} + +.prose h1, +.prose h2, +.prose h3, +.prose h4, +.prose h5, +.prose h6 { + color: #ffffff !important; +} + +.prose code { + color: #ffffff !important; +} + +.prose blockquote { + border-left-color: var(--spaghetti-yellow) !important; +} + +.prose th, +.prose td { + color: #ffffff !important; +} + +.page-heading { + @apply font-semibold text-black dark:text-white; +} + +/* Better contrast for text elements */ +.text-spaghetti-brown { + color: #f59e0b !important; /* Amber-400 for better visibility */ +} + +/* Better background for code blocks in dark mode */ +.prose pre { + background-color: #1f2937 !important; /* gray-800 */ + color: #f9fafb !important; /* gray-50 */ +} + +/* Improved dark mode for cards and buttons */ +.group:hover .border-black\/15, +.group:hover .border-white\/20 { + border-color: rgba(255, 255, 255, 0.3) !important; +} + /* Pastel Theme Colors */ .text-spaghetti-yellow { color: var(--spaghetti-yellow); diff --git a/src/types/appwrite.ts b/src/types/appwrite.ts deleted file mode 100644 index 06735ab..0000000 --- a/src/types/appwrite.ts +++ /dev/null @@ -1,85 +0,0 @@ -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 - 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; - image?: string; // File ID for the featured image - template: string; // e.g., "default", "feature" - featured: boolean; -}; - -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; - }>; -};