Migrate to Astro 5

This commit is contained in:
Bad Manners 2024-12-03 19:09:09 -03:00
parent 5d701069e9
commit bb1e533a00
Signed by: badmanners
GPG key ID: 8C88292CCB075609
129 changed files with 1408 additions and 1448 deletions
.vscode
astro.config.mjs
examples
package-lock.jsonpackage.json
scripts
src
components
content.config.ts
data
blog
games
series
stories
tag-categories
users
i18n
integrations

20
.vscode/settings.json vendored
View file

@ -2,24 +2,10 @@
"files.associations": { "files.associations": {
"*.css": "tailwindcss" "*.css": "tailwindcss"
}, },
"json.schemas": [
{
"fileMatch": ["/src/content/series/**"],
"url": "./.astro/collections/series.schema.json"
},
{
"fileMatch": ["/src/content/tag-categories/**"],
"url": "./.astro/collections/tag-categories.schema.json"
},
{
"fileMatch": ["/src/content/users/**"],
"url": "./.astro/collections/users.schema.json"
}
],
"yaml.schemas": { "yaml.schemas": {
"./.astro/collections/series.schema.json": "/src/content/series/**", "./.astro/collections/series.schema.json": "/src/data/series/**",
"./.astro/collections/tag-categories.schema.json": "/src/content/tag-categories/**", "./.astro/collections/tag-categories.schema.json": "/src/data/tag-categories/**",
"./.astro/collections/users.schema.json": "/src/content/users/**" "./.astro/collections/users.schema.json": "/src/data/users/**"
}, },
"[astro]": { "[astro]": {
"editor.defaultFormatter": "esbenp.prettier-vscode" "editor.defaultFormatter": "esbenp.prettier-vscode"

View file

@ -60,15 +60,14 @@ export default defineConfig({
redirects: { redirects: {
"/stories/1": "/stories", "/stories/1": "/stories",
}, },
experimental: { env: {
env: { schema: {
schema: { APACHE_CONFIG: envField.boolean({ context: "server", access: "public", default: false }),
PUBLISH_DRAFTS: envField.boolean({ PUBLISH_DRAFTS: envField.boolean({
context: "server", context: "server",
access: "public", access: "public",
default: false, default: false,
}), }),
},
}, },
}, },
}); });

View file

@ -1,5 +1,5 @@
--- ---
# slug: some-custom-slug # id: some-custom-id
title: Example Blog Post title: Example Blog Post
# pubDate: 2024-01-01 # pubDate: 2024-01-01
isDraft: true isDraft: true

View file

@ -1,5 +1,5 @@
--- ---
# slug: some-custom-slug # id: some-custom-id
title: Example Game title: Example Game
# shortTitle: Example # shortTitle: Example
# pubDate: 2024-01-01 # pubDate: 2024-01-01

View file

@ -1,5 +1,5 @@
--- ---
# slug: some-custom-slug # id: some-custom-id
title: Example Story title: Example Story
# shortTitle: Example # shortTitle: Example
# pubDate: 2024-01-01 # pubDate: 2024-01-01

2560
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,7 +1,7 @@
{ {
"name": "gallery.badmanners.xyz", "name": "gallery.badmanners.xyz",
"type": "module", "type": "module",
"version": "1.13.1", "version": "1.14.0",
"scripts": { "scripts": {
"postinstall": "astro sync", "postinstall": "astro sync",
"dev": "astro dev", "dev": "astro dev",
@ -17,16 +17,16 @@
"dependencies": { "dependencies": {
"@astrojs/alpinejs": "^0.4.0", "@astrojs/alpinejs": "^0.4.0",
"@astrojs/check": "^0.9.4", "@astrojs/check": "^0.9.4",
"@astrojs/mdx": "^3.1.7", "@astrojs/mdx": "^4.0.1",
"@astrojs/rss": "^4.0.7", "@astrojs/rss": "^4.0.9",
"@astrojs/tailwind": "^5.1.1", "@astrojs/tailwind": "^5.1.3",
"@astropub/md": "^1.0.0", "@astropub/md": "^1.0.0",
"@pagefind/default-ui": "^1.2.0", "@pagefind/default-ui": "^1.2.0",
"@tailwindcss/typography": "^0.5.15", "@tailwindcss/typography": "^0.5.15",
"@types/alpinejs": "^3.13.10", "@types/alpinejs": "^3.13.10",
"alpinejs": "^3.14.1", "alpinejs": "^3.14.1",
"astro": "^4.15.11", "astro": "^5.0.1",
"astro-htaccess": "^0.2.0", "astro-htaccess": "^0.2.3",
"clsx": "^2.1.1", "clsx": "^2.1.1",
"fluid-tailwind": "^1.0.3", "fluid-tailwind": "^1.0.3",
"github-slugger": "^2.0.0", "github-slugger": "^2.0.0",

View file

@ -7,7 +7,7 @@ import { createInterface } from "node:readline";
import { program } from "commander"; import { program } from "commander";
import fetchRetryWrapper from "fetch-retry"; import fetchRetryWrapper from "fetch-retry";
import type { HealthcheckResponse } from "../src/pages/api/healthcheck"; import type { HealthcheckResponse } from "../src/pages/api/healthcheck";
import type { ExportStoryResponse } from "../src/pages/api/export-story/[...slug]"; import type { ExportStoryResponse } from "../src/pages/api/export-story/[...id]";
function getRTFStyles(rtfSource: string) { function getRTFStyles(rtfSource: string) {
const matches = rtfSource.matchAll( const matches = rtfSource.matchAll(
@ -46,7 +46,7 @@ const isLibreOfficeRunning = async () =>
lines.on("close", () => res(false)); lines.on("close", () => res(false));
}); });
async function exportStory(slug: string, options: { outputDir: string }) { async function exportStory(id: string, options: { outputDir: string }) {
/* Check that LibreOffice is not running */ /* Check that LibreOffice is not running */
if (await isLibreOfficeRunning()) { if (await isLibreOfficeRunning()) {
console.error("ERROR: LibreOffice cannot be open while this command is running!"); console.error("ERROR: LibreOffice cannot be open while this command is running!");
@ -103,7 +103,7 @@ async function exportStory(slug: string, options: { outputDir: string }) {
let storyText = ""; let storyText = "";
try { try {
console.log("Getting data from Astro..."); console.log("Getting data from Astro...");
const response = await fetch(new URL(`api/export-story/${slug}`, astroURL)); const response = await fetch(new URL(`api/export-story/${id}`, astroURL));
if (!response.ok) { if (!response.ok) {
throw new Error(`Failed to reach export-story API (status code ${response.status})`); throw new Error(`Failed to reach export-story API (status code ${response.status})`);
} }
@ -114,7 +114,7 @@ async function exportStory(slug: string, options: { outputDir: string }) {
// Story // Story
(async () => { (async () => {
storyText = data.story; storyText = data.story;
await writeFile(join(outputDir, `${slug}.txt`), storyText); await writeFile(join(outputDir, `${id}.txt`), storyText);
})(), })(),
// Descriptions // Descriptions
Object.entries(data.description).map( Object.entries(data.description).map(
@ -153,9 +153,9 @@ async function exportStory(slug: string, options: { outputDir: string }) {
console.log("Parsing story into output formats..."); console.log("Parsing story into output formats...");
// Process output files in parallel // Process output files in parallel
await Promise.all([ await Promise.all([
// ${slug}.md // ${id}.md
writeFile(join(outputDir, `${slug}.md`), storyText.replaceAll(/=(?==)/g, "= ").replaceAll("*", "\\*")), writeFile(join(outputDir, `${id}.md`), storyText.replaceAll(/=(?==)/g, "= ").replaceAll("*", "\\*")),
// ${slug}.rtf // ${id}.rtf
(async () => { (async () => {
const tempDir = await mkdtemp(join(tmpdir(), "export-story-")); const tempDir = await mkdtemp(join(tmpdir(), "export-story-"));
await writeFile(join(tempDir, "temp.txt"), storyText.replaceAll(/\n\n+/g, "\n")); await writeFile(join(tempDir, "temp.txt"), storyText.replaceAll(/\n\n+/g, "\n"));
@ -174,7 +174,7 @@ async function exportStory(slug: string, options: { outputDir: string }) {
console.warn(`Missing RTF style "Normal"! Skipping RTF file generation.`); console.warn(`Missing RTF style "Normal"! Skipping RTF file generation.`);
} else { } else {
await writeFile( await writeFile(
join(outputDir, `${slug}.rtf`), join(outputDir, `${id}.rtf`),
rtfText.replaceAll(rtfStyles["Preformatted Text"], rtfStyles["Normal"]), rtfText.replaceAll(rtfStyles["Preformatted Text"], rtfStyles["Normal"]),
); );
} }
@ -187,7 +187,7 @@ async function exportStory(slug: string, options: { outputDir: string }) {
await program await program
.name("export-story") .name("export-story")
.description("Generate and export formatted upload files for a story") .description("Generate and export formatted upload files for a story")
.argument("<story-slug>", `Slug portion of the story's URL (eg. "the-lost-of-the-marshes/chapter-1")`) .argument("<story-id>", `ID portion of the story's URL (eg. "the-lost-of-the-marshes/chapter-1")`)
.option("-o, --output-dir <directory>", `Empty or inexistent directory path to export files to`) .option("-o, --output-dir <directory>", `Empty or inexistent directory path to export files to`)
.action(exportStory) .action(exportStory)
.parseAsync(); .parseAsync();

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 { t, type Lang } from "@i18n";
import UserComponent from "./UserComponent.astro"; import UserComponent from "./UserComponent.astro";
import CopyrightedCharactersItem from "./CopyrightedCharactersItem.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 { t, type Lang } from "@i18n";
import { IconEkasPortal, IconFurAffinity, IconInkbunny, IconSoFurry, IconWeasyl } from "./icons/brands"; import { IconEkasPortal, IconFurAffinity, IconInkbunny, IconSoFurry, IconWeasyl } from "./icons/brands";
@ -16,7 +16,7 @@ const isVisible = eka || furaffinity || inkbunny || sofurry || weasyl;
{ {
isVisible ? ( isVisible ? (
<section id="external-posts-section" class="my-5 px-2 font-serif" aria-describedby="title-external-posts"> <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"> <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")} {t(lang, "published_content/syndication_see_also_on")}
</h2> </h2>
@ -87,7 +87,7 @@ const isVisible = eka || furaffinity || inkbunny || sofurry || weasyl;
</li> </li>
) : null} ) : null}
</ul> </ul>
</> </Fragment>
</section> </section>
) : null ) : null
} }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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