~james/core

core/docs/astro.config.mjs -rw-r--r-- 6.5 KiB
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 16 hours ago
                                                                                
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
// @ts-check
import { fileURLToPath } from "node:url";
import { defineConfig } from "astro/config";
import starlight from "@astrojs/starlight";
import starlightLlmActions from "starlight-llm-actions";
import starlightLinksValidator from "starlight-links-validator";
import sitemap from "@astrojs/sitemap";
import svelte from "@astrojs/svelte";
import tailwindcss from "@tailwindcss/vite";
import Icons from "unplugin-icons/vite";
import { fontsBase } from "../web/src/fontsBase.mjs";

// the ui components are shared with the web app, imported straight from its
// source rather than published as a package
const webLib = fileURLToPath(new URL("../web/src/lib", import.meta.url));
const base = "/docs";

const svelteStyleFallback = {
	name: "svelte-style-fallback",
	enforce: "pre",
	transform(code, id) {
		if (!id.includes("svelte&type=style&lang.css")) return;
		if (!code.includes("<style")) return;
		const match = code.match(/<style[^>]*>([\s\S]*?)<\/style>/i);
		return { code: match ? match[1] : "", map: null };
	},
};

export default defineConfig({
	site: "https://tangled.org",
	// served at tangled.org/docs by the docs worker. the build lands in dist/docs
	// because static assets on workers are matched against the full request path
	base,
	outDir: "./dist/docs",
	integrations: [
		starlight({
			title: "Tangled Docs",
			titleDelimiter: "·",
			disable404Route: true,
			routeMiddleware: ["./src/starlightRouteData.ts"],
			tableOfContents: { minHeadingLevel: 2, maxHeadingLevel: 2 },
			plugins: [
				starlightLlmActions({
					renderMarkdown: "simple",
					linkAlternate: true,
					llmsTxt: { exclude: ["index"] },
				}),
				starlightLinksValidator(),
			],
			description:
				"Documentation for Tangled — decentralized code collaboration built on the AT Protocol.",
			social: [
				{ icon: "x.com", label: "X", href: "https://x.com/tangled_org" },
				{
					icon: "blueSky",
					label: "Bluesky",
					href: "https://bsky.app/profile/tangled.org",
				},
			],
			favicon: "/favicon.svg",
			head: [
				{
					tag: "link",
					attrs: {
						rel: "preload",
						href: `${base}/fonts/TimelessSansVF.woff2`,
						as: "font",
						type: "font/woff2",
						crossorigin: "anonymous",
					},
				},
				{
					tag: "link",
					// head entries are emitted verbatim; starlight only rebases `favicon`
					attrs: { rel: "apple-touch-icon", href: "/docs/apple-touch-icon.png" },
				},
			],
			editLink: {
				baseUrl: "https://tangled.org/@tangled.org/core/blob/master/docs/",
			},
			customCss: [
				"./src/styles/global.css",
				"./src/styles/tangled.css",
				"./src/styles/custom.css",
				"./src/styles/diagrams.css",
			],
			components: {
				Header: "./src/components/Header.astro",
				Hero: "./src/components/Hero.astro",
				MarkdownContent: "./src/components/MarkdownContent.astro",
				MobileMenuFooter: "./src/components/MobileMenuFooter.astro",
				PageTitle: "./src/components/PageTitle.astro",
				Sidebar: "./src/components/Sidebar.astro",
				SiteTitle: "./src/components/SiteTitle.astro",
				ThemeProvider: "./src/components/ThemeProvider.astro",
			},
			expressiveCode: {
				// same palettes as the web app's syntax tokens
				themes: ["catppuccin-macchiato", "catppuccin-latte"],
				// a plain bordered block like tangled.org's, no editor or terminal chrome
				defaultProps: { frame: "none" },
				styleOverrides: {
					// expressive-code adds borderWidth to this for the outer
					// radius, so subtract it to land on --radius-md exactly
					borderRadius: "calc(var(--radius-md) - 1px)",
					borderColor: "var(--color-border-default)",
					borderWidth: "1px",
					codeBackground: "var(--color-background-canvas)",
					codeFontFamily: "var(--font-mono)",
					codeFontSize: "0.8125rem",
					codeLineHeight: "1.5385",
					codePaddingBlock: "0.75rem",
					codePaddingInline: "0.75rem",
					frames: {
						shadowColor: "transparent",
						frameBoxShadowCssValue: "none",
					},
				},
			},
			sidebar: [
				{
					label: "Getting started",
					items: [
						"introduction",
						"quick-start",
						"comparison-with-github",
						"migrating-from-github",
						"why-atproto",
					],
				},
				{
					label: "Using Tangled",
					items: [
						"guides/profile",
						"guides/repositories",
						"guides/pull-requests",
						"guides/access",
						"guides/vouching",
						"guides/notifications",
						"guides/organizations",
						"guides/signing-commits",
						"guides/importing",
						"sites",
						"troubleshooting",
					],
				},
				{
					label: "Repositories",
					items: ["knots/repositories", "knots/self-hosting"],
				},
				{
					label: "Running CI",
					items: [
						"spindles",
						"spindles/writing-workflows",
						"spindles/workflows",
						"spindles/secrets",
						"spindles/webhooks",
						"spindles/self-hosting",
					],
				},
				{
					label: "Self-hosting",
					items: [
						"self-hosting",
						"self-hosting/knot",
						"self-hosting/spindle",
						"self-hosting/frontend",
						"self-hosting/indexer",
					],
				},
				{
					label: "Integrations",
					items: ["integrations/discord", "integrations/contributing"],
				},
				{
					label: "Upgrading",
					items: ["upgrading/knots-and-spindles", "upgrading/knot-2"],
				},
				{
					label: "API",
					items: ["api/knot", "api/spindle", "api/bobbin"],
				},
				{
					label: "Reference",
					items: [
						"reference/records",
						"reference/identifiers",
						"reference/knot-config",
						"reference/spindle-config",
					],
				},
				{
					label: "Contributing",
					items: ["contributing/hacking", "contributing/guide"],
				},
			],
		}),
		sitemap(),
		svelte(),
	],
	vite: {
		plugins: [svelteStyleFallback, tailwindcss(), Icons({ compiler: "svelte" }), fontsBase(base)],
		resolve: {
			// same aliases the web app's components import through
			alias: {
				$lib: webLib,
				// the web app's own imports (sveltekit 3 subpath imports)
				"#lib": webLib,
				"$icon/": "~icons/lucide/",
				// routing and environment are sveltekit-only; components that build hrefs or
				// guard browser apis import them
				"$app/paths": fileURLToPath(new URL("./src/stubs/app-paths.ts", import.meta.url)),
				"$app/env": fileURLToPath(new URL("./src/stubs/app-env.ts", import.meta.url)),
			},
			// web/ has no node_modules in the nix build: resolve the components'
			// runtime deps (and svelte itself, which must be a single copy) from here
			dedupe: ["svelte", "tailwind-variants", "tailwind-merge"],
		},
		server: {
			fs: {
				allow: [
					fileURLToPath(new URL(".", import.meta.url)),
					fileURLToPath(new URL("../web/src", import.meta.url)),
				],
			},
		},
	},
});