-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathastro.config.ts
More file actions
101 lines (91 loc) · 2.67 KB
/
astro.config.ts
File metadata and controls
101 lines (91 loc) · 2.67 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
import mdx from "@astrojs/mdx";
import sitemap from "@astrojs/sitemap";
import solidJs from "@astrojs/solid-js";
import tailwind from "@astrojs/tailwind";
import { transformerTwoslash } from "@shikijs/twoslash";
import { defineConfig, envField } from "astro/config";
import { dirname } from "node:path";
import { fileURLToPath } from "node:url";
import { rehypePlugins, remarkPlugins } from "./src/build-time";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// Production URL
const hostname = "zaduma.vercel.app";
const site = `https://${hostname}/`;
// https://astro.build/config
export default defineConfig({
site,
env: {
schema: {
OG_IMAGE_SECRET: envField.string({
context: "server",
access: "secret",
}),
},
},
markdown: {
syntaxHighlight: "shiki",
shikiConfig: {
themes: {
light: "github-light",
dark: "github-dark",
},
transformers: [
transformerTwoslash({
explicitTrigger: true,
twoslashOptions: {
compilerOptions: {
strict: true,
module: 199 /* NodeNext */,
moduleResolution: 99 /* NodeNext */,
target: 99 /* ESNext */,
types: ["node"],
},
},
}),
],
},
gfm: true,
},
integrations: [
tailwind({
applyBaseStyles: false,
}),
mdx({
extendMarkdownConfig: true,
// MDX integration inherits all remark plugins from markdown.remarkPlugins
remarkPlugins: remarkPlugins(__dirname),
rehypePlugins: rehypePlugins,
}),
solidJs(),
sitemap(),
],
vite: {
ssr: {
noExternal: [
"@fontsource-variable/inter",
"@fontsource-variable/brygada-1918",
],
},
define: {
"import.meta.env.PUBLIC_URL": JSON.stringify(makePublicURL()),
},
},
});
function makePublicURL() {
const VERCEL_URL = process.env.VERCEL_URL;
const DEPLOYMENT_ALIAS = process.env.DEPLOYMENT_ALIAS;
// If the site is built on vercel, we can just use VERCEL_URL.
if (VERCEL_URL) return VERCEL_URL;
if (!DEPLOYMENT_ALIAS) {
// If there's no DEPLOYMENT_ALIAS nor VERCEL_URL, we assume we're building locally.
return "http://localhost:3000/";
}
// Otherwise, we build on GitHub Actions (and get access to Git History).
// If DEPLOYMENT_ALIAS is set to `main--${hostname}`, we're on the main branch,
// and we return the canonical URL.
if (DEPLOYMENT_ALIAS === `main--${hostname}`) return site;
// Otherwise, we're building a preview deployment, and set the deployment alias
// in `import.meta.env.PUBLIC_URL`.
return `https://${DEPLOYMENT_ALIAS}`;
}