-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.mjs
56 lines (53 loc) · 1.25 KB
/
astro.config.mjs
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
import { defineConfig } from 'astro/config'
import vue from '@astrojs/vue'
// https://github.com/hexojs/hexo-renderer-stylus/blob/master/lib/renderer.js
import cloudflare from '@astrojs/cloudflare'
import { config } from './src/config'
function getProperty(obj, name) {
name = name.replace(/\[(\w+)\]/g, '.$1').replace(/^\./, '')
const split = name.split('.')
let key = split.shift()
if (!Object.prototype.hasOwnProperty.call(obj, key))
return ''
let result = obj[key]
const len = split.length
if (!len) {
if (result === 0)
return result
return result || ''
}
if (typeof result !== 'object')
return ''
for (let i = 0; i < len; i++) {
key = split[i]
if (!Object.prototype.hasOwnProperty.call(result, key))
return ''
result = result[split[i]]
if (typeof result !== 'object')
return result
}
return result
}
const define = {
'astro-config': (data) => {
return getProperty(config, data.val)
},
}
// https://astro.build/config
export default defineConfig({
site: 'https://example.com',
output: 'static',
integrations: [vue()],
vite: {
ssr: {
external: ['node:fs'],
},
css: {
preprocessorOptions: {
stylus: {
define,
},
},
},
}
})