starlight-theme-nova 0.0.3 → 0.0.4

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 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.3",
4
+ "version": "0.0.4",
5
5
  "description": "",
6
6
  "author": "ocavue <ocavue@gmail.com>",
7
7
  "license": "MIT",
@@ -26,20 +26,21 @@
26
26
  "src"
27
27
  ],
28
28
  "dependencies": {
29
- "@shikijs/transformers": "^1.29.0",
29
+ "@shikijs/transformers": "^1.29.2",
30
+ "@shikijs/twoslash": "^1.29.2",
30
31
  "astro-theme-toggle": "^0.5.1",
31
32
  "hast-util-is-element": "^3.0.0"
32
33
  },
33
34
  "devDependencies": {
34
35
  "@astrojs/starlight": "^0.32.2",
35
- "@iconify-json/bxl": "^1.0.0",
36
+ "@iconify-json/bxl": "^1.2.2",
36
37
  "@iconify-json/logos": "^1.2.4",
37
- "@iconify-json/lucide": "^1.2.22",
38
- "@iconify-json/tabler": "^1.0.0",
38
+ "@iconify-json/lucide": "^1.2.30",
39
+ "@iconify-json/tabler": "^1.2.17",
39
40
  "@ocavue/tsconfig": "^0.2.0",
40
- "@types/node": "^20.0.0",
41
+ "@types/node": "^20.17.24",
41
42
  "@unocss/cli": "^66.0.0",
42
- "astro": "^5.1.5",
43
+ "astro": "^5.5.2",
43
44
  "typescript": "^5.7.2",
44
45
  "unocss": "^66.0.0",
45
46
  "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 { shikiConfig } from '../shiki-config'
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 { shikiConfig } from './shiki-config'
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)],
@@ -3,20 +3,24 @@ import {
3
3
  transformerNotationDiff,
4
4
  transformerNotationHighlight,
5
5
  } from '@shikijs/transformers'
6
+ import { transformerTwoslash } from '@shikijs/twoslash'
6
7
  import type { ShikiConfig } from 'astro'
7
8
 
8
9
  import { transformerCopyButton } from './shiki-transformer-copy-button'
9
10
 
10
- export const shikiConfig: ShikiConfig = {
11
- themes: {
12
- light: 'one-light',
13
- dark: 'github-dark-dimmed',
14
- },
15
- defaultColor: false,
16
- transformers: [
17
- transformerNotationDiff(),
18
- transformerNotationHighlight(),
19
- transformerMetaHighlight(),
20
- transformerCopyButton(),
21
- ],
11
+ export function createShikiConfig(options: { twoslash: boolean }): ShikiConfig {
12
+ return {
13
+ themes: {
14
+ light: 'one-light',
15
+ dark: 'github-dark-dimmed',
16
+ },
17
+ defaultColor: false,
18
+ transformers: [
19
+ transformerNotationDiff(),
20
+ transformerNotationHighlight(),
21
+ transformerMetaHighlight(),
22
+ transformerCopyButton(),
23
+ options.twoslash ? transformerTwoslash() : undefined,
24
+ ].filter((x) => !!x),
25
+ }
22
26
  }