-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathblume.config.ts
More file actions
165 lines (156 loc) · 4.44 KB
/
Copy pathblume.config.ts
File metadata and controls
165 lines (156 loc) · 4.44 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
import { defineConfig } from "blume";
interface ThemeMetadata {
value: string;
color_scheme: "dark" | "light";
preview: {
darker: string;
dark: string;
primary: string;
content: string;
};
docs: {
muted: string;
muted_foreground: string;
border: string;
accent_foreground: string;
code_background: string;
};
}
interface BunRuntime {
file(path: URL): { text(): Promise<string> };
YAML: { parse(source: string): unknown };
}
const bun = (globalThis as typeof globalThis & { Bun: BunRuntime }).Bun;
const themes = bun.YAML.parse(
await bun.file(new URL("./config/themes.yml", import.meta.url)).text(),
) as ThemeMetadata[];
const defaultTheme = themes.find((theme) => theme.value === "neon");
if (!defaultTheme) throw new Error("The default Neon theme is missing");
const docsThemes = Object.fromEntries(
themes.map((theme) => [
theme.value,
{
colorScheme: theme.color_scheme,
tokens: {
"--blume-background": theme.preview.darker,
"--blume-foreground": theme.preview.content,
"--blume-muted": theme.docs.muted,
"--blume-muted-foreground": theme.docs.muted_foreground,
"--blume-border": theme.docs.border,
"--blume-accent": theme.preview.primary,
"--blume-accent-foreground": theme.docs.accent_foreground,
"--blume-code-background": theme.docs.code_background,
},
},
]),
);
const themeScript = `(() => {
const themes = ${JSON.stringify(docsThemes)};
const cookie = document.cookie
.split("; ")
.find((entry) => entry.startsWith("hackatime_theme="));
const selected = cookie
? cookie.slice("hackatime_theme=".length)
: "neon";
const theme = Object.hasOwn(themes, selected) ? selected : "neon";
const { colorScheme, tokens } = themes[theme];
document.documentElement.dataset.hackatimeTheme = theme;
document.documentElement.dataset.theme = colorScheme;
for (const [property, value] of Object.entries(tokens)) {
document.documentElement.style.setProperty(property, value);
}
try {
localStorage.setItem("blume-theme", colorScheme);
} catch {}
})();`;
export default defineConfig({
title: "Hackatime Docs",
description:
"Learn how to set up Hackatime, track your coding time, and build integrations.",
basePath: "/docs",
logo: {
image: "/images/new-icon-rounded.png",
text: "Hackatime",
href: "/docs",
},
github: {
owner: "hackclub",
repo: "hackatime",
},
navigation: {
sidebar: {
display: "page",
},
},
integrations: [
{
name: "hackatime-docs-theme",
hooks: {
"astro:config:setup": ({ injectScript }) => {
injectScript("head-inline", themeScript);
},
},
},
],
theme: {
accent: defaultTheme.preview.primary,
background: defaultTheme.preview.dark,
mode: defaultTheme.color_scheme,
radius: "lg",
},
deployment: {
output: "static",
site: "https://hackatime.hackclub.com",
},
redirects: [
{
from: "/getting-started/configuration",
to: "/configuration",
status: 301,
},
],
analytics: {
scripts: [
{
content: `window.addEventListener("blume:track", (event) => {
if (event.detail?.event !== "feedback") return;
let visitorToken = localStorage.getItem("hackatime-docs-visitor");
if (!visitorToken) {
visitorToken = crypto.randomUUID();
localStorage.setItem("hackatime-docs-visitor", visitorToken);
}
fetch("/docs/feedback", {
method: "POST",
credentials: "same-origin",
keepalive: true,
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
helpful: event.detail.props.helpful === "yes",
path: event.detail.props.path,
title: event.detail.props.title,
visitor_token: visitorToken,
}),
}).catch(() => {});
});`,
},
],
},
seo: {
og: {
enabled: true,
logo: "/images/hackatime-icon.svg",
palette: {
accent: defaultTheme.preview.primary,
background: defaultTheme.preview.darker,
foreground: defaultTheme.preview.content,
muted: defaultTheme.docs.muted_foreground,
border: defaultTheme.docs.border,
},
},
rss: { enabled: false },
sitemap: true,
robots: false,
structuredData: true,
x: { handle: "@hackclub" },
},
});