From 7327795d394f05039a3e0fe0e6615453138bcd6a Mon Sep 17 00:00:00 2001 From: Alex Lebens Date: Sun, 8 Mar 2026 21:38:54 -0500 Subject: [PATCH] feat: add an all page with cards to link to it --- pnpm-lock.yaml | 2 +- src/components/cards/LargeCategoryCard.astro | 77 +++++++++++++ src/components/cards/LargeInvisibleCard.astro | 59 ++++++++++ .../sections/AllCategoriesSection.astro | 31 +++++ src/components/sections/AllPostsSection.astro | 20 ++++ src/components/sections/CategorySection.astro | 2 +- src/lib/directusTypes.ts | 4 + src/pages/all.astro | 109 ++++++++++++++++++ src/pages/blog/index.astro | 3 + src/pages/categories/[...slug].astro | 59 +++++++++- src/pages/categories/index.astro | 3 + src/pages/index.astro | 3 + 12 files changed, 368 insertions(+), 4 deletions(-) create mode 100644 src/components/cards/LargeCategoryCard.astro create mode 100644 src/components/cards/LargeInvisibleCard.astro create mode 100644 src/components/sections/AllCategoriesSection.astro create mode 100644 src/components/sections/AllPostsSection.astro create mode 100644 src/pages/all.astro diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 55cf7fa..9148404 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -75,7 +75,7 @@ importers: specifier: ^4.0.0 version: 4.0.0 photoswipe: - specifier: 5.4.4 + specifier: ^5.4.4 version: 5.4.4 preline: specifier: ^4.1.2 diff --git a/src/components/cards/LargeCategoryCard.astro b/src/components/cards/LargeCategoryCard.astro new file mode 100644 index 0000000..3d45a01 --- /dev/null +++ b/src/components/cards/LargeCategoryCard.astro @@ -0,0 +1,77 @@ +--- +import Logo from '@components/images/Logo.astro'; +import { getDirectusImageURL } from '@/support/url'; + +interface Props { + url: string; + title: string; + description: string; + logoLight: string; + logoDark?: string; + count: number; + publishDate: string; +} + +const { url, title, description, logoLight, logoDark, count, publishDate } = Astro.props; +--- + +
+ +
+
+
+
+ +
+

+ {title} +

+
+
+

+ {description} +

