-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathastro.config.mjs
71 lines (66 loc) · 2.06 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { defineConfig, sharpImageService } from 'astro/config';
import markdoc from '@astrojs/markdoc';
import sitemap from '@astrojs/sitemap';
import tailwind from '@astrojs/tailwind';
import vercel from '@astrojs/vercel/static';
import robotsTxt from 'astro-robots-txt';
import siteConfig from './site.config.mjs';
/*
We are doing some URL mumbo jumbo here to tell Astro what the URL of your website will be.
In local development, your SEO meta tags will have localhost URL.
In built production websites, your SEO meta tags should have your website URL.
So we give our website URL here and the template will know what URL to use
for meta tags during build.
If you don't know your website URL yet, don't worry about this
and leave it empty or use localhost URL. It won't break anything.
*/
const SERVER_PORT = 3000;
// the url to access your blog during local development
const LOCALHOST_URL = siteConfig.localhostURL;
const LIVE_URL = siteConfig.liveURL;
// this is the astro command your npm script runs
// When you're building your site in local or in CI, you could just set your URL manually
const SCRIPT = process.env.npm_lifecycle_script || '';
const isBuild = SCRIPT.includes('astro build');
const BASE_URL = isBuild ? LIVE_URL : LOCALHOST_URL;
// https://astro.build/config
export default defineConfig({
server: {
port: SERVER_PORT,
},
site: BASE_URL,
image: {
service: sharpImageService(),
},
prefetch: { prefetchAll: true },
integrations: [
markdoc(),
sitemap({
serialize(item) {
if ([`${siteConfig.liveURL}/`, `${siteConfig.liveURL}/blog/`].includes(item.url)) {
item.lastmod = new Date();
item.priority = 1;
}
return item;
},
}),
tailwind({
config: {
applyBaseStyles: false,
},
}),
robotsTxt(),
],
vite: {
define: {
'import.meta.env.PUBLIC_VERCEL_ANALYTICS_ID': JSON.stringify(process.env.VERCEL_ANALYTICS_ID),
},
},
adapter: vercel({
webAnalytics: {
enabled: true,
},
maxDuration: 8,
}),
output: 'static',
});