Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(deps): migrate to astro v5 #518

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ pnpm-debug.log*

package-lock.json
pnpm-lock.yaml

# astro
.astro
Binary file modified bun.lockb
Binary file not shown.
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
"subfont": "subfont -ir --no-fallbacks --silent --root dist"
},
"devDependencies": {
"@astrojs/mdx": "^3.1.4",
"@astrojs/partytown": "^2.1.1",
"@astrojs/rss": "^4.0.7",
"@astrojs/sitemap": "^3.1.6",
"@astrojs/tailwind": "^5.1.0",
"@astrojs/mdx": "4.0.2",
"@astrojs/partytown": "2.1.2",
"@astrojs/rss": "4.0.10",
"@astrojs/sitemap": "3.2.1",
"@astrojs/tailwind": "5.1.3",
"@astrolib/analytics": "^0.6.1",
"@astrolib/seo": "^1.0.0-beta.5",
"@biomejs/biome": "1.9.4",
Expand All @@ -27,7 +27,7 @@
"@types/bun": "^1.1.7",
"@types/react": "^18.3.4",
"@types/react-dom": "^18.3.0",
"astro": "4.16.18",
"astro": "5.1.1",
"astro-icon": "^0.8.2",
"hast-util-to-string": "^3.0.0",
"hastscript": "^9.0.0",
Expand All @@ -45,13 +45,14 @@
"vite-plugin-lib": "^2.1.1"
},
"dependencies": {
"@astrojs/react": "^3.6.2",
"@astrojs/react": "4.1.1",
"@tanstack/react-table": "^8.20.1",
"chart.js": "^4.4.6",
"react": "^18.3.1",
"react-chartjs-2": "^5.2.0",
"react-dom": "^18.3.1",
"unpic": "^3.18.0",
"uuid": "^11.0.1"
}
},
"trustedDependencies": ["@biomejs/biome", "@parcel/watcher"]
}
9 changes: 6 additions & 3 deletions src/pages/[...blog]/[...page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import Pagination from "~/components/atoms/Pagination.astro";

import { fetchPosts } from "~/utils/posts";
import { getCanonical, getPermalink, BLOG_BASE } from "~/utils/permalinks";
import type { InferGetStaticPropsType, GetStaticPaths } from "astro";

export async function getStaticPaths({ paginate }) {
export const getStaticPaths = (async ({ paginate }) => {
if (BLOG?.disabled || BLOG?.blog?.disabled) return [];

const posts = await fetchPosts();
Expand All @@ -17,9 +18,11 @@ export async function getStaticPaths({ paginate }) {
params: { blog: BLOG_BASE || undefined },
pageSize: BLOG.postsPerPage,
});
}
}) satisfies GetStaticPaths

const { page } = Astro.props;
type Props = InferGetStaticPropsType<typeof getStaticPaths>;

const { page } = Astro.props as Props;
const currentPage = page.currentPage ?? 1;

const meta = {
Expand Down
5 changes: 5 additions & 0 deletions src/pages/[...blog]/[slug].astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import {
} from "~/utils/permalinks";
import { fetchPosts } from "~/utils/posts";
import { findImage } from "~/utils/images";
import type { Post } from "~/types";

interface Props {
post: Post
}

export async function getStaticPaths() {
if (BLOG?.disabled || BLOG?.post?.disabled) return [];
Expand Down
3 changes: 2 additions & 1 deletion src/pages/[...categories]/[category]/[...page].astro
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ import {
cleanSlug,
CATEGORY_BASE,
} from "~/utils/permalinks";
import type { Post } from "~/types";

export async function getStaticPaths({ paginate }) {
if (BLOG?.disabled || BLOG?.category?.disabled) return [];

const posts = await fetchPosts();
const posts = await fetchPosts() as Post[];

const categories = new Set();
posts.map((post) => {
Expand Down
3 changes: 0 additions & 3 deletions src/pages/legal.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ const meta = {
description: SITE.description,
canonical: getCanonical(getHomePermalink()),
};

import { Icon } from "astro-icon";
import Picture from "~/components/core/Picture.astro";
---

<Layout {meta}>
Expand Down
3 changes: 0 additions & 3 deletions src/pages/privacy.astro
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ const meta = {
description: SITE.description,
canonical: getCanonical(getHomePermalink()),
};

import { Icon } from "astro-icon";
import Picture from "~/components/core/Picture.astro";
---

<Layout {meta}>
Expand Down
18 changes: 18 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export interface Post {
id: string;
publishDate: Date;
draft: boolean;
canonical: string;
slug: string;
title: string;
description: string;
image: string;
imageCreditUrl: string | null;
content: string; // or 'body' in case you consume from API
excerpt: string;
authors: string[];
category: string;
tags: string[];
readingTime: number;
tweet: string;
}
Loading