starlight-theme-bejamas 0.0.0-canary.0138fd3
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/CHANGELOG.md +132 -0
- package/package.json +50 -0
- package/src/config.test.ts +40 -0
- package/src/config.ts +51 -0
- package/src/env.d.ts +16 -0
- package/src/global.d.ts +20 -0
- package/src/index.ts +152 -0
- package/src/lib/theme-choice.test.ts +251 -0
- package/src/lib/theme-choice.ts +346 -0
- package/src/lib/theme-stylesheet-runtime.test.ts +246 -0
- package/src/lib/theme-stylesheet.test.ts +16 -0
- package/src/lib/theme-stylesheet.ts +123 -0
- package/src/lib/utils.ts +6 -0
- package/src/lib/vite.ts +62 -0
- package/src/overrides/Footer.astro +143 -0
- package/src/overrides/Header.astro +166 -0
- package/src/overrides/Hero.astro +175 -0
- package/src/overrides/MobileTableOfContents.astro +275 -0
- package/src/overrides/PageFrame.astro +287 -0
- package/src/overrides/PageTitle.astro +142 -0
- package/src/overrides/Pagination.astro +57 -0
- package/src/overrides/Sidebar.astro +54 -0
- package/src/overrides/SiteTitle.astro +59 -0
- package/src/overrides/TableOfContents/TableOfContentsList.astro +88 -0
- package/src/overrides/TableOfContents/starlight-toc.ts +125 -0
- package/src/overrides/ThemeProvider.astro +198 -0
- package/src/overrides/ThemeSelect.astro +110 -0
- package/src/styles/theme.css +776 -0
- package/src/virtual-internal.d.ts +40 -0
- package/src/virtual-modules.d.ts +28 -0
- package/src/virtual.d.ts +12 -0
- package/tsconfig.json +11 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# starlight-theme-bejamas
|
|
2
|
+
|
|
3
|
+
## 0.2.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#143](https://github.com/bejamas/ui/pull/143) [`94b6e69`](https://github.com/bejamas/ui/commit/94b6e698d22920f974d263709828cb9cfaa1bce5) Thanks [@Tadzik-2](https://github.com/Tadzik-2)! - Publish semantic icons publicly and validate packed release manifests so the theme installs without workspace protocol or private runtime dependencies.
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`94b6e69`](https://github.com/bejamas/ui/commit/94b6e698d22920f974d263709828cb9cfaa1bce5)]:
|
|
10
|
+
- @bejamas/semantic-icons@0.1.1
|
|
11
|
+
|
|
12
|
+
## 0.2.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#102](https://github.com/bejamas/ui/pull/102) [`25987b8`](https://github.com/bejamas/ui/commit/25987b872d38280dfe47f820019f86c1cb00eb6d) Thanks [@thomkrupa](https://github.com/thomkrupa)! - Improve the Starlight Bejamas theme runtime and expose the shared theme-choice helpers for consumers that need to integrate with theme state directly.
|
|
17
|
+
- Unify light, dark, and auto theme choice handling across the theme picker, page chrome, and preview surfaces so theme state stays in sync more reliably.
|
|
18
|
+
- Refresh browser theme-color metadata and the active theme stylesheet more consistently when theme state or presets change.
|
|
19
|
+
- Sync semantic icon updates as part of the theme runtime so icon-library changes propagate cleanly with preset-driven theme updates.
|
|
20
|
+
- Export `starlight-theme-bejamas/lib/theme-choice` as a public entrypoint for consumers that want to read, apply, or react to the shared theme-choice state.
|
|
21
|
+
|
|
22
|
+
## 0.1.18
|
|
23
|
+
|
|
24
|
+
### Patch Changes
|
|
25
|
+
|
|
26
|
+
- [#83](https://github.com/bejamas/ui/pull/83) [`4e1ceaf`](https://github.com/bejamas/ui/commit/4e1ceaf8ab8dc2405f06b5124bf5bdb2bfae44bc) Thanks [@thomkrupa](https://github.com/thomkrupa)! - fix typo
|
|
27
|
+
|
|
28
|
+
## 0.1.17
|
|
29
|
+
|
|
30
|
+
### Patch Changes
|
|
31
|
+
|
|
32
|
+
- [#80](https://github.com/bejamas/ui/pull/80) [`c3f2b3a`](https://github.com/bejamas/ui/commit/c3f2b3a2f94f8c60657e33bab49320a5d5258e11) Thanks [@thomkrupa](https://github.com/thomkrupa)! - fix shared splash layout bg
|
|
33
|
+
|
|
34
|
+
- [#82](https://github.com/bejamas/ui/pull/82) [`043d0fa`](https://github.com/bejamas/ui/commit/043d0faa76a34f25620f7ad8bc30d8aa9be8e3be) Thanks [@thomkrupa](https://github.com/thomkrupa)! - fix sidebar margin
|
|
35
|
+
|
|
36
|
+
## 0.1.16
|
|
37
|
+
|
|
38
|
+
### Patch Changes
|
|
39
|
+
|
|
40
|
+
- [#78](https://github.com/bejamas/ui/pull/78) [`a2d6526`](https://github.com/bejamas/ui/commit/a2d6526f3c6e205d1ccd219665afef299263db9c) Thanks [@thomkrupa](https://github.com/thomkrupa)! - improve mobile design
|
|
41
|
+
|
|
42
|
+
## 0.1.15
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- [#71](https://github.com/bejamas/ui/pull/71) [`4e38086`](https://github.com/bejamas/ui/commit/4e38086536db86aa7e25dbad3da28dcb0027f7a6) Thanks [@thomkrupa](https://github.com/thomkrupa)! - remove scrollbar from sidebar
|
|
47
|
+
|
|
48
|
+
## 0.1.14
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- [#66](https://github.com/bejamas/ui/pull/66) [`50515c3`](https://github.com/bejamas/ui/commit/50515c39115a0febdfa683db9263257ec4338baf) Thanks [@thomkrupa](https://github.com/thomkrupa)! - remove margin from console
|
|
53
|
+
|
|
54
|
+
## 0.1.13
|
|
55
|
+
|
|
56
|
+
### Patch Changes
|
|
57
|
+
|
|
58
|
+
- [#60](https://github.com/bejamas/ui/pull/60) [`045558f`](https://github.com/bejamas/ui/commit/045558f12df6d2a1bcff82254baf06c79fbdd623) Thanks [@thomkrupa](https://github.com/thomkrupa)! - update theme switcher to new select
|
|
59
|
+
|
|
60
|
+
## 0.1.12
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
- [#51](https://github.com/bejamas/ui/pull/51) [`342c66c`](https://github.com/bejamas/ui/commit/342c66cf9ebb85fa07de8d3f3d17074c82afe527) Thanks [@thomkrupa](https://github.com/thomkrupa)! - fix max-height for code
|
|
65
|
+
|
|
66
|
+
## 0.1.11
|
|
67
|
+
|
|
68
|
+
### Patch Changes
|
|
69
|
+
|
|
70
|
+
- [#47](https://github.com/bejamas/ui/pull/47) [`099bc0f`](https://github.com/bejamas/ui/commit/099bc0f20772cc1e4e1d86e39f208737339a5693) Thanks [@thomkrupa](https://github.com/thomkrupa)! - improve background colors
|
|
71
|
+
|
|
72
|
+
## 0.1.10
|
|
73
|
+
|
|
74
|
+
### Patch Changes
|
|
75
|
+
|
|
76
|
+
- [#45](https://github.com/bejamas/ui/pull/45) [`171f2fe`](https://github.com/bejamas/ui/commit/171f2fe63c2cb795f0f3cb30c1c16f37b5af62c1) Thanks [@thomkrupa](https://github.com/thomkrupa)! - make the page description a bit more narrow
|
|
77
|
+
|
|
78
|
+
## 0.1.9
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- [#42](https://github.com/bejamas/ui/pull/42) [`dd91b4e`](https://github.com/bejamas/ui/commit/dd91b4edbfd43a08a0b6766057b9c991bb18a5f0) Thanks [@thomkrupa](https://github.com/thomkrupa)! - improve table styling
|
|
83
|
+
|
|
84
|
+
## 0.1.8
|
|
85
|
+
|
|
86
|
+
### Patch Changes
|
|
87
|
+
|
|
88
|
+
- [#40](https://github.com/bejamas/ui/pull/40) [`58fbd77`](https://github.com/bejamas/ui/commit/58fbd775b67b2e132662ecfd9e69f674b004e675) Thanks [@thomkrupa](https://github.com/thomkrupa)! - improve z-indexes for code blocks
|
|
89
|
+
|
|
90
|
+
## 0.1.7
|
|
91
|
+
|
|
92
|
+
### Patch Changes
|
|
93
|
+
|
|
94
|
+
- [#30](https://github.com/bejamas/ui/pull/30) [`4f2f6d4`](https://github.com/bejamas/ui/commit/4f2f6d41ba455d0dc87ee8db45974f78c7ca4a7d) Thanks [@thomkrupa](https://github.com/thomkrupa)! - decrease inline padding for mobile component preview
|
|
95
|
+
|
|
96
|
+
## 0.1.6
|
|
97
|
+
|
|
98
|
+
### Patch Changes
|
|
99
|
+
|
|
100
|
+
- [#25](https://github.com/bejamas/ui/pull/25) [`001ddca`](https://github.com/bejamas/ui/commit/001ddcae75e510cd5f2afca4e24af6412bf84ed9) Thanks [@thomkrupa](https://github.com/thomkrupa)! - improve source preview
|
|
101
|
+
|
|
102
|
+
## 0.1.5
|
|
103
|
+
|
|
104
|
+
### Patch Changes
|
|
105
|
+
|
|
106
|
+
- [#19](https://github.com/bejamas/ui/pull/19) [`bd4c3a0`](https://github.com/bejamas/ui/commit/bd4c3a0b596718a25aefaf7b30d185d30693618a) Thanks [@thomkrupa](https://github.com/thomkrupa)! - improve page footer ui
|
|
107
|
+
|
|
108
|
+
## 0.1.4
|
|
109
|
+
|
|
110
|
+
### Patch Changes
|
|
111
|
+
|
|
112
|
+
- [#17](https://github.com/bejamas/ui/pull/17) [`5751b96`](https://github.com/bejamas/ui/commit/5751b9652384891bc740947a654650cff272c2c1) Thanks [@thomkrupa](https://github.com/thomkrupa)! - improve pagination spacing
|
|
113
|
+
|
|
114
|
+
## 0.1.3
|
|
115
|
+
|
|
116
|
+
### Patch Changes
|
|
117
|
+
|
|
118
|
+
- [#15](https://github.com/bejamas/ui/pull/15) [`067a92b`](https://github.com/bejamas/ui/commit/067a92bd34171b5403c7033cd2cccd54ad7ffe41) Thanks [@thomkrupa](https://github.com/thomkrupa)! - improve codeblock ui
|
|
119
|
+
|
|
120
|
+
## 0.1.2
|
|
121
|
+
|
|
122
|
+
### Patch Changes
|
|
123
|
+
|
|
124
|
+
- [#6](https://github.com/bejamas/ui/pull/6) [`fcca220`](https://github.com/bejamas/ui/commit/fcca220c0d4760edbaaefbfe2ce0af512bfadc26) Thanks [@thomkrupa](https://github.com/thomkrupa)! - convert component names to PascalCase for barrel import
|
|
125
|
+
|
|
126
|
+
- [#6](https://github.com/bejamas/ui/pull/6) [`41d9e97`](https://github.com/bejamas/ui/commit/41d9e97f7cee67e95d9c9eeb112762d1487d4e4f) Thanks [@thomkrupa](https://github.com/thomkrupa)! - change imports of bejamas/ui components
|
|
127
|
+
|
|
128
|
+
## 0.1.1
|
|
129
|
+
|
|
130
|
+
### Patch Changes
|
|
131
|
+
|
|
132
|
+
- fix search position on tablet screen size
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "starlight-theme-bejamas",
|
|
3
|
+
"author": "Bejamas",
|
|
4
|
+
"version": "0.0.0-canary.0138fd3",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"description": "A Starlight theme using bejamas/ui",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": "./src/index.ts",
|
|
10
|
+
"./config": "./src/config.ts",
|
|
11
|
+
"./lib/theme-choice": "./src/lib/theme-choice.ts",
|
|
12
|
+
"./styles/theme.css": "./src/styles/theme.css",
|
|
13
|
+
"./overrides/Header.astro": "./src/overrides/Header.astro",
|
|
14
|
+
"./overrides/PageFrame.astro": "./src/overrides/PageFrame.astro",
|
|
15
|
+
"./overrides/SiteTitle.astro": "./src/overrides/SiteTitle.astro",
|
|
16
|
+
"./overrides/Pagination.astro": "./src/overrides/Pagination.astro",
|
|
17
|
+
"./overrides/PageTitle.astro": "./src/overrides/PageTitle.astro",
|
|
18
|
+
"./overrides/Hero.astro": "./src/overrides/Hero.astro",
|
|
19
|
+
"./overrides/MobileTableOfContents.astro": "./src/overrides/MobileTableOfContents.astro",
|
|
20
|
+
"./overrides/Footer.astro": "./src/overrides/Footer.astro",
|
|
21
|
+
"./overrides/ThemeSelect.astro": "./src/overrides/ThemeSelect.astro",
|
|
22
|
+
"./overrides/ThemeProvider.astro": "./src/overrides/ThemeProvider.astro"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"starlight",
|
|
27
|
+
"theme",
|
|
28
|
+
"bejamas",
|
|
29
|
+
"bejamas/ui",
|
|
30
|
+
"astro",
|
|
31
|
+
"astro-component",
|
|
32
|
+
"withastro"
|
|
33
|
+
],
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "https://github.com/bejamas/ui.git",
|
|
37
|
+
"directory": "packages/starlight-theme-bejamas"
|
|
38
|
+
},
|
|
39
|
+
"bugs": "https://github.com/bejamas/ui/issues",
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@astrojs/starlight": "^0.42.3",
|
|
42
|
+
"astro": "^7.3.4"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@bejamas/semantic-icons": "0.0.0-canary.0138fd3",
|
|
46
|
+
"@fontsource-variable/inter": "^5.3.0",
|
|
47
|
+
"@fontsource/inter": "^5.3.0",
|
|
48
|
+
"@lucide/astro": "^1.47.0"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import { StarlightThemeBejamasConfigSchema } from "./config";
|
|
4
|
+
|
|
5
|
+
describe("starlight-theme-bejamas config schema", () => {
|
|
6
|
+
test("parses nav and component maps under zod v4", () => {
|
|
7
|
+
const result = StarlightThemeBejamasConfigSchema.safeParse({
|
|
8
|
+
nav: [
|
|
9
|
+
{
|
|
10
|
+
label: {
|
|
11
|
+
en: "Docs",
|
|
12
|
+
fr: "Documentation",
|
|
13
|
+
},
|
|
14
|
+
href: "/docs/introduction",
|
|
15
|
+
attrs: {
|
|
16
|
+
rel: "prefetch",
|
|
17
|
+
"data-track": "docs-link",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
components: {
|
|
22
|
+
ThemeSelect: "./src/components/ThemeSwitcher.astro",
|
|
23
|
+
PageTitle: "./src/components/PageTitle.astro",
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
expect(result.success).toBe(true);
|
|
28
|
+
if (!result.success) {
|
|
29
|
+
throw result.error;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
expect(result.data.nav?.[0]?.label).toEqual({
|
|
33
|
+
en: "Docs",
|
|
34
|
+
fr: "Documentation",
|
|
35
|
+
});
|
|
36
|
+
expect(result.data.components?.ThemeSelect).toBe(
|
|
37
|
+
"./src/components/ThemeSwitcher.astro",
|
|
38
|
+
);
|
|
39
|
+
});
|
|
40
|
+
});
|
package/src/config.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { AstroBuiltinAttributes } from "astro";
|
|
2
|
+
import type { HTMLAttributes } from "astro/types";
|
|
3
|
+
import { z } from "astro/zod";
|
|
4
|
+
|
|
5
|
+
const linkHTMLAttributesSchema = z.record(
|
|
6
|
+
z.string(),
|
|
7
|
+
z.union([z.string(), z.number(), z.boolean(), z.undefined()]),
|
|
8
|
+
) as z.Schema<
|
|
9
|
+
Omit<HTMLAttributes<"a">, keyof AstroBuiltinAttributes | "children">
|
|
10
|
+
>;
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line ts/explicit-function-return-type
|
|
13
|
+
const LinkItemHTMLAttributesSchema = () => linkHTMLAttributesSchema.default({});
|
|
14
|
+
|
|
15
|
+
const navLinkSchema = z.object({
|
|
16
|
+
/**
|
|
17
|
+
* An optional badge to display next to the topic label.
|
|
18
|
+
*
|
|
19
|
+
* This option accepts the same configuration as the Starlight badge sidebar item configuration.
|
|
20
|
+
* @see https://starlight.astro.build/guides/sidebar/#badges
|
|
21
|
+
*/
|
|
22
|
+
badge: z.string().optional(),
|
|
23
|
+
/**
|
|
24
|
+
* The topic label visible at the top of the sidebar.
|
|
25
|
+
*
|
|
26
|
+
* The value can be a string, or for multilingual sites, an object with values for each different locale. When using
|
|
27
|
+
* the object form, the keys must be BCP-47 tags (e.g. en, fr, or zh-CN).
|
|
28
|
+
*/
|
|
29
|
+
label: z.union([z.string(), z.record(z.string(), z.string())]),
|
|
30
|
+
/**
|
|
31
|
+
* The link to the topic’s content which an be a relative link to local files or the full URL of an external page.
|
|
32
|
+
*
|
|
33
|
+
* For internal links, the link can either be a page included in the items array or a different page acting as the
|
|
34
|
+
* topic’s landing page.
|
|
35
|
+
*/
|
|
36
|
+
href: z.string(),
|
|
37
|
+
/** HTML attributes to add to the link item. */
|
|
38
|
+
attrs: LinkItemHTMLAttributesSchema(),
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
export const StarlightThemeBejamasConfigSchema = z.object({
|
|
42
|
+
nav: z.array(navLinkSchema).optional(),
|
|
43
|
+
components: z.record(z.string(), z.string()).optional(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export type StarlightThemeBejamasUserConfig = z.input<
|
|
47
|
+
typeof StarlightThemeBejamasConfigSchema
|
|
48
|
+
>;
|
|
49
|
+
export type StarlightThemeBejamasConfig = z.output<
|
|
50
|
+
typeof StarlightThemeBejamasConfigSchema
|
|
51
|
+
>;
|
package/src/env.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference path="./virtual-modules.d.ts" />
|
|
2
|
+
/// <reference path="./virtual-internal.d.ts" />
|
|
3
|
+
|
|
4
|
+
import type { I18nT } from "@astrojs/starlight/utils/createTranslationSystem";
|
|
5
|
+
import type { StarlightRouteData } from "@astrojs/starlight/utils/routing/types";
|
|
6
|
+
|
|
7
|
+
declare global {
|
|
8
|
+
namespace App {
|
|
9
|
+
interface Locals {
|
|
10
|
+
t: I18nT;
|
|
11
|
+
starlightRoute: StarlightRouteData;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export {};
|
package/src/global.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
StarlightThemeProvider?: {
|
|
4
|
+
refreshThemeColors?: (theme?: string) => void;
|
|
5
|
+
updatePickers?: (theme?: string) => void;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const StarlightThemeProvider: {
|
|
10
|
+
refreshThemeColors?: (theme?: string) => void;
|
|
11
|
+
updatePickers?: (theme?: string) => void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
namespace App {
|
|
15
|
+
interface Locals {
|
|
16
|
+
t: I18nT;
|
|
17
|
+
starlightRoute: StarlightRouteData;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
StarlightPlugin,
|
|
3
|
+
StarlightUserConfig,
|
|
4
|
+
} from "@astrojs/starlight/types";
|
|
5
|
+
import type { AstroIntegration, AstroIntegrationLogger } from "astro";
|
|
6
|
+
|
|
7
|
+
import { createInlineSvgUrl } from "@astrojs/starlight/expressive-code";
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
StarlightThemeBejamasConfigSchema,
|
|
11
|
+
type StarlightThemeBejamasUserConfig,
|
|
12
|
+
} from "./config";
|
|
13
|
+
import { vitePluginStarlightThemeBejamas } from "./lib/vite";
|
|
14
|
+
|
|
15
|
+
export default function starlightThemeBejamas(
|
|
16
|
+
userConfig: StarlightThemeBejamasUserConfig,
|
|
17
|
+
): StarlightPlugin {
|
|
18
|
+
const parsedConfig = StarlightThemeBejamasConfigSchema.safeParse(userConfig);
|
|
19
|
+
|
|
20
|
+
if (!parsedConfig.success) {
|
|
21
|
+
throw new Error(
|
|
22
|
+
`The provided plugin configuration is invalid.\n${parsedConfig.error.issues
|
|
23
|
+
.map((issue: { message: string }) => issue.message)
|
|
24
|
+
.join("\n")}`,
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const config = parsedConfig.data;
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
name: "starlight-theme-bejamas-plugin",
|
|
32
|
+
hooks: {
|
|
33
|
+
"config:setup": function ({
|
|
34
|
+
config: starlightConfig,
|
|
35
|
+
logger,
|
|
36
|
+
updateConfig,
|
|
37
|
+
addIntegration,
|
|
38
|
+
}: {
|
|
39
|
+
config: StarlightUserConfig;
|
|
40
|
+
logger: AstroIntegrationLogger;
|
|
41
|
+
updateConfig: (config: StarlightUserConfig) => void;
|
|
42
|
+
addIntegration: (integration: AstroIntegration) => void;
|
|
43
|
+
}) {
|
|
44
|
+
const userExpressiveCodeConfig =
|
|
45
|
+
starlightConfig.expressiveCode === false ||
|
|
46
|
+
starlightConfig.expressiveCode === true
|
|
47
|
+
? {}
|
|
48
|
+
: starlightConfig.expressiveCode;
|
|
49
|
+
|
|
50
|
+
const componentOverrides: typeof config.components = {};
|
|
51
|
+
|
|
52
|
+
type OverridableComponent =
|
|
53
|
+
| "Header"
|
|
54
|
+
| "PageFrame"
|
|
55
|
+
| "SiteTitle"
|
|
56
|
+
| "Pagination"
|
|
57
|
+
| "PageTitle"
|
|
58
|
+
| "Hero"
|
|
59
|
+
| "MobileTableOfContents"
|
|
60
|
+
| "Footer"
|
|
61
|
+
| "ThemeSelect"
|
|
62
|
+
| "ThemeProvider";
|
|
63
|
+
|
|
64
|
+
const overridableComponents: OverridableComponent[] = [
|
|
65
|
+
"Header",
|
|
66
|
+
"PageFrame",
|
|
67
|
+
"SiteTitle",
|
|
68
|
+
"Pagination",
|
|
69
|
+
"PageTitle",
|
|
70
|
+
"Hero",
|
|
71
|
+
"MobileTableOfContents",
|
|
72
|
+
"Footer",
|
|
73
|
+
"ThemeSelect",
|
|
74
|
+
"ThemeProvider",
|
|
75
|
+
];
|
|
76
|
+
|
|
77
|
+
for (const component of overridableComponents) {
|
|
78
|
+
if (config.components?.[component]) {
|
|
79
|
+
logger.warn(
|
|
80
|
+
`It looks like you already have a \`${component}\` component override in your Starlight configuration.`,
|
|
81
|
+
);
|
|
82
|
+
} else {
|
|
83
|
+
componentOverrides[component] =
|
|
84
|
+
`starlight-theme-bejamas/overrides/${component}.astro`;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
updateConfig({
|
|
89
|
+
components: {
|
|
90
|
+
...componentOverrides,
|
|
91
|
+
...config.components,
|
|
92
|
+
},
|
|
93
|
+
customCss: [
|
|
94
|
+
"@fontsource/inter/400.css",
|
|
95
|
+
"@fontsource/inter/500.css",
|
|
96
|
+
"@fontsource/inter/700.css",
|
|
97
|
+
...(starlightConfig.customCss ?? []),
|
|
98
|
+
"starlight-theme-bejamas/styles/theme.css",
|
|
99
|
+
],
|
|
100
|
+
expressiveCode:
|
|
101
|
+
starlightConfig.expressiveCode === false
|
|
102
|
+
? false
|
|
103
|
+
: {
|
|
104
|
+
themes: ["github-dark-default", "github-light-default"],
|
|
105
|
+
...userExpressiveCodeConfig,
|
|
106
|
+
styleOverrides: {
|
|
107
|
+
codeBackground: "var(--code-background)",
|
|
108
|
+
borderWidth: "0px",
|
|
109
|
+
borderRadius: "calc(var(--radius) + 4px)",
|
|
110
|
+
gutterBorderWidth: "0px",
|
|
111
|
+
...userExpressiveCodeConfig?.styleOverrides,
|
|
112
|
+
frames: {
|
|
113
|
+
editorBackground: "var(--code-background)",
|
|
114
|
+
terminalBackground: "var(--code-background)",
|
|
115
|
+
copyIcon: createInlineSvgUrl(
|
|
116
|
+
`<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="lucide lucide-clipboard"><rect width="8" height="4" x="8" y="2" rx="1" ry="1"></rect><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path></svg>`,
|
|
117
|
+
),
|
|
118
|
+
...userExpressiveCodeConfig?.styleOverrides?.frames,
|
|
119
|
+
},
|
|
120
|
+
textMarkers: {
|
|
121
|
+
markBackground: "var(--mark-background)",
|
|
122
|
+
markBorderColor: "var(--border)",
|
|
123
|
+
...userExpressiveCodeConfig?.styleOverrides?.textMarkers,
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
defaultProps: {
|
|
127
|
+
showLineNumbers: false,
|
|
128
|
+
overridesByLang: {
|
|
129
|
+
astro: {
|
|
130
|
+
showLineNumbers: true,
|
|
131
|
+
},
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
addIntegration({
|
|
138
|
+
name: "starlight-theme-bejamas-integration",
|
|
139
|
+
hooks: {
|
|
140
|
+
"astro:config:setup": ({ updateConfig }) => {
|
|
141
|
+
updateConfig({
|
|
142
|
+
vite: {
|
|
143
|
+
plugins: [vitePluginStarlightThemeBejamas(config)],
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
};
|
|
152
|
+
}
|