starlight-theme-nova 0.0.3 → 0.0.5
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/lib/shiki.css +17 -1
- package/package.json +9 -7
- package/src/components/Code.astro +4 -1
- package/src/index.ts +2 -2
- package/src/shiki-config.ts +20 -8
- package/src/shiki-transformer-copy-button.ts +1 -3
package/lib/shiki.css
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
@import '@shikijs/twoslash/style-rich.css';
|
|
2
|
+
|
|
1
3
|
.sl-markdown-content .astro-code {
|
|
2
4
|
padding: 0;
|
|
3
5
|
font-size: 0.875rem;
|
|
@@ -11,7 +13,7 @@
|
|
|
11
13
|
border-style: solid;
|
|
12
14
|
border-color: var(--sl-color-gray-5);
|
|
13
15
|
|
|
14
|
-
code {
|
|
16
|
+
& > code {
|
|
15
17
|
display: grid;
|
|
16
18
|
align-items: stretch;
|
|
17
19
|
overflow-x: hidden;
|
|
@@ -53,10 +55,12 @@
|
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
.astro-code {
|
|
58
|
+
--twoslash-popup-bg: var(--shiki-light-bg);
|
|
56
59
|
background-color: var(--shiki-light-bg);
|
|
57
60
|
}
|
|
58
61
|
|
|
59
62
|
html.dark .astro-code {
|
|
63
|
+
--twoslash-popup-bg: var(--shiki-dark-bg);
|
|
60
64
|
background-color: var(--shiki-dark-bg);
|
|
61
65
|
}
|
|
62
66
|
|
|
@@ -75,3 +79,15 @@ html.dark .astro-code span {
|
|
|
75
79
|
font-weight: var(--shiki-dark-font-weight);
|
|
76
80
|
text-decoration: var(--shiki-dark-text-decoration);
|
|
77
81
|
}
|
|
82
|
+
|
|
83
|
+
.astro-code.twoslash .twoslash-popup-container {
|
|
84
|
+
transform: translateY(1.8em);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.astro-code.twoslash .twoslash-query-presisted .twoslash-popup-container {
|
|
88
|
+
transform: translateY(2.2em);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.astro-code.twoslash .twoslash-query-line .twoslash-popup-container {
|
|
92
|
+
transform: translateY(1.3em);
|
|
93
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starlight-theme-nova",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.5",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "ocavue <ocavue@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -26,20 +26,22 @@
|
|
|
26
26
|
"src"
|
|
27
27
|
],
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@shikijs/transformers": "^
|
|
29
|
+
"@shikijs/transformers": "^3.2.1",
|
|
30
|
+
"@shikijs/twoslash": "^3.2.1",
|
|
31
|
+
"@shikijs/types": "^3.2.1",
|
|
30
32
|
"astro-theme-toggle": "^0.5.1",
|
|
31
33
|
"hast-util-is-element": "^3.0.0"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"@astrojs/starlight": "^0.32.2",
|
|
35
|
-
"@iconify-json/bxl": "^1.
|
|
37
|
+
"@iconify-json/bxl": "^1.2.2",
|
|
36
38
|
"@iconify-json/logos": "^1.2.4",
|
|
37
|
-
"@iconify-json/lucide": "^1.2.
|
|
38
|
-
"@iconify-json/tabler": "^1.
|
|
39
|
+
"@iconify-json/lucide": "^1.2.30",
|
|
40
|
+
"@iconify-json/tabler": "^1.2.17",
|
|
39
41
|
"@ocavue/tsconfig": "^0.2.0",
|
|
40
|
-
"@types/node": "^20.
|
|
42
|
+
"@types/node": "^20.17.24",
|
|
41
43
|
"@unocss/cli": "^66.0.0",
|
|
42
|
-
"astro": "^5.
|
|
44
|
+
"astro": "^5.5.2",
|
|
43
45
|
"typescript": "^5.7.2",
|
|
44
46
|
"unocss": "^66.0.0",
|
|
45
47
|
"unocss-preset-animations": "^1.1.1"
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
import type { ComponentProps } from 'astro/types'
|
|
3
3
|
import { Code as CodeComponent } from 'astro:components'
|
|
4
|
-
import {
|
|
4
|
+
import { createShikiConfig } from '../shiki-config'
|
|
5
5
|
|
|
6
6
|
type Props = ComponentProps<typeof CodeComponent>
|
|
7
|
+
|
|
8
|
+
// For unknown reasons, enabling twoslash breaks the build, thus twoslash is disabled here.
|
|
9
|
+
const shikiConfig = createShikiConfig({ twoslash: false })
|
|
7
10
|
---
|
|
8
11
|
|
|
9
12
|
<CodeComponent {...shikiConfig} {...Astro.props} />
|
package/src/index.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type {
|
|
|
3
3
|
StarlightUserConfig,
|
|
4
4
|
} from '@astrojs/starlight/types'
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import { createShikiConfig } from './shiki-config'
|
|
7
7
|
import type { ThemeNovaOptions } from './user-options'
|
|
8
8
|
import { vitePluginUserConfig } from './virtual-user-config'
|
|
9
9
|
|
|
@@ -54,7 +54,7 @@ export default function starlightThemeNova(
|
|
|
54
54
|
'astro:config:setup': ({ updateConfig }) => {
|
|
55
55
|
updateConfig({
|
|
56
56
|
markdown: {
|
|
57
|
-
shikiConfig,
|
|
57
|
+
shikiConfig: createShikiConfig({ twoslash: true }),
|
|
58
58
|
},
|
|
59
59
|
vite: {
|
|
60
60
|
plugins: [vitePluginUserConfig(options)],
|
package/src/shiki-config.ts
CHANGED
|
@@ -3,20 +3,32 @@ import {
|
|
|
3
3
|
transformerNotationDiff,
|
|
4
4
|
transformerNotationHighlight,
|
|
5
5
|
} from '@shikijs/transformers'
|
|
6
|
+
import { transformerTwoslash } from '@shikijs/twoslash'
|
|
7
|
+
import type { ShikiTransformer } from '@shikijs/types'
|
|
6
8
|
import type { ShikiConfig } from 'astro'
|
|
7
9
|
|
|
8
10
|
import { transformerCopyButton } from './shiki-transformer-copy-button'
|
|
9
11
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
light: 'one-light',
|
|
13
|
-
dark: 'github-dark-dimmed',
|
|
14
|
-
},
|
|
15
|
-
defaultColor: false,
|
|
16
|
-
transformers: [
|
|
12
|
+
export function createShikiConfig(options: { twoslash: boolean }): ShikiConfig {
|
|
13
|
+
const transformers: ShikiTransformer[] = [
|
|
17
14
|
transformerNotationDiff(),
|
|
18
15
|
transformerNotationHighlight(),
|
|
19
16
|
transformerMetaHighlight(),
|
|
20
17
|
transformerCopyButton(),
|
|
21
|
-
|
|
18
|
+
options.twoslash
|
|
19
|
+
? transformerTwoslash({
|
|
20
|
+
explicitTrigger: true,
|
|
21
|
+
})
|
|
22
|
+
: undefined,
|
|
23
|
+
].filter((x) => !!x)
|
|
24
|
+
|
|
25
|
+
return {
|
|
26
|
+
themes: {
|
|
27
|
+
light: 'one-light',
|
|
28
|
+
dark: 'github-dark-dimmed',
|
|
29
|
+
},
|
|
30
|
+
defaultColor: false,
|
|
31
|
+
// @ts-expect-error: Astro is using outdated Shiki v1
|
|
32
|
+
transformers: transformers,
|
|
33
|
+
}
|
|
22
34
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ShikiTransformer } from '@shikijs/types'
|
|
2
2
|
import { isElement } from 'hast-util-is-element'
|
|
3
3
|
|
|
4
|
-
type ShikiTransformer = NonNullable<ShikiConfig['transformers']>[number]
|
|
5
|
-
|
|
6
4
|
const name = 'starlight-theme-nova-shiki-transformer-copy-button'
|
|
7
5
|
|
|
8
6
|
/**
|