-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.ts
42 lines (36 loc) · 1.22 KB
/
astro.config.ts
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 { copyFile, rm } from "node:fs/promises";
import { fileURLToPath } from "node:url";
import { relative } from "node:path";
import sitemap from "@astrojs/sitemap";
// https://astro.build/config
export default defineConfig({
site: "https://example.com",
integrations: [
mdx(),
sitemap(),
import.meta.env.DEV
? undefined
: {
name: "html-to-aspx",
hooks: {
"astro:build:done": async (ctx) => {
const dir = fileURLToPath(ctx.dir);
await Promise.all(
ctx.routes.map(async (route) => {
if (route.type !== "page" || !route.distURL) return;
const target = fileURLToPath(route.distURL);
const dest = target.toString().replace(".html", ".aspx");
const targetForLog = relative(dir, target);
const destForLog = relative(dir, dest);
await copyFile(target, dest);
await rm(target);
ctx.logger.info(`move: "${targetForLog}" -> "${destForLog}"`);
})
);
},
},
},
],
});