-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathastro.config.ts
More file actions
70 lines (66 loc) 路 2.12 KB
/
Copy pathastro.config.ts
File metadata and controls
70 lines (66 loc) 路 2.12 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
import { type AstroIntegration, type HookParameters } from "astro"
import { defineConfig } from "astro/config"
import { satteri } from "@astrojs/markdown-satteri"
import mdx from "@astrojs/mdx"
import sitemap from "@astrojs/sitemap"
import astroExpressiveCode, { ExpressiveCodeTheme } from "astro-expressive-code"
import { spawn } from "node:child_process"
import fs from "node:fs"
import { dirname, relative } from "node:path"
import { fileURLToPath } from "node:url"
import { astroMarkdownEndpoints } from "./src/integrations/astro-markdown-endpoints/index"
import { astroOpenGraph } from "./src/integrations/astro-open-graph/index"
import { markdownHastPlugins } from "./src/plugins/satteri/index"
export { astroOpenGraph } from "./src/integrations/astro-open-graph/index"
export const astroSearch = (): AstroIntegration => {
const integrationName = "astro-search"
return {
name: integrationName,
hooks: {
"astro:build:done": ({ dir }: HookParameters<"astro:build:done">) => {
const targetDir = fileURLToPath(dir)
const cwd = dirname(fileURLToPath(import.meta.url))
const relativeDir = relative(cwd, targetDir)
return new Promise<void>((resolve) => {
spawn("pagefind", ["--site", relativeDir], {
stdio: "inherit",
shell: true,
cwd,
}).on("close", () => resolve())
})
},
},
}
}
const jsoncString = fs.readFileSync(
new URL(`./src/themes/dracula.jsonc`, import.meta.url),
"utf-8",
)
const draculaTheme = ExpressiveCodeTheme.fromJSONString(jsoncString)
export default defineConfig({
integrations: [
astroExpressiveCode({
frames: {
showCopyToClipboardButton: true,
},
styleOverrides: {
codeFontFamily: "var(--font-mono)",
codeFontSize: "var(--text-sm)",
},
themes: [draculaTheme],
}),
astroOpenGraph(),
astroSearch(),
mdx(),
sitemap(),
astroMarkdownEndpoints(),
],
markdown: {
processor: satteri({
features: { smartPunctuation: false },
hastPlugins: markdownHastPlugins,
}),
},
prefetch: true,
site: "https://www.bws.bio",
})