@voidzero-dev/vitepress-theme 3.0.0 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.ts +77 -0
- package/package.json +3 -2
package/config.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { UserConfig } from "vitepress";
|
|
2
|
+
import { resolve } from "path";
|
|
3
|
+
import tailwindcss from "@tailwindcss/vite";
|
|
4
|
+
import type { VoidZeroThemeConfig } from "./src";
|
|
5
|
+
|
|
6
|
+
const __dirname = import.meta.dirname;
|
|
7
|
+
|
|
8
|
+
const aliases = {
|
|
9
|
+
"@assets": resolve(__dirname, "src/assets"),
|
|
10
|
+
"@components": resolve(__dirname, "src/components"),
|
|
11
|
+
"@vp-default": resolve(__dirname, "src/components/vitepress-default"),
|
|
12
|
+
"@vp-composables": resolve(
|
|
13
|
+
__dirname,
|
|
14
|
+
"src/composables/vitepress-default"
|
|
15
|
+
),
|
|
16
|
+
"@vp-support": resolve(__dirname, "src/support/vitepress-default"),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function extendConfig<T>(c: T): T {
|
|
20
|
+
const config = c as UserConfig;
|
|
21
|
+
|
|
22
|
+
// inject banner dismissal inline script in head
|
|
23
|
+
// so that the dismissed class is added before CSS is loaded
|
|
24
|
+
const bannerId = (config.themeConfig as VoidZeroThemeConfig).banner?.id;
|
|
25
|
+
if (bannerId) {
|
|
26
|
+
config.head ??= [];
|
|
27
|
+
config.head.unshift([
|
|
28
|
+
"script",
|
|
29
|
+
{},
|
|
30
|
+
`if (localStorage.getItem("banner-dismissed-${bannerId}") === 'true')
|
|
31
|
+
document.documentElement.classList.add("banner-dismissed")`,
|
|
32
|
+
]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const v = (config.vite ??= {});
|
|
36
|
+
|
|
37
|
+
// inject fs allow so this can be linked locally
|
|
38
|
+
v.server ??= {}
|
|
39
|
+
v.server.fs ??= {}
|
|
40
|
+
v.server.fs.allow ??= []
|
|
41
|
+
v.server.fs.allow.push(__dirname)
|
|
42
|
+
|
|
43
|
+
// add riv file asset include
|
|
44
|
+
const a = (v.assetsInclude ??= []);
|
|
45
|
+
if (!Array.isArray(a)) {
|
|
46
|
+
v.assetsInclude = [a, "**/*.riv"];
|
|
47
|
+
} else {
|
|
48
|
+
a.push("**/*.riv");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// inject tailwind plugin
|
|
52
|
+
v.plugins ??= [];
|
|
53
|
+
v.plugins.unshift(tailwindcss() as any);
|
|
54
|
+
|
|
55
|
+
// inject alias
|
|
56
|
+
v.resolve ??= {};
|
|
57
|
+
v.resolve.alias ??= {};
|
|
58
|
+
Object.assign(v.resolve.alias, aliases);
|
|
59
|
+
|
|
60
|
+
const pkg = "@voidzero-dev/vitepress-theme";
|
|
61
|
+
|
|
62
|
+
// inject optimize exclude
|
|
63
|
+
v.optimizeDeps ??= {};
|
|
64
|
+
v.optimizeDeps.exclude ??= [];
|
|
65
|
+
v.optimizeDeps.exclude.push(pkg);
|
|
66
|
+
|
|
67
|
+
// inject ssr no-external
|
|
68
|
+
v.ssr ??= {};
|
|
69
|
+
const e = (v.ssr.noExternal ??= []);
|
|
70
|
+
if (!Array.isArray(e)) {
|
|
71
|
+
if (e !== true) v.ssr.noExternal = [e, pkg];
|
|
72
|
+
} else {
|
|
73
|
+
e.push(pkg);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return c;
|
|
77
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voidzero-dev/vitepress-theme",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Shared VitePress theme for VoidZero projects",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "UNLICENSED",
|
|
7
7
|
"main": "./src/index.ts",
|
|
8
8
|
"module": "./src/index.ts",
|
|
9
9
|
"files": [
|
|
10
|
-
"src"
|
|
10
|
+
"src",
|
|
11
|
+
"config.ts"
|
|
11
12
|
],
|
|
12
13
|
"sideEffects": [
|
|
13
14
|
"*.css"
|