-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathastro.config.ts
More file actions
119 lines (115 loc) · 4.03 KB
/
astro.config.ts
File metadata and controls
119 lines (115 loc) · 4.03 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
import { existsSync, readFileSync } from 'node:fs';
import { extname, join } from 'node:path';
import { RemarkPlugin } from '@astrojs/markdown-remark';
import mdx from '@astrojs/mdx';
import react from '@astrojs/react';
import sitemap from '@astrojs/sitemap';
import vue from '@astrojs/vue';
import { defineConfig } from 'astro/config';
import AutoImport from 'astro-auto-import';
import { astroExpressiveCode } from 'astro-expressive-code';
import icon from 'astro-icon';
import dotenv from 'dotenv';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeSlug from 'rehype-slug';
import remarkSmartypants from 'remark-smartypants';
import { asideAutoImport, astroAsides } from './integrations/astro-asides';
import { astroYoutubeEmbeds, youtubeAutoImport } from './integrations/astro-youtube-embed';
import { PagefindIndex } from './integrations/pagefind-index';
import { autolinkConfig } from './plugins/rehype-autolink-config';
import { rehypeOptimizeStatic } from './plugins/rehype-optimize-static';
import { rehypeTasklistEnhancer } from './plugins/rehype-tasklist-enhancer';
import { rehypeWrapTables } from './plugins/rehype-wrap-tables';
import { remarkBuildkiteVersionPlugin } from './plugins/remark-buildkite-version';
import { remarkEnterpriseVersionPlugin } from './plugins/remark-enterprise-version';
import { remarkGraphvizPlugin } from './plugins/remark-graphviz';
dotenv.config({
path: `.env.${process.env.NODE_ENV}`,
});
// https://astro.build/config
export default defineConfig({
site: process.env.SITE_URL ? process.env.SITE_URL : 'https://docs.mergify.com',
integrations: [
AutoImport({
imports: [asideAutoImport, youtubeAutoImport],
}),
astroAsides(),
astroYoutubeEmbeds(),
astroExpressiveCode(),
mdx(),
react(),
vue(),
sitemap({
// To be iso with gatsby's sitemap, not sure it's useful
changefreq: 'daily',
priority: 0.7,
filter: (page) =>
!page.includes('/enterprise') &&
!page.includes('/support/premium') &&
!page.includes('/merge-queue/migrate-partitions-to-scopes'),
}),
PagefindIndex(),
icon({
include: {
lucide: ['*'],
octicon: ['*'],
'simple-icons': ['*'],
},
}),
],
compressHTML: false,
vite: {
plugins: [
{
// Pagefind's JS bundle is not a standard ES module Vite can transform.
// Serve it directly from public/ so dynamic `import('/pagefind/pagefind.js')` works in dev.
name: 'pagefind-static',
configureServer(server) {
server.middlewares.use((req, res, next) => {
if (!req.url?.startsWith('/pagefind/')) return next();
const cleanPath = req.url.split('?')[0];
const filePath = join(process.cwd(), 'public', cleanPath);
if (!existsSync(filePath)) return next();
const mimeTypes: Record<string, string> = {
'.js': 'application/javascript',
'.json': 'application/json',
'.wasm': 'application/wasm',
};
res.setHeader(
'Content-Type',
mimeTypes[extname(filePath)] ?? 'application/octet-stream'
);
res.end(readFileSync(filePath));
});
},
},
],
},
markdown: {
// Override with our own config
smartypants: false,
remarkPlugins: [
remarkBuildkiteVersionPlugin(),
remarkEnterpriseVersionPlugin(),
remarkGraphvizPlugin(),
[
remarkSmartypants as RemarkPlugin,
{
dashes: false,
},
],
],
rehypePlugins: [
rehypeSlug,
// This adds links to headings
[rehypeAutolinkHeadings, autolinkConfig],
// Tweak GFM task list syntax
rehypeTasklistEnhancer(),
// Wrap markdown tables in a scrollable container
rehypeWrapTables(),
// Collapse static parts of the hast to html
/** Issue with graphviz where inline styles get transformed: `font-size` => `fontsize` whch breaks rendered graphs SVG */
rehypeOptimizeStatic,
],
},
});