Skip to content

Commit

Permalink
upgrade to astro v5
Browse files Browse the repository at this point in the history
  • Loading branch information
activatedgeek committed Jan 17, 2025
1 parent 74e831a commit 250d06b
Show file tree
Hide file tree
Showing 26 changed files with 10,540 additions and 5,923 deletions.
16,389 changes: 10,493 additions & 5,896 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "copernicus",
"type": "module",
"version": "0.9.1",
"version": "0.10.0",
"scripts": {
"dev": "astro dev",
"pretty": "prettier --write .",
Expand All @@ -13,13 +13,13 @@
"ncu": "ncu"
},
"dependencies": {
"@astrojs/cloudflare": "^11.2.0",
"@astrojs/mdx": "^3.1.9",
"@astrojs/react": "^3.6.3",
"@astrojs/cloudflare": "^12.2.0",
"@astrojs/mdx": "^4.0.6",
"@astrojs/react": "^4.1.5",
"@astrojs/rss": "^4.0.11",
"@astrojs/sitemap": "^3.2.1",
"@picocss/pico": "^2.0.6",
"astro": "^4.16.14",
"astro": "^5.1.7",
"autoprefixer": "^10.4.20",
"cssnano": "^7.0.6",
"github-slugger": "^2.0.0",
Expand Down
3 changes: 2 additions & 1 deletion src/components/MDPage.astro
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
import { render } from "astro:content";
import { FaCalendarDay, FaTag } from "react-icons/fa";
import Html from "@components/Html.astro";
Expand All @@ -10,7 +11,7 @@ import "@styles/katex.css";
const { page } = Astro.props;
const { data: frontmatter } = page;
const { Content } = await page.render();
const { Content } = await render(page);
const { title, description, date, updated, area, comments, hideMetadata } =
frontmatter;
Expand Down
32 changes: 19 additions & 13 deletions src/content/config.ts → src/content.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { z, defineCollection, reference } from "astro:content";
import { glob } from "astro/loaders";

const areas = defineCollection({
type: "data",
loader: glob({ pattern: "**/[^_]*.json", base: "./src/data/areas" }),
schema: z.object({
label: z.string(),
emoji: z.string(),
Expand All @@ -11,15 +12,22 @@ const areas = defineCollection({
});

const authors = defineCollection({
type: "data",
loader: glob({ pattern: "**/[^_]*.json", base: "./src/data/authors" }),
schema: z.object({
name: z.string(),
url: z.string().url(),
}),
});

const social = defineCollection({
loader: glob({ pattern: "**/[^_]*.json", base: "./src/data/social" }),
schema: z.object({
url: z.string().url(),
}),
});

const kb = defineCollection({
type: "content",
loader: glob({ pattern: "**/[^_]*.md", base: "./src/content/kb" }),
schema: z.object({
title: z.string(),
description: z.string().optional().default(""),
Expand All @@ -36,26 +44,24 @@ const kb = defineCollection({
}),
});

const overview = defineCollection({
loader: glob({ pattern: "**/[^_]*.md", base: "./src/content/overview" }),
schema: kb.schema,
});

const thoughts = defineCollection({
type: "content",
loader: glob({ pattern: "**/[^_]*.md", base: "./src/content/thoughts" }),
schema: z.object({
date: z.coerce.date(),
authors: z.array(reference("authors")).optional().default(["sk"]),
}),
});

const social = defineCollection({
type: "data",
schema: z.object({
url: z.string().url(),
}),
});

export const collections = {
areas,
authors,
kb,
overview: kb,
social,
kb,
overview,
thoughts,
};
5 changes: 5 additions & 0 deletions src/content/thoughts/202501151709.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
date: Jan 15 2025, 17:13 -0400
---

My four sources of meaning in life, in a strict order - beauty, love, knowledge, and work.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/lib/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function processCollectionItem(item) {
};

return {
params: { slug },
params: { slug, id: slug },
props: { page: { ...item, slug } },
};
}
Expand Down
7 changes: 4 additions & 3 deletions src/pages/kb/rss.xml.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { render } from "astro:content";
import { experimental_AstroContainer } from "astro/container";
import { getEntry, getCollection } from "astro:content";
import rss from "@astrojs/rss";
Expand All @@ -10,12 +11,12 @@ const {

export const prerender = true;

export async function render({ params: { slug }, props: { page } }) {
export async function offline_render({ params: { slug }, props: { page } }) {
const {
data: { title, description, date, updated },
} = page;

const { Content } = await page.render();
const { Content } = await render(page);
const container = await experimental_AstroContainer.create();
const content = await container.renderToString(Content);

Expand All @@ -40,7 +41,7 @@ const allPages = (
}) => !unlisted,
);

const rssItems = await Promise.all(allPages.map(render));
const rssItems = await Promise.all(allPages.map(offline_render));

export async function GET({ site }) {
return rss({
Expand Down
15 changes: 11 additions & 4 deletions src/pages/thoughts/[page].astro
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
---
import { getCollection } from "astro:content";
import { getCollection, render } from "astro:content";
import THtml from "@components/THtml.astro";
import Date from "@components/Date.astro";
export async function getStaticPaths({ paginate }) {
const thoughts = await getCollection("thoughts");
return paginate(thoughts.reverse(), { pageSize: 19 });
const thoughts = (await getCollection("thoughts")).sort(
({ data: { date: dateA } }, { data: { date: dateB } }) => {
if (dateA < dateB) {
return 1;
}
return -1;
},
);
return paginate(thoughts, { pageSize: 19 });
}
export const prerender = true;
Expand All @@ -33,7 +40,7 @@ const {
<section>
{
data.map(async (page) => {
const { Content } = await page.render();
const { Content } = await render(page);
const {
data: { date },
} = page;
Expand Down

0 comments on commit 250d06b

Please sign in to comment.