forked from playfulprogramming/playfulprogramming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
astro.config.ts
85 lines (81 loc) · 2.26 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import { defineConfig, AstroUserConfig } from "astro/config";
import preact from "@astrojs/preact";
import sitemap from "@astrojs/sitemap";
import icon from "astro-icon";
import { EnumChangefreq as ChangeFreq } from "sitemap";
import { siteUrl } from "./src/constants/site-config";
import vercel from "@astrojs/vercel/static";
import symlink from "symlink-dir";
import * as path from "path";
import { languages } from "./src/constants/index";
import { fileToOpenGraphConverter } from "./src/utils/translations";
import { posts } from "./src/utils/data";
import { SUPPORTED_IMAGE_SIZES } from "./src/utils/get-picture";
await symlink(path.resolve("content"), path.resolve("public/content"));
export default defineConfig({
site: siteUrl,
adapter: vercel({
// Uses Vercel's Image Optimization API: https://vercel.com/docs/image-optimization
imageService: true,
imagesConfig: {
sizes: SUPPORTED_IMAGE_SIZES,
domains: [],
formats: ["image/avif", "image/webp"],
},
devImageService: "sharp",
}),
integrations: [
icon(),
preact({ compat: true }),
sitemap({
changefreq: ChangeFreq.DAILY,
priority: 0.7,
lastmod: new Date(),
i18n: {
defaultLocale: "en",
locales: Object.keys(languages).reduce(
(prev, key) => {
prev[key] = fileToOpenGraphConverter(key as keyof typeof languages);
return prev;
},
{} as Record<string, string>,
),
},
filter(page) {
// return true, unless last part of the URL ends with "_noindex"
// in which case it should not be in the sitemap
const lastPartOfSlug = page
.split("/")
.filter((part) => !!part.length)
.at(-1);
if (lastPartOfSlug!.endsWith("_noindex")) return false;
const relatedPost = posts.get(lastPartOfSlug!);
if (relatedPost && relatedPost[0]?.originalLink) return false;
return true;
},
serialize({ url, ...rest }) {
return {
// remove trailing slash from sitemap URLs
url: url.replace(/\/$/g, ""),
...rest,
};
},
}),
],
vite: {
optimizeDeps: {
exclude: ["msw", "msw/node", "sharp"],
},
ssr: {
external: ["svgo"],
noExternal: [
"react-aria",
"react-stately",
/@react-aria/,
/@react-stately/,
/@react-types/,
],
},
},
markdown: {} as AstroUserConfig["markdown"] as never,
});