Migrate to Astro 5

This commit is contained in:
Bad Manners 2024-12-03 19:09:09 -03:00
parent 5d701069e9
commit bb1e533a00
No known key found for this signature in database
GPG key ID: 8C88292CCB075609
129 changed files with 1408 additions and 1448 deletions

View file

@ -1,5 +1,5 @@
---
import type { CopyrightedCharacters } from "@content/config";
import type { CopyrightedCharacters } from "src/content.config";
import { t, type Lang } from "@i18n";
import UserComponent from "./UserComponent.astro";
import CopyrightedCharactersItem from "./CopyrightedCharactersItem.astro";

View file

@ -1,5 +1,5 @@
---
import type { Posts } from "@content/config";
import type { Posts } from "src/content.config";
import { t, type Lang } from "@i18n";
import { IconEkasPortal, IconFurAffinity, IconInkbunny, IconSoFurry, IconWeasyl } from "./icons/brands";
@ -16,7 +16,7 @@ const isVisible = eka || furaffinity || inkbunny || sofurry || weasyl;
{
isVisible ? (
<section id="external-posts-section" class="my-5 px-2 font-serif" aria-describedby="title-external-posts">
<>
<Fragment>
<h2 id="title-external-posts" class="py-2 font-serif text-xl font-semibold text-stone-800 dark:text-stone-100">
{t(lang, "published_content/syndication_see_also_on")}
</h2>
@ -87,7 +87,7 @@ const isVisible = eka || furaffinity || inkbunny || sofurry || weasyl;
</li>
) : null}
</ul>
</>
</Fragment>
</section>
) : null
}

View file

@ -1,4 +1,5 @@
import { defineCollection, reference, z } from "astro:content";
import { glob } from "astro/loaders";
// Constants
@ -258,7 +259,7 @@ export type Posts = PublishedContent["posts"];
// Content collections
const storiesCollection = defineCollection({
type: "content",
loader: glob({ pattern: "**/*.{md,mdx}", base: "./src/data/stories" }),
schema: ({ image }) =>
z
.object({
@ -287,7 +288,7 @@ const storiesCollection = defineCollection({
});
const gamesCollection = defineCollection({
type: "content",
loader: glob({ pattern: "**/*.{md,mdx}", base: "./src/data/games" }),
schema: ({ image }) =>
z
.object({
@ -309,7 +310,7 @@ const gamesCollection = defineCollection({
});
const blogCollection = defineCollection({
type: "content",
loader: glob({ pattern: "**/*.{md,mdx}", base: "./src/data/blog" }),
schema: ({ image }) =>
z
.object({
@ -328,7 +329,7 @@ const blogCollection = defineCollection({
// Data collections
const usersCollection = defineCollection({
type: "data",
loader: glob({ pattern: "*.{yml,yaml}", base: "./src/data/users" }),
schema: ({ image }) =>
z
.object({
@ -349,7 +350,7 @@ const usersCollection = defineCollection({
});
const seriesCollection = defineCollection({
type: "data",
loader: glob({ pattern: "*.{yml,yaml}", base: "./src/data/series" }),
schema: z.object({
// Required parameters
name: z.string(),
@ -358,7 +359,7 @@ const seriesCollection = defineCollection({
});
const tagCategoriesCollection = defineCollection({
type: "data",
loader: glob({ pattern: "*.{yml,yaml}", base: "./src/data/tag-categories" }),
schema: z.object({
// Required parameters
name: z.string(),

View file

@ -1,5 +1,4 @@
---
slug: ssh-all-the-way-down
title: SSH all the way down!
pubDate: 2024-09-22
isAgeRestricted: false

View file

@ -1,5 +1,4 @@
---
slug: supercharged-ssh-apps-on-sish
title: Supercharged SSH applications on sish
pubDate: 2024-09-23
isAgeRestricted: false

View file

@ -1,5 +1,4 @@
---
slug: engaged-in-reality
title: Engaged in Reality
pubDate: 2024-11-01
authors: bad-manners

View file

@ -1,5 +1,4 @@
---
slug: playing-it-safe
title: Playing It Safe
pubDate: 2024-08-08
authors: bad-manners

View file

@ -1,5 +1,5 @@
import { type GamePlatform, type Lang, DEFAULT_LANG } from "@content/config";
export { type Lang, DEFAULT_LANG } from "@content/config";
import { type GamePlatform, type Lang, DEFAULT_LANG } from "src/content.config";
export { type Lang, DEFAULT_LANG } from "src/content.config";
const UI_STRINGS = {
// Utility functions

View file

@ -24,7 +24,7 @@ export default function pagefind(config: PagefindConfig = {}): AstroIntegration
outDir = fileURLToPath(new URL(".vercel/output/static/", config.root));
} else if (config.adapter?.name === "@astrojs/cloudflare") {
outDir = fileURLToPath(new URL(config.base?.replace(/^\//, ""), config.outDir));
} else if (config.adapter?.name === "@astrojs/node" && config.output === "hybrid") {
} else if (config.adapter?.name === "@astrojs/node") {
outDir = fileURLToPath(config.build.client!);
} else {
outDir = fileURLToPath(config.outDir);

View file

@ -33,13 +33,13 @@ const relatedBlogPosts = (await getEntries(props.relatedBlogPosts)).filter((post
series={series}
prev={prev && !prev.data.isDraft
? {
link: `/blog/${prev.slug}`,
link: `/blog/${prev.id}`,
title: t(props.lang, "blog/previous_post", prev.data.title),
}
: undefined}
next={next && !next.data.isDraft
? {
link: `/blog/${next.slug}`,
link: `/blog/${next.id}`,
title: t(props.lang, "blog/next_post", next.data.title),
}
: undefined}

View file

@ -55,7 +55,7 @@ const isCurrentRoute = (path: string) =>
src={logo.src}
alt="A pixelated metal briefcase over a green gradient background."
class="u-logo my-4 w-full max-w-[192px] rounded-sm border-2 border-green-800 shadow-md dark:border-green-950"
width={192}
height={192}
/>
</a>
<span class="p-name mb-6 mt-4 text-3xl font-semibold">Bad Manners</span>
@ -124,9 +124,9 @@ const isCurrentRoute = (path: string) =>
currentYear === "2024" ? (
<time datetime="2024">2024</time>
) : (
<>
<Fragment>
<time datetime="2024">2024</time>&ndash;<time datetime={currentYear}>{currentYear}</time>
</>
</Fragment>
)
} |
</span>

View file

@ -35,10 +35,10 @@ const metaDescription = t(props.lang, "game/warnings", props.platforms, props.co
copyrightedCharacters={props.copyrightedCharacters}
series={series}
prev={prev && !prev.data.isDraft
? { link: `/games/${prev.slug}`, title: t(props.lang, "game/previous_game", prev.data.title) }
? { link: `/games/${prev.id}`, title: t(props.lang, "game/previous_game", prev.data.title) }
: undefined}
next={next && !next.data.isDraft
? { link: `/games/${next.slug}`, title: t(props.lang, "game/next_game", next.data.title) }
? { link: `/games/${next.id}`, title: t(props.lang, "game/next_game", next.data.title) }
: undefined}
relatedStories={relatedStories}
relatedGames={relatedGames}

View file

@ -9,7 +9,7 @@ import BaseLayout from "@layouts/BaseLayout.astro";
import CopyrightedCharacters from "@components/CopyrightedCharacters.astro";
import Prose from "@components/Prose.astro";
import MastodonComments from "@components/MastodonComments.astro";
import type { CopyrightedCharacters as CopyrightedCharactersType, Posts } from "@content/config";
import type { CopyrightedCharacters as CopyrightedCharactersType, Posts } from "src/content.config";
import { qualifyLocalURLsInMarkdown } from "@utils/qualify_local_urls_in_markdown";
import {
IconSun,
@ -366,7 +366,7 @@ const returnTo = series
<ul class="font-serif">
{props.relatedStories.map((story) => (
<li>
<a href={`/stories/${story.slug}`}>{story.data.title}</a>
<a href={`/stories/${story.id}`}>{story.data.title}</a>
</li>
))}
</ul>
@ -387,7 +387,7 @@ const returnTo = series
<ul class="font-serif">
{props.relatedGames.map((game) => (
<li>
<a href={`/games/${game.slug}`}>{game.data.title}</a>
<a href={`/games/${game.id}`}>{game.data.title}</a>
</li>
))}
</ul>
@ -408,7 +408,7 @@ const returnTo = series
<ul class="font-serif">
{props.relatedBlogPosts.map((post) => (
<li>
<a href={`/blog/${post.slug}`}>{post.data.title}</a>
<a href={`/blog/${post.id}`}>{post.data.title}</a>
</li>
))}
</ul>

View file

@ -41,13 +41,13 @@ const metaDescription = t(props.lang, "story/warnings", wordCount, props.content
series={series}
prev={prev && !prev.data.isDraft
? {
link: `/stories/${prev.slug}`,
link: `/stories/${prev.id}`,
title: t(props.lang, "story/previous_story", prev.data.shortTitle || prev.data.title),
}
: undefined}
next={next && !next.data.isDraft
? {
link: `/stories/${next.slug}`,
link: `/stories/${next.id}`,
title: t(props.lang, "story/next_story", next.data.shortTitle || next.data.title),
}
: undefined}

View file

@ -8,6 +8,6 @@ import GalleryLayout from "@layouts/GalleryLayout.astro";
<meta name="description" content="The requested link could not be found." />
</Fragment>
<h1 class="m-2 text-3xl font-semibold text-stone-800 dark:text-stone-100">404 &ndash; Not Found</h1>
<hr class="mb-3 ml-[2px] mt-2 h-[4px] max-w-xs rounded-sm bg-stone-800 dark:bg-stone-100" aria-hidden />
<hr class="mb-3 ml-[2px] mt-2 h-[4px] max-w-xs rounded-sm bg-stone-800 dark:bg-stone-100" aria-hidden="true" />
<p class="my-4">The requested link could not be found. Make sure that the URL is correct.</p>
</GalleryLayout>

View file

@ -1,6 +1,6 @@
import type { APIRoute, GetStaticPaths } from "astro";
import { getCollection, type CollectionEntry, getEntries } from "astro:content";
import type { PostWebsite } from "@content/config";
import type { PostWebsite } from "src/content.config";
import { t } from "@i18n";
import { formatCopyrightedCharacters } from "@utils/format_copyrighted_characters";
import { markdownToBbcode } from "@utils/markdown_to_bbcode";
@ -36,7 +36,7 @@ type Props = {
};
type Params = {
slug: CollectionEntry<"stories">["slug"];
id: CollectionEntry<"stories">["id"];
};
export const getStaticPaths: GetStaticPaths = async () => {
@ -44,7 +44,7 @@ export const getStaticPaths: GetStaticPaths = async () => {
return [];
}
return (await getCollection("stories")).map((story) => ({
params: { slug: story.slug } satisfies Params,
params: { id: story.id } satisfies Params,
props: { story } satisfies Props,
}));
};
@ -52,6 +52,9 @@ export const getStaticPaths: GetStaticPaths = async () => {
export const GET: APIRoute<Props, Params> = async ({ props: { story }, site }) => {
try {
const { lang } = story.data;
if (!story.body) {
throw new Error("Story body cannot be empty");
}
const copyrightedCharacters = await formatCopyrightedCharacters(story.data.copyrightedCharacters);
const authorsList = await getEntries(story.data.authors);
const commissionersList = story.data.commissioners && (await getEntries(story.data.commissioners));

View file

@ -1,13 +1,13 @@
---
import type { GetStaticPaths } from "astro";
import { type CollectionEntry, getCollection } from "astro:content";
import { type CollectionEntry, getCollection, render } from "astro:content";
import { PUBLISH_DRAFTS } from "astro:env/server";
import BlogPostLayout from "@layouts/BlogPostLayout.astro";
type Props = CollectionEntry<"blog">;
type Params = {
slug: CollectionEntry<"blog">["slug"];
id: CollectionEntry<"blog">["id"];
};
export const getStaticPaths: GetStaticPaths = async () => {
@ -15,13 +15,13 @@ export const getStaticPaths: GetStaticPaths = async () => {
return posts
.filter((post) => import.meta.env.DEV || PUBLISH_DRAFTS || !post.data.isDraft)
.map((post) => ({
params: { slug: post.slug } satisfies Params,
params: { id: post.id } satisfies Params,
props: post satisfies Props,
}));
};
const post = Astro.props;
const { Content } = await post.render();
const { Content } = await render(post);
---
<BlogPostLayout {...post.data}>

Some files were not shown because too many files have changed in this diff Show more