-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathastro.config.mjs
More file actions
121 lines (116 loc) · 3.68 KB
/
Copy pathastro.config.mjs
File metadata and controls
121 lines (116 loc) · 3.68 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
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// astro.config.mjs
// @ts-check
import * as fs from "node:fs";
import mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap";
import cloudflare from "@astrojs/cloudflare";
import { defineConfig } from "astro/config";
import { unified } from "@astrojs/markdown-remark";
import icon from "astro-iconset";
import feedDiscovery from "./src/integrations/feed-discovery.ts";
import opengraphImages from "./src/integrations/opengraph-images.ts";
import webmentionsIntegration from "./src/integrations/webmentions.ts";
import remarkMermaid from "./src/remark/remark-mermaid.ts";
const isDrafts = process.env.INCLUDE_DRAFTS === "true";
const siteUrl = isDrafts ? "https://drafts.msfjarvis.dev" : "https://msfjarvis.dev";
const webmentionWorkerOrigin = process.env.WEBMENTION_WORKER_ORIGIN;
const webmentionAuthToken = process.env.WEBMENTION_AUTH_TOKEN;
const { renderCollectionCard } = await import("./src/og/renderers/collection-card.tsx");
export default defineConfig({
site: siteUrl,
output: "server",
markdown: {
processor: unified({
gfm: true,
smartypants: true,
remarkPlugins: [remarkMermaid],
}),
},
integrations: [
mdx(),
sitemap(),
icon({
include: {
"simple-icons": ["mastodon", "forgejo"],
},
}),
opengraphImages({
matchPathname: (pathname) => /^(posts|notes|weeknotes)\/[^/]+\/$/.test(pathname),
options: {
verbose: false,
fonts: [
{
name: "JetBrains Mono",
weight: 600,
style: "normal",
data: fs.readFileSync(
"node_modules/@fontsource/jetbrains-mono/files/jetbrains-mono-latin-600-normal.woff",
),
},
{
name: "Inter",
weight: 400,
style: "normal",
data: fs.readFileSync(
"node_modules/@fontsource/inter/files/inter-latin-400-normal.woff",
),
},
{
name: "Inter",
weight: 600,
style: "normal",
data: fs.readFileSync(
"node_modules/@fontsource/inter/files/inter-latin-600-normal.woff",
),
},
],
},
render: renderCollectionCard,
}),
feedDiscovery(),
webmentionsIntegration({
siteUrl,
workerOrigin: webmentionWorkerOrigin,
authToken: webmentionAuthToken,
}),
],
adapter: cloudflare({
imageService: "compile",
prerenderEnvironment: "workerd",
}),
vite: {
plugins: [
{
// Sätteri ships a Rust/NAPI binary with a WASM browser fallback that
// imports @napi-rs/wasm-runtime — a browser-only peer not installed in
// this project. The Cloudflare adapter sets noExternal:true so Rolldown
// tries to bundle everything, hitting the unresolvable import.
// Marking it external is safe: satteri only runs at build time, never
// in the Cloudflare Worker at runtime.
// TODO: remove once @astrojs/cloudflare or @astrojs/markdown-satteri
// handles this automatically (similar to how sharp is already excluded).
name: "satteri-externals",
enforce: "post",
config(cfg) {
const existing = Array.isArray(cfg.build?.rolldownOptions?.external)
? cfg.build.rolldownOptions.external
: [];
return {
build: { rolldownOptions: { external: [...existing, "@napi-rs/wasm-runtime"] } },
};
},
},
],
ssr: {
external: ["@resvg/resvg-js", "mermaid"],
},
optimizeDeps: {
exclude: ["@resvg/resvg-js"],
},
server: {
watch: {
ignored: ["**/.direnv/**", "**/node_modules/**"],
},
},
},
});