-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathastro.config.mjs
More file actions
130 lines (122 loc) · 4.49 KB
/
Copy pathastro.config.mjs
File metadata and controls
130 lines (122 loc) · 4.49 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
// @ts-check
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
import path from 'node:path';
import tailwindcss from '@tailwindcss/vite';
import mdx from '@astrojs/mdx';
import react from '@astrojs/react';
import remarkDirective from 'remark-directive';
import rehypeSlug from 'rehype-slug';
import { highlightLinesTransformer } from './src/plugins/shiki-highlight-transformer.mjs';
import { remarkAside } from './src/plugins/remark-aside.mjs';
import { remarkTransformRequire } from './src/plugins/remark-transform-require.mjs';
import { remarkTransformDetails } from './src/plugins/remark-transform-details.mjs';
import { remarkHeadingId } from './src/plugins/remark-heading-id.mjs';
import { remarkTransformLinks } from './src/plugins/remark-transform-links.mjs';
import { remarkStripImports } from './src/plugins/remark-strip-imports.mjs';
import { remarkStripHighlightComments } from './src/plugins/remark-strip-highlight-comments.mjs';
import { remarkFloatClear } from './src/plugins/remark-float-clear.mjs';
// https://astro.build/config
export default defineConfig({
site: 'https://adapty.io',
base: '/docs',
outDir: './build',
build: {
inlineStylesheets: 'never',
},
vite: {
plugins: [
tailwindcss(),
],
server: {
watch: {
ignored: [
'**/.DS_Store',
'**/.Spotlight-V100/**',
'**/.DocumentRevisions-V100/**',
'**/.astro/**',
],
},
},
define: {
global: 'window',
'process.env': '{}',
},
resolve: {
alias: {
'@site': path.resolve('./'),
'@components': path.resolve('./src/components'),
'react-medium-image-zoom/dist/styles.css': path.resolve('./src/styles/empty.css'),
'react-medium-image-zoom': path.resolve('./src/components/ZoomShim.tsx'),
}
}
},
markdown: {
remarkPlugins: [remarkHeadingId, remarkDirective, remarkAside, remarkFloatClear, remarkStripImports, remarkStripHighlightComments, remarkTransformRequire, remarkTransformDetails, remarkTransformLinks],
rehypePlugins: [rehypeSlug],
shikiConfig: {
theme: 'github-light',
wrap: true,
transformers: [
{
name: 'title-transformer',
pre(node) {
// Extract title from meta
const meta = this.options.meta?.__raw || '';
const titleMatch = meta.match(/title="([^"]+)"/);
if (titleMatch) {
node.properties['data-title'] = titleMatch[1];
}
// Add language attribute for badge display
const lang = this.options.lang || '';
if (lang) {
node.properties['data-language'] = lang;
}
}
},
highlightLinesTransformer()
]
},
},
integrations: [
react(),
sitemap({
// Exclude localized pages — they are covered by locale-specific sitemaps (e.g. sitemap-zh-index.xml)
filter: (page) => !page.includes('/docs/zh/') && !page.includes('/docs/tr/') && !page.includes('/docs/ru/') && !page.includes('/docs/es/') && !page.includes('/docs/ja/'),
// Strip trailing slashes so sitemap URLs match the canonical tags emitted by DocsLayout.
// The canonical strips trailing slashes (DocsLayout.astro:35-37), so the sitemap must too.
// Mismatch causes the Algolia crawler (ignoreCanonicalTo: false) to skip sitemap entries.
serialize: (item) => ({
...item,
url: item.url.endsWith('/') ? item.url.slice(0, -1) : item.url,
}),
}),
mdx({
remarkPlugins: [remarkHeadingId, remarkDirective, remarkAside, remarkFloatClear, remarkStripImports, remarkStripHighlightComments, remarkTransformRequire, remarkTransformDetails, remarkTransformLinks],
rehypePlugins: [rehypeSlug],
shikiConfig: {
theme: 'github-light',
wrap: true,
transformers: [
{
name: 'title-transformer',
pre(node) {
// Extract title from meta
const meta = this.options.meta?.__raw || '';
const titleMatch = meta.match(/title="([^"]+)"/);
if (titleMatch) {
node.properties['data-title'] = titleMatch[1];
}
// Add language attribute for badge display
const lang = this.options.lang || '';
if (lang) {
node.properties['data-language'] = lang;
}
}
},
highlightLinesTransformer()
]
}
})
]
});