-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathastro.config.ts
More file actions
42 lines (37 loc) · 1.31 KB
/
astro.config.ts
File metadata and controls
42 lines (37 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { defineConfig } from "astro/config";
import mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap";
import react from "@astrojs/react";
import node from "@astrojs/node";
import fs from "node:fs";
import remarkPythonRefs from "./src/plugins/remark-python-refs";
const isDev = process.env.NODE_ENV === "development" || process.argv.includes("dev");
// Load redirects generated by the migration script
let redirects: Record<string, string> = {};
try {
const redirectsPath = new URL("./src/data/redirects.json", import.meta.url);
redirects = JSON.parse(fs.readFileSync(redirectsPath, "utf-8"));
} catch {
// No redirects file yet (run migration first)
}
// Old Blogger feed URL is handled by src/pages/feeds/posts/default/index.ts
// so RSS readers get actual XML instead of an HTML meta-refresh redirect.
// Keystatic integration only in dev mode (requires server rendering)
const integrations = [mdx(), sitemap(), react()];
if (isDev) {
const keystatic = (await import("@keystatic/astro")).default;
integrations.push(keystatic());
}
export default defineConfig({
site: "https://blog.python.org",
base: "/",
integrations,
output: isDev ? "server" : "static",
...(isDev && {
adapter: node({ mode: "standalone" }),
}),
markdown: {
remarkPlugins: [remarkPythonRefs],
},
redirects,
});