+
+
+ + + + + {count} + + + + + + + {publishDate} + +
+
+
+
+
diff --git a/src/components/cards/LargeInvisibleCard.astro b/src/components/cards/LargeInvisibleCard.astro new file mode 100644 index 0000000..7ca7c0a --- /dev/null +++ b/src/components/cards/LargeInvisibleCard.astro @@ -0,0 +1,59 @@ +--- +import { Icon } from 'astro-icon/components'; +import { Image } from 'astro:assets'; + +import { getDirectusImageURL } from '@/support/url'; + +interface Props { + title: string; + subTitle: string; + url: string; + img?: string; + imgAlt?: string; +} + +const { title, subTitle, url, img, imgAlt } = Astro.props; +--- + +
+ + {img && ( +
+ {imgAlt} +
+ )} +
diff --git a/src/components/sections/AllCategoriesSection.astro b/src/components/sections/AllCategoriesSection.astro new file mode 100644 index 0000000..5fb2eed --- /dev/null +++ b/src/components/sections/AllCategoriesSection.astro @@ -0,0 +1,31 @@ +--- +import { readItems, readSingleton } from '@directus/sdk'; + +import LargeCategoryCard from '@components/cards/LargeCategoryCard.astro'; +import directus from '@lib/directus'; +import { timeago } from '@support/time'; + +const global = await directus.request(readSingleton('site_global')); + +const posts = await directus.request( + readItems('posts', { + filter: { published: { _eq: true } }, + fields: ['*'], + sort: ['-published_date'], + }) +); +--- + +
+
+ +
+
diff --git a/src/components/sections/AllPostsSection.astro b/src/components/sections/AllPostsSection.astro new file mode 100644 index 0000000..96bd225 --- /dev/null +++ b/src/components/sections/AllPostsSection.astro @@ -0,0 +1,20 @@ +--- +import { readSingleton } from '@directus/sdk'; + +import LargeInvisibleCard from '@components/cards/LargeInvisibleCard.astro'; +import directus from '@lib/directus'; + +const global = await directus.request(readSingleton('site_global')); +--- + +
+
+ +
+
diff --git a/src/components/sections/CategorySection.astro b/src/components/sections/CategorySection.astro index 949e7e8..0119ec9 100644 --- a/src/components/sections/CategorySection.astro +++ b/src/components/sections/CategorySection.astro @@ -1,7 +1,7 @@ --- import { readItems } from '@directus/sdk'; -import type { Post, Category } from '@lib/directusTypes'; +import type { Post } from '@lib/directusTypes'; import CategoryCard from '@components/cards/CategoryCard.astro'; import directus from '@lib/directus'; diff --git a/src/lib/directusTypes.ts b/src/lib/directusTypes.ts index fdfb6fc..126ed08 100644 --- a/src/lib/directusTypes.ts +++ b/src/lib/directusTypes.ts @@ -14,6 +14,10 @@ export type Global = { portrait_alt: string; home_image: string; home_image_alt: string; + all_image: string; + all_image_alt: string; + all_logoLight: string; + all_logoDark: string; blog_image: string; blog_image_alt: string; categories_image: string; diff --git a/src/pages/all.astro b/src/pages/all.astro new file mode 100644 index 0000000..5e89b1b --- /dev/null +++ b/src/pages/all.astro @@ -0,0 +1,109 @@ +--- +import { readItems, readSingleton } from '@directus/sdk'; + +import HeaderSection from '@components/sections/HeaderSection.astro'; +import BlogCard from '@components/cards/BlogCard.astro'; +import BaseLayout from '@layouts/BaseLayout.astro'; +import directus from '@lib/directus'; + +const global = await directus.request(readSingleton('site_global')); +const posts = await directus.request( + readItems('posts', { + filter: { published: { _eq: true } }, + fields: ['*'], + sort: ['-published_date'], + }) +); +--- + + + + + +
+
+ {posts.map((b) => +
+ +
+ )} +
+
+ +
+ + diff --git a/src/pages/blog/index.astro b/src/pages/blog/index.astro index af6cfe8..fbeb377 100644 --- a/src/pages/blog/index.astro +++ b/src/pages/blog/index.astro @@ -6,6 +6,7 @@ import type { Post } from '@lib/directusTypes'; import HeroSection from '@components/sections/HeroSection.astro'; import SelectedPostsSection from '@components/sections/SelectedPostsSection.astro'; import RecentPostsSection from '@components/sections/RecentPostsSection.astro'; +import AllPostsSection from '@components/sections/AllPostsSection.astro'; import BaseLayout from '@layouts/BaseLayout.astro'; import directus from '@lib/directus'; @@ -60,6 +61,8 @@ const recentPosts: Post[] = posts.filter( title="Recent Posts" /> + + diff --git a/src/pages/categories/index.astro b/src/pages/categories/index.astro index d6fd9a6..ac99fa0 100644 --- a/src/pages/categories/index.astro +++ b/src/pages/categories/index.astro @@ -3,6 +3,7 @@ import { readSingleton } from '@directus/sdk'; import HeroSection from '@components/sections/HeroSection.astro'; import CategorySection from '@components/sections/CategorySection.astro'; +import AllCategoriesSection from '@components/sections/AllCategoriesSection.astro'; import BaseLayout from '@layouts/BaseLayout.astro'; import directus from '@lib/directus'; @@ -40,6 +41,8 @@ const global = await directus.request(readSingleton('site_global')); + +