Compare commits

..

1 Commits

Author SHA1 Message Date
4dbaf2f44a chore(deps): update dependency @directus/sdk to v21.2.0
All checks were successful
renovate/stability-days Updates have met minimum release age requirement
test-build / guarddog (pull_request) Successful in 24s
test-build / build (pull_request) Successful in 5m16s
2026-03-05 23:01:55 +00:00
17 changed files with 396 additions and 470 deletions

View File

@@ -26,18 +26,7 @@ jobs:
cache: pnpm cache: pnpm
- name: Install Dependencies - name: Install Dependencies
run: pnpm install --frozen-lockfile run: pnpm install
- name: Cache Astro Build Cache
uses: actions/cache@v4
with:
path: |
node_modules/.cache
.astro/cache
key: ${{ runner.os }}-astro-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-astro-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-
${{ runner.os }}-astro-cache-
- name: Lint Code - name: Lint Code
run: pnpm lint run: pnpm lint
@@ -53,14 +42,14 @@ jobs:
uses: actions/checkout@v6 uses: actions/checkout@v6
- name: Login to Registry - name: Login to Registry
uses: docker/login-action@v4 uses: docker/login-action@v3
with: with:
registry: ${{ vars.REPOSITORY_HOST }} registry: ${{ vars.REPOSITORY_HOST }}
username: ${{ gitea.actor }} username: ${{ gitea.actor }}
password: ${{ secrets.REPOSITORY_TOKEN }} password: ${{ secrets.REPOSITORY_TOKEN }}
- name: Login to Docker - name: Login to Docker
uses: docker/login-action@v4 uses: docker/login-action@v3
with: with:
registry: ${{ vars.DH_REGISTRY }} registry: ${{ vars.DH_REGISTRY }}
username: ${{ secrets.DH_USERNAME }} username: ${{ secrets.DH_USERNAME }}
@@ -73,7 +62,7 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v4 uses: docker/setup-buildx-action@v3
with: with:
driver: kubernetes driver: kubernetes
driver-opts: | driver-opts: |
@@ -88,7 +77,7 @@ jobs:
- name: Extract Metadata - name: Extract Metadata
id: meta id: meta
uses: docker/metadata-action@v6 uses: docker/metadata-action@v5
with: with:
tags: | tags: |
type=ref,event=branch type=ref,event=branch
@@ -112,7 +101,7 @@ jobs:
fi fi
- name: Build and Push Image - name: Build and Push Image
uses: docker/build-push-action@v7 uses: docker/build-push-action@v6
with: with:
context: . context: .
push: true push: true
@@ -124,8 +113,6 @@ jobs:
COMMIT_SHA=${{ steps.version.outputs.commit }} COMMIT_SHA=${{ steps.version.outputs.commit }}
IS_RELEASE=${{ steps.version.outputs.is_release }} IS_RELEASE=${{ steps.version.outputs.is_release }}
file: ./Dockerfile file: ./Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
- name: ntfy Success - name: ntfy Success
uses: niniyas/ntfy-action@master uses: niniyas/ntfy-action@master

View File

@@ -26,18 +26,7 @@ jobs:
cache: pnpm cache: pnpm
- name: Install Dependencies - name: Install Dependencies
run: pnpm install --frozen-lockfile run: pnpm install
- name: Cache Astro Build Cache
uses: actions/cache@v4
with:
path: |
node_modules/.cache
.astro/cache
key: ${{ runner.os }}-astro-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-astro-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-
${{ runner.os }}-astro-cache-
- name: Lint Code - name: Lint Code
run: pnpm lint run: pnpm lint
@@ -53,14 +42,14 @@ jobs:
uses: actions/checkout@v6 uses: actions/checkout@v6
- name: Login to Registry - name: Login to Registry
uses: docker/login-action@v4 uses: docker/login-action@v3
with: with:
registry: ${{ vars.REGISTRY_HOST }} registry: ${{ vars.REGISTRY_HOST }}
username: ${{ vars.REGISTRY_USER }} username: ${{ vars.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_SECRET }} password: ${{ secrets.REGISTRY_SECRET }}
- name: Login to Docker - name: Login to Docker
uses: docker/login-action@v4 uses: docker/login-action@v3
with: with:
registry: ${{ vars.DH_REGISTRY }} registry: ${{ vars.DH_REGISTRY }}
username: ${{ secrets.DH_USERNAME }} username: ${{ secrets.DH_USERNAME }}
@@ -73,7 +62,7 @@ jobs:
- name: Set up Docker Buildx - name: Set up Docker Buildx
id: buildx id: buildx
uses: docker/setup-buildx-action@v4 uses: docker/setup-buildx-action@v3
with: with:
driver: kubernetes driver: kubernetes
driver-opts: | driver-opts: |
@@ -88,7 +77,7 @@ jobs:
- name: Extract Metadata - name: Extract Metadata
id: meta id: meta
uses: docker/metadata-action@v6 uses: docker/metadata-action@v5
with: with:
tags: | tags: |
type=ref,event=branch type=ref,event=branch
@@ -112,7 +101,7 @@ jobs:
fi fi
- name: Build and Push Image - name: Build and Push Image
uses: docker/build-push-action@v7 uses: docker/build-push-action@v6
with: with:
context: . context: .
push: true push: true
@@ -124,8 +113,6 @@ jobs:
COMMIT_SHA=${{ steps.version.outputs.commit }} COMMIT_SHA=${{ steps.version.outputs.commit }}
IS_RELEASE=${{ steps.version.outputs.is_release }} IS_RELEASE=${{ steps.version.outputs.is_release }}
file: ./Dockerfile file: ./Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
- name: ntfy Success - name: ntfy Success
uses: niniyas/ntfy-action@master uses: niniyas/ntfy-action@master

View File

@@ -28,18 +28,7 @@ jobs:
cache: pnpm cache: pnpm
- name: Install Dependencies - name: Install Dependencies
run: pnpm install --frozen-lockfile run: pnpm install
- name: Cache Astro Build Cache
uses: actions/cache@v4
with:
path: |
node_modules/.cache
.astro/cache
key: ${{ runner.os }}-astro-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-astro-cache-${{ hashFiles('**/pnpm-lock.yaml') }}-
${{ runner.os }}-astro-cache-
- name: Lint Code - name: Lint Code
run: pnpm lint run: pnpm lint

View File

@@ -22,7 +22,7 @@ WORKDIR /app
COPY --from=prod-deps /app/node_modules /app/node_modules COPY --from=prod-deps /app/node_modules /app/node_modules
COPY --from=build /app/dist /app/dist COPY --from=build /app/dist /app/dist
LABEL version="2.24.0" LABEL version="2.19.0"
LABEL description="Astro based personal website" LABEL description="Astro based personal website"
ENV HOST=0.0.0.0 ENV HOST=0.0.0.0

View File

@@ -1,7 +1,7 @@
{ {
"name": "site-profile", "name": "site-profile",
"type": "module", "type": "module",
"version": "2.24.0", "version": "2.19.0",
"homepage": "https://www.alexlebens.dev", "homepage": "https://www.alexlebens.dev",
"bugs": { "bugs": {
"url": "https://gitea.alexlebens.dev/alexlebens/site-profile/issues", "url": "https://gitea.alexlebens.dev/alexlebens/site-profile/issues",
@@ -33,7 +33,7 @@
"@astrojs/react": "^4.4.2", "@astrojs/react": "^4.4.2",
"@astrojs/rss": "^4.0.15", "@astrojs/rss": "^4.0.15",
"@astrojs/sitemap": "^3.7.0", "@astrojs/sitemap": "^3.7.0",
"@directus/sdk": "^21.2.0", "@directus/sdk": "^21.1.0",
"@giscus/react": "^3.1.0", "@giscus/react": "^3.1.0",
"@iconify-json/mdi": "^1.2.3", "@iconify-json/mdi": "^1.2.3",
"@iconify-json/pajamas": "^1.2.15", "@iconify-json/pajamas": "^1.2.15",
@@ -46,7 +46,7 @@
"@types/unist": "^3.0.3", "@types/unist": "^3.0.3",
"astro": "^5.18.0", "astro": "^5.18.0",
"astro-icon": "^1.1.5", "astro-icon": "^1.1.5",
"marked": "^17.0.4", "marked": "^17.0.3",
"marked-shiki": "^1.2.1", "marked-shiki": "^1.2.1",
"mdast-util-to-string": "^4.0.0", "mdast-util-to-string": "^4.0.0",
"preline": "^4.1.2", "preline": "^4.1.2",
@@ -63,7 +63,7 @@
"@eslint-react/eslint-plugin": "^2.13.0", "@eslint-react/eslint-plugin": "^2.13.0",
"@tailwindcss/forms": "^0.5.11", "@tailwindcss/forms": "^0.5.11",
"@tailwindcss/typography": "^0.5.19", "@tailwindcss/typography": "^0.5.19",
"eslint": "^10.0.3", "eslint": "^10.0.2",
"eslint-config-prettier": "^10.1.8", "eslint-config-prettier": "^10.1.8",
"eslint-plugin-astro": "^1.6.0", "eslint-plugin-astro": "^1.6.0",
"eslint-plugin-format": "^2.0.1", "eslint-plugin-format": "^2.0.1",

549
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@ const currentPath = pathname.slice(1);
class="fixed flex flex-wrap md:flex-nowrap md:justify-start inset-x-0 top-0 w-full z-50" class="fixed flex flex-wrap md:flex-nowrap md:justify-start inset-x-0 top-0 w-full z-50"
> >
<nav <nav
class="nav-base relative md:flex md:items-center md:justify-between rounded-[36px] transition-all duration-300 w-full px-4 py-3 mx-2 md:mx-8 mt-4" class="nav-base relative md:flex md:items-center md:justify-between rounded-[36px] w-full px-4 mx-2 py-3 mt-4"
aria-label="Global" aria-label="Global"
> >
<div class="flex items-center justify-between ml-0"> <div class="flex items-center justify-between ml-0">

View File

@@ -2,30 +2,28 @@
import { Icon } from 'astro-icon/components'; import { Icon } from 'astro-icon/components';
import { Image } from 'astro:assets'; import { Image } from 'astro:assets';
import { formatDate } from '@support/time';
import { getDirectusImageURL } from '@/support/url'; import { getDirectusImageURL } from '@/support/url';
interface Props { interface Props {
title: string; title: string;
subTitle: string; subTitle: string;
url: string; url: string;
pubDate: Date,
img: string; img: string;
imgAlt: string; imgAlt: string;
} }
const { title, subTitle, url, pubDate, img, imgAlt } = Astro.props; const { title, subTitle, url, img, imgAlt } = Astro.props;
--- ---
<div class="smooth-reveal flex flex-col px-4 py-10 mx-auto w-full"> <div class="smooth-reveal flex flex-col px-4 py-10 mx-auto">
<a <a
class="md:card-base-hidden group items-center md:grid md:grid-cols-2 lg:grid lg:grid-cols-2 gap-8 xl:gap-16 w-full md:px-8 md:py-8" class="md:card-base-hidden group items-center md:grid md:grid-cols-2 lg:grid lg:grid-cols-2 gap-8 xl:gap-16 max-w-340 2xl:max-w-full md:px-8 md:py-8"
href={url} href={url}
data-astro-prefetch data-astro-prefetch
> >
<div> <div>
<Image <Image
class="rounded-2xl rounded-b-none md:rounded-2xl md:shadow-2xl w-full h-full sm:max-h-80 md:max-h-90 object-cover" class="rounded-2xl rounded-b-none md:rounded-2xl w-full h-full sm:max-h-80 md:max-h-90 object-cover"
src={getDirectusImageURL(img)} src={getDirectusImageURL(img)}
alt={imgAlt} alt={imgAlt}
draggable="false" draggable="false"
@@ -42,21 +40,17 @@ const { title, subTitle, url, pubDate, img, imgAlt } = Astro.props;
<p class="card-text-title font-light text-pretty sm:text-lg max-w-prose mb-8"> <p class="card-text-title font-light text-pretty sm:text-lg max-w-prose mb-8">
{subTitle} {subTitle}
</p> </p>
<div class="flex items-center justify-between w-full"> <div class="button-base button-bg-teal inline-flex rounded-lg gap-x-2">
<div class="button-base button-bg-teal inline-flex rounded-lg gap-x-2"> <div class="button-text-title flex relative items-center text-center">
<div class="button-text-title flex relative items-center text-center"> <span class="mr-2">
<span class="mr-2"> Read More
Read More </span>
</span> <Icon
<Icon name="mdi:keyboard-arrow-right"
name="mdi:keyboard-arrow-right" class="button-hover-arrow"
class="button-hover-arrow" />
/>
</div>
</div> </div>
<span class="card-text-description text-sm ml-auto">
{formatDate(pubDate)}
</span>
</div> </div>
</div>
</a> </a>
</div> </div>

View File

@@ -2,26 +2,25 @@
import { Icon } from 'astro-icon/components'; import { Icon } from 'astro-icon/components';
import { Image } from 'astro:assets'; import { Image } from 'astro:assets';
import { formatDate } from '@support/time';
import { getDirectusImageURL } from '@/support/url'; import { getDirectusImageURL } from '@/support/url';
interface Props { interface Props {
title: string; title: string;
subTitle: string; subTitle: string;
url: string; url: string;
pubDate: Date; single?: boolean;
imgOne: string; imgOne: any;
imgOneAlt: string; imgOneAlt: any;
imgTwo?: string; imgTwo?: any;
imgTwoAlt?: string; imgTwoAlt?: any;
} }
const { title, subTitle, url, pubDate, imgOne, imgOneAlt, imgTwo, imgTwoAlt } = Astro.props; const { title, subTitle, url, single, imgOne, imgOneAlt, imgTwo, imgTwoAlt } = Astro.props;
--- ---
<div class="smooth-reveal flex flex-col px-4 py-10 mx-auto w-full"> <div class="smooth-reveal flex flex-col px-5 py-10 mx-auto">
<a <a
class="md:card-base-hidden group flex flex-col-reverse md:grid md:items-center md:grid-cols-2 lg:grid lg:grid-cols-2 md:gap-8 xl:gap-16 w-full md:px-8 md:py-8" class="md:card-base-hidden group flex flex-col-reverse md:items-center md:grid md:grid-cols-2 lg:grid lg:grid-cols-2 md:gap-8 xl:gap-16 max-w-340 2xl:max-w-full md:px-8 md:py-8"
href={url} href={url}
data-astro-prefetch data-astro-prefetch
> >
@@ -32,30 +31,25 @@ const { title, subTitle, url, pubDate, imgOne, imgOneAlt, imgTwo, imgTwoAlt } =
<p class="card-text-title font-light text-pretty sm:text-lg max-w-prose mb-8"> <p class="card-text-title font-light text-pretty sm:text-lg max-w-prose mb-8">
{subTitle} {subTitle}
</p> </p>
<div class="flex items-center justify-between w-full"> <div class="button-base button-bg-teal inline-flex rounded-lg gap-x-2">
<div class="button-base button-bg-teal inline-flex rounded-lg gap-x-2"> <div class="button-text-title flex relative items-center text-center">
<div class="button-text-title flex relative items-center text-center"> <span class="mr-2">
<span class="mr-2"> Read More
Read More </span>
</span> <Icon
<Icon name="mdi:keyboard-arrow-right"
name="mdi:keyboard-arrow-right" class="button-hover-arrow"
class="button-hover-arrow" />
/>
</div>
</div> </div>
<span class="card-text-description text-sm ml-auto">
{formatDate(pubDate)}
</span>
</div> </div>
</div> </div>
{!imgTwo ? ( {single ? (
<div> <div>
<Image <Image
class="rounded-2xl rounded-b-none md:rounded-2xl md:shadow-2xl w-full h-full sm:max-h-80 md:max-h-90 object-cover" class="rounded-2xl rounded-b-none md:rounded-2xl w-full"
src={getDirectusImageURL(imgOne)} src={getDirectusImageURL(imgOne)}
alt={imgOneAlt} alt={imgOneAlt}
draggable="false" format="webp"
loading="lazy" loading="lazy"
width="850" width="850"
height="420" height="420"
@@ -63,42 +57,30 @@ const { title, subTitle, url, pubDate, imgOne, imgOneAlt, imgTwo, imgTwoAlt } =
/> />
</div> </div>
) : ( ) : (
<> <div class="grid grid-cols-2 gap-4">
<div class="md:hidden"> <Image
<Image class="rounded-xl w-full"
class="rounded-2xl rounded-b-none shadow-2xl w-full h-full sm:max-h-80 object-cover" src={getDirectusImageURL(imgOne)}
src={getDirectusImageURL(imgOne)} alt={imgOneAlt}
alt={imgOneAlt} draggable="false"
draggable="false" format="webp"
loading="lazy" loading="lazy"
width="850" width="400"
height="420" height="230"
inferSize={true} inferSize={true}
/> />
</div> <Image
<div class="hidden md:flex md:items-start"> class="rounded-xl w-full mt-4 lg:mt-10"
<Image src={getDirectusImageURL(imgTwo)}
class="rounded-xl z-10 shadow-2xl w-3/5 h-full object-cover" alt={imgTwoAlt}
src={getDirectusImageURL(imgOne)} draggable="false"
alt={imgOneAlt} format="webp"
draggable="false" loading="lazy"
loading="lazy" width="400"
width="600" height="230"
height="310" inferSize={true}
inferSize={true} />
/> </div>
<Image
class="rounded-xl shadow-2xl w-3/5 h-full -ml-16 mt-12 object-cover"
src={getDirectusImageURL(imgTwo)}
alt={imgTwoAlt}
draggable="false"
loading="lazy"
width="600"
height="310"
inferSize={true}
/>
</div>
</>
)} )}
</a> </a>
</div> </div>

View File

@@ -10,7 +10,7 @@ import { timeago } from '@support/time';
const posts = await directus.request( const posts = await directus.request(
readItems('posts', { readItems('posts', {
filter: { published: { _eq: true } }, filter: { published: { _eq: true } },
fields: ['*', 'category.slug'], fields: ['*'],
sort: ['-published_date'], sort: ['-published_date'],
}) })
); );
@@ -31,16 +31,13 @@ const layoutPattern = [
const postMap: Map<string, Post[]> = posts const postMap: Map<string, Post[]> = posts
.sort((a: Post, b: Post) => b.published_date.valueOf() - a.published_date.valueOf()) .sort((a: Post, b: Post) => b.published_date.valueOf() - a.published_date.valueOf())
.reduce((acc, obj) => { .reduce((acc, obj) => {
const categorySlug = obj.category?.slug; let posts = acc.get(obj.category);
if (!categorySlug) return acc;
let posts = acc.get(categorySlug);
if (!posts) { if (!posts) {
posts = []; posts = [];
} }
posts.push(obj); posts.push(obj);
acc.set(categorySlug, posts); acc.set(obj.category, posts);
return acc; return acc;
}, new Map<string, Post[]>()); }, new Map<string, Post[]>());

View File

@@ -23,11 +23,7 @@ const { posts, title, subTitle } = Astro.props;
</span> </span>
</div> </div>
</div> </div>
<div class="columns-1 sm:columns-2 lg:columns-3 gap-6"> <div class="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
{posts.map((b) => ( {posts.map((b) => <BlogCard post={b} />)}
<div class="break-inside-avoid mb-6">
<BlogCard post={b} />
</div>
))}
</div> </div>
</section> </section>

View File

@@ -11,13 +11,12 @@ interface Props {
const { posts } = Astro.props; const { posts } = Astro.props;
--- ---
<section class="smooth-reveal flex flex-col gap-4 md:mb-20"> <section class="smooth-reveal flex flex-col gap-4">
{posts.map((post, index) => index % 2 === 0 ? ( {posts.map((post, index) => index % 2 === 0 ? (
<LargeBlogLeftCard <LargeBlogLeftCard
title={post.title} title={post.title}
subTitle={post.description} subTitle={post.description}
url={`/blog/${post.slug}`} url={`/blog/${post.slug}`}
pubDate={post.published_date}
img={post.image} img={post.image}
imgAlt={post.image_alt} imgAlt={post.image_alt}
/> />
@@ -26,7 +25,7 @@ const { posts } = Astro.props;
title={post.title} title={post.title}
subTitle={post.description} subTitle={post.description}
url={`/blog/${post.slug}`} url={`/blog/${post.slug}`}
pubDate={post.published_date} single={!post.image_second}
imgOne={post.image} imgOne={post.image}
imgOneAlt={post.image_alt} imgOneAlt={post.image_alt}
imgTwo={post?.image_second} imgTwo={post?.image_second}

View File

@@ -68,66 +68,67 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
/> />
</head> </head>
<body class="bg-background selection:bg-yellow-400 m-0 p-0 overflow-hidden"> <body class="bg-background selection:bg-yellow-400 m-0 p-0 overflow-x-hidden">
<!-- Sliding backgrounds --> <!-- Sliding backgrounds -->
<div class="bg"/> <div class="bg"/>
<div class="bg bg2"/> <div class="bg bg2"/>
<div class="bg bg3"/> <div class="bg bg3"/>
<!-- Fixed header --> <!-- Layout -->
<Header /> <div class="grow w-full max-w-(--breakpoint-2xl) px-4 sm:px-6 lg:px-8 py-20 mx-auto">
<!-- Main body --> <Header />
<div id="reset-scroll" class="mask-container w-screen h-screen overflow-y-auto overflow-x-hidden">
<main>
<!-- Content -->
<div class="grow w-full max-w-(--breakpoint-2xl) px-4 sm:px-6 lg:px-8 py-20 mx-auto">
<slot />
</div>
<!-- Footer -->
<Footer />
<main class="has-js scroll-fade-container min-h-screen">
<slot />
</main> </main>
</div> </div>
<Footer />
</body> </body>
</html> </html>
<script> <script>
const resetScroll = () => { document.addEventListener('astro:page-load', () => {
const scrollContainer = document.getElementById('reset-scroll'); const onScroll = () => {
if (scrollContainer) { document.documentElement.style.setProperty('--scroll-offset', `${window.scrollY}px`);
scrollContainer.scrollTop = 0; document.documentElement.classList.add('has-js');
} };
};
resetScroll(); window.removeEventListener('scroll', onScroll);
document.addEventListener('astro:after-swap', resetScroll); window.addEventListener('scroll', onScroll, { passive: true });
onScroll();
});
</script> </script>
<style> <style>
/* Fade away content below header when scrolling */ /* Fade away content below header when scrolling */
.mask-container { .has-js .scroll-fade-container {
-webkit-mask-image: linear-gradient( -webkit-mask-image: linear-gradient(
to bottom, to bottom,
transparent 0px, transparent 0px,
transparent 90px, transparent 16px,
black 140px, black 80px,
black 100% black 100%
); );
mask-image: linear-gradient( mask-image: linear-gradient(
to bottom, to bottom,
transparent 0px, transparent 0px,
transparent 90px, transparent 16px,
black 140px, black 60px,
black 100% black 100%
); );
-webkit-mask-size: 100vw 100vh; -webkit-mask-size: 100vw 100vh;
-webkit-mask-repeat: no-repeat; -webkit-mask-repeat: no-repeat;
-webkit-mask-position-y: var(--scroll-offset);
mask-position-y: var(--scroll-offset);
} }
/* Background that creates the "glimmer" effect */ /* Background that creates the "glimmer" effect */
@@ -148,9 +149,9 @@ const normalizeTitle = !title ? global.name : `${title} | ${global.name}`;
} }
:global(.dark) .bg { :global(.dark) .bg {
--bg-primary: #3b3836; --bg-primary: #332f2e;
--bg-secondary: #332f2e; --bg-secondary: #44403c;
--bg-tertiary: #44403c; --bg-tertiary: #57534e;
} }
.bg2 { .bg2 {

View File

@@ -37,7 +37,7 @@ export type Post = {
title: string; title: string;
description: string; description: string;
tags: string[]; tags: string[];
category: Category; category: string;
selected: boolean; selected: boolean;
published: boolean; published: boolean;
content: string; content: string;

View File

@@ -17,9 +17,7 @@ import { getDirectusImageURL } from '@/support/url';
const post = Astro.props; const post = Astro.props;
export async function getStaticPaths() { export async function getStaticPaths() {
const posts = await directus.request(readItems('posts', { const posts = await directus.request(readItems('posts'));
fields: ['*', 'category.*'],
}));
return posts.map((post) => ({ return posts.map((post) => ({
params: { slug: post.slug }, params: { slug: post.slug },
props: post, props: post,
@@ -27,7 +25,12 @@ export async function getStaticPaths() {
} }
const global = await directus.request(readSingleton('site_global')); const global = await directus.request(readSingleton('site_global'));
const category = post.category; const [category] = post.category ? await directus.request(
readItems('categories', {
filter: { slug: { _eq: post.category },},
limit: 1,
}))
: [];
const readingTime = getReadingTime(post.content || ''); const readingTime = getReadingTime(post.content || '');

View File

@@ -20,7 +20,7 @@ const posts = await directus.request(
}) })
); );
const selectedPosts: Post[] = posts.filter((p) => p.selected).slice(0, 4); const selectedPosts: Post[] = posts.filter((p) => p.selected).slice(0, 3);
const recentPosts: Post[] = posts.filter( const recentPosts: Post[] = posts.filter(
(p) => !selectedPosts.some((selected) => selected.slug === p.slug) (p) => !selectedPosts.some((selected) => selected.slug === p.slug)
).slice(0, 9); ).slice(0, 9);

View File

@@ -22,7 +22,7 @@ const global = await directus.request(readSingleton('site_global'));
const posts = await directus.request( const posts = await directus.request(
readItems('posts', { readItems('posts', {
filter: { published: { _eq: true } }, filter: { published: { _eq: true } },
fields: ['*', 'category.slug'], fields: ['*'],
sort: ['-published_date'], sort: ['-published_date'],
}) })
); );
@@ -30,7 +30,7 @@ const posts = await directus.request(
const categoriesPosts = posts const categoriesPosts = posts
.sort((a: Post, b: Post) => b.published_date.valueOf() - a.published_date.valueOf()) .sort((a: Post, b: Post) => b.published_date.valueOf() - a.published_date.valueOf())
.filter((b) => { .filter((b) => {
return b.category?.slug === category.slug; return b.category === category.slug;
}); });
--- ---