-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathastro.config.ts
More file actions
172 lines (161 loc) · 5.11 KB
/
Copy pathastro.config.ts
File metadata and controls
172 lines (161 loc) · 5.11 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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
import { satteri } from "@astrojs/markdown-satteri";
import starlight from "@astrojs/starlight";
import type { StarlightConfig } from "@astrojs/starlight/types";
import { defineConfig, fontProviders } from "astro/config";
import { satteriRelativeMarkdownLinks } from "@system76/satteri-relative-markdown-links";
import { viteStaticCopy } from "vite-plugin-static-copy";
import wrapImagesWithOriginals from "./src/plugins/satteri-wrap-images-with-originals.ts";
import { generateSidebar } from "./src/plugins/summary-to-sidebar.ts";
type HeadConfig = NonNullable<StarlightConfig["head"]>[number];
const base = "tech-docs";
const buildEnv = process.env.BUILD_ENV ?? "local";
const siteByBuildEnv = {
local: `http://localhost:4321/${base}`,
staging: `https://genesis76.com/${base}`,
production: `https://system76.com/${base}`,
};
if (!(buildEnv in siteByBuildEnv)) {
throw new Error(
`Invalid BUILD_ENV "${buildEnv}", expected one of: ${Object.keys(siteByBuildEnv).join(", ")}`,
);
}
function googleAnalyticsHead(): HeadConfig[] {
if (buildEnv !== "production") {
return [];
}
return [
{
tag: "script",
attrs: {
async: true,
src: "https://www.googletagmanager.com/gtag/js?id=G-H37KSF3165",
},
},
{
tag: "script",
content: `window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-H37KSF3165');`,
},
];
}
const site = siteByBuildEnv[buildEnv as keyof typeof siteByBuildEnv];
// https://astro.build/config
export default defineConfig({
integrations: [
starlight({
title: "System76 Technical Documentation",
logo: {
light: "./src/assets/img/system76_logo-light.svg",
dark: "./src/assets/img/system76_logo-dark.svg",
replacesTitle: true,
},
lastUpdated: true,
social: [
{
icon: "x.com",
label: "Twitter",
href: "https://x.com/system76",
},
{
icon: "linkedin",
label: "LinkedIn",
href: "https://www.linkedin.com/company/system76",
},
{
icon: "reddit",
label: "reddit",
href: "https://www.reddit.com/r/System76/",
},
{
icon: "github",
label: "GitHub",
href: "https://github.com/system76",
},
],
sidebar: generateSidebar(
new URL("./src/SUMMARY.md", import.meta.url).pathname,
),
tableOfContents: false, // Turned on per-page.
favicon: "/favicon.png",
customCss: [
"./src/assets/css/variables.css",
"./src/assets/css/img-background.css",
"./src/assets/css/toc-width-fix.css",
],
locales: {
root: {
label: "English",
lang: "en",
},
},
routeMiddleware: "./src/plugins/toc-formatting-middleware.ts",
components: {
Head: "./src/components/Head.astro",
},
head: [...googleAnalyticsHead()],
}),
],
base,
site,
fonts: [
{
provider: fontProviders.fontsource(),
name: "Fira Sans",
cssVariable: "--font-fira-sans",
weights: [400, 700],
styles: ["normal"],
subsets: ["latin"],
},
{
provider: fontProviders.fontsource(),
name: "Roboto Slab",
cssVariable: "--font-roboto-slab",
weights: [400, 700],
styles: ["normal"],
subsets: ["latin"],
},
{
provider: fontProviders.fontsource(),
name: "Ubuntu Mono",
cssVariable: "--font-ubuntu-mono",
weights: [400],
styles: ["normal"],
subsets: ["latin"],
},
],
image: {
service: {
entrypoint: "./src/avifImageService.mjs",
},
layout: "constrained",
responsiveStyles: true,
},
markdown: {
processor: satteri({
mdastPlugins: [
satteriRelativeMarkdownLinks({
base,
collectionBase: false,
}),
wrapImagesWithOriginals({
base,
}),
],
}),
},
vite: {
plugins: [
viteStaticCopy({
targets: [
{
src: "src/content/docs/**/*.{jpg,jpeg,png,gif,webp,tiff,avif}",
dest: "originals",
rename: { stripBase: 3 },
},
],
}),
],
},
});