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": {
"*.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": {
"./.astro/collections/series.schema.json": "/src/content/series/**",
"./.astro/collections/tag-categories.schema.json": "/src/content/tag-categories/**",
"./.astro/collections/users.schema.json": "/src/content/users/**"
"./.astro/collections/series.schema.json": "/src/data/series/**",
"./.astro/collections/tag-categories.schema.json": "/src/data/tag-categories/**",
"./.astro/collections/users.schema.json": "/src/data/users/**"
},
"[astro]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"

View file

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

View file

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

View file

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

View file

@ -1,5 +1,5 @@
---
# slug: some-custom-slug
# id: some-custom-id
title: Example Story
# shortTitle: Example
# 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",
"type": "module",
"version": "1.13.1",
"version": "1.14.0",
"scripts": {
"postinstall": "astro sync",
"dev": "astro dev",
@ -17,16 +17,16 @@
"dependencies": {
"@astrojs/alpinejs": "^0.4.0",
"@astrojs/check": "^0.9.4",
"@astrojs/mdx": "^3.1.7",
"@astrojs/rss": "^4.0.7",
"@astrojs/tailwind": "^5.1.1",
"@astrojs/mdx": "^4.0.1",
"@astrojs/rss": "^4.0.9",
"@astrojs/tailwind": "^5.1.3",
"@astropub/md": "^1.0.0",
"@pagefind/default-ui": "^1.2.0",
"@tailwindcss/typography": "^0.5.15",
"@types/alpinejs": "^3.13.10",
"alpinejs": "^3.14.1",
"astro": "^4.15.11",
"astro-htaccess": "^0.2.0",
"astro": "^5.0.1",
"astro-htaccess": "^0.2.3",
"clsx": "^2.1.1",
"fluid-tailwind": "^1.0.3",
"github-slugger": "^2.0.0",

View file

@ -7,7 +7,7 @@ import { createInterface } from "node:readline";
import { program } from "commander";
import fetchRetryWrapper from "fetch-retry";
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) {
const matches = rtfSource.matchAll(
@ -46,7 +46,7 @@ const isLibreOfficeRunning = async () =>
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 */
if (await isLibreOfficeRunning()) {
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 = "";
try {
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) {
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
(async () => {
storyText = data.story;
await writeFile(join(outputDir, `${slug}.txt`), storyText);
await writeFile(join(outputDir, `${id}.txt`), storyText);
})(),
// Descriptions
Object.entries(data.description).map(
@ -153,9 +153,9 @@ async function exportStory(slug: string, options: { outputDir: string }) {
console.log("Parsing story into output formats...");
// Process output files in parallel
await Promise.all([
// ${slug}.md
writeFile(join(outputDir, `${slug}.md`), storyText.replaceAll(/=(?==)/g, "= ").replaceAll("*", "\\*")),
// ${slug}.rtf
// ${id}.md
writeFile(join(outputDir, `${id}.md`), storyText.replaceAll(/=(?==)/g, "= ").replaceAll("*", "\\*")),
// ${id}.rtf
(async () => {
const tempDir = await mkdtemp(join(tmpdir(), "export-story-"));
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.`);
} else {
await writeFile(
join(outputDir, `${slug}.rtf`),
join(outputDir, `${id}.rtf`),
rtfText.replaceAll(rtfStyles["Preformatted Text"], rtfStyles["Normal"]),
);
}
@ -187,7 +187,7 @@ async function exportStory(slug: string, options: { outputDir: string }) {
await program
.name("export-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`)
.action(exportStory)
.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 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);

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