-
-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathastro.config.mjs
More file actions
132 lines (131 loc) · 4.19 KB
/
astro.config.mjs
File metadata and controls
132 lines (131 loc) · 4.19 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
122
123
124
125
126
127
128
129
130
131
132
import { defineConfig } from "astro/config"
import { plainTextPlugin } from "@barnabask/astro-minisearch"
import { remarkReadingTime } from "./src/lib/remark-reading-time.mjs"
import { remarkPublicImages } from "./src/lib/remark-public-images.mjs"
import { remarkCallouts } from "./src/lib/remark-callouts.mjs"
import downloadDdevRedirects from "./src/lib/download-ddev-redirects.js"
import prefetch from "@astrojs/prefetch"
import react from "@astrojs/react"
import { rehypeAccessibleEmojis } from "rehype-accessible-emojis"
import rehypeAstroRelativeMarkdownLinks from "astro-rehype-relative-markdown-links"
import { rehypeWrapTables } from "./src/lib/rehype-wrap-tables.mjs"
import rehypeAutolinkHeadings from "rehype-autolink-headings"
import rehypeExternalLinks from "rehype-external-links"
import rehypeFigure from "rehype-figure"
import rehypeSlug from "rehype-slug"
import rehypeUnwrapImages from "rehype-unwrap-images"
import remarkDirective from "remark-directive"
import remarkGfm from "remark-gfm"
import remarkToc from "remark-toc"
import robotsTxt from "astro-robots-txt"
import searchIndex from "./src/lib/search-index.js"
import sitemap from "@astrojs/sitemap"
import tailwindcss from "@tailwindcss/vite"
import { addCopyButton } from "shiki-transformer-copy-button"
import { SHIKI_THEMES } from "./src/const.ts"
// https://astro.build/config
export default defineConfig({
site: "https://ddev.com",
vite: {
server: {
allowedHosts: [
process.env.DDEV_TLD ? "." + process.env.DDEV_TLD : undefined,
// Allow Coder workspace hosts derived from VSCODE_PROXY_URI
// e.g. "https://{{port}}--main--ddev-com--rfay.coder.ddev.com" → ".coder.ddev.com"
process.env.VSCODE_PROXY_URI?.match(/^https?:\/\/[^.]+\.(.+)$/)?.[1]
? "." +
process.env.VSCODE_PROXY_URI.match(/^https?:\/\/[^.]+\.(.+)$/)?.[1]
: undefined,
].filter(Boolean),
},
// Configure CORS for the dev server (security)
cors: { origin: process.env.DDEV_PRIMARY_URL },
plugins: [tailwindcss()],
optimizeDeps: {
include: ["astro/toolbar"],
},
},
integrations: [
react(),
sitemap({
serialize(item) {
if (
item.url.endsWith(".json/") ||
item.url.endsWith(".svg/") ||
item.url.endsWith(".xml/")
) {
// Don't index sitemaps or generated SVG, which come with `/` route endings here
return undefined
}
return item
},
}),
robotsTxt({
sitemap: true,
}),
searchIndex({
output: "search.json",
}),
downloadDdevRedirects(),
prefetch(),
],
markdown: {
syntaxHighlight: "shiki",
// https://github.com/shikijs/shiki/blob/main/docs/languages.md
shikiConfig: {
themes: SHIKI_THEMES,
defaultColor: false,
// You can add options to the transformer here
// For example, to change the 'copied' state duration:
// toggle: 3000, // 3 seconds
transformers: [
addCopyButton({
// visibility: 'hover', // if you want it to only show on hover
}),
],
},
remarkPlugins: [
remarkPublicImages,
remarkReadingTime,
remarkDirective,
remarkCallouts,
remarkGfm, // GitHub Flavored Markdown (tables, strikethrough, task lists, autolinks)
[
remarkToc,
{
heading: "table of contents", // Case-insensitive heading to look for
tight: true, // Compact lists
},
],
],
rehypePlugins: [
rehypeSlug,
[
rehypeAutolinkHeadings,
{
behavior: "wrap",
},
],
[
rehypeExternalLinks,
{
target: "_blank",
rel: ["noopener", "noreferrer"],
},
],
rehypeFigure, // Wrap images in <figure> with <figcaption>
rehypeUnwrapImages, // Remove paragraph wrappers after figure processing
rehypeAccessibleEmojis, // Add accessible labels to emojis
plainTextPlugin({
contentKey: "plainText",
removeEmoji: false,
headingTags: ["h2", "h3"],
}),
rehypeAstroRelativeMarkdownLinks,
rehypeWrapTables,
],
},
image: {
domains: ["avatars.githubusercontent.com"],
},
})