starlight-theme-nova 0.8.1 → 0.9.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.
@@ -9,7 +9,8 @@
9
9
  --sl-text-h2: var(--sl-text-2xl);
10
10
  --sl-text-h3: var(--sl-text-xl);
11
11
  --sl-text-h4: var(--sl-text-lg);
12
- --sl-text-h5: unset;
12
+ --sl-text-h5: var(--sl-text-base);
13
+ --sl-text-h6: var(--sl-text-sm);
13
14
  }
14
15
 
15
16
  /* Dark mode Starlight theme variables. */
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "starlight-theme-nova",
3
3
  "type": "module",
4
- "version": "0.8.1",
4
+ "version": "0.9.1",
5
5
  "description": "",
6
6
  "author": "ocavue <ocavue@gmail.com>",
7
7
  "license": "MIT",
@@ -28,13 +28,14 @@
28
28
  "dependencies": {
29
29
  "@aria-ui/core": "^0.0.21",
30
30
  "@pagefind/default-ui": "^1.3.0",
31
- "@shikijs/transformers": "^3.5.0",
32
- "@shikijs/twoslash": "^3.5.0",
33
- "@shikijs/types": "^3.5.0",
31
+ "@shikijs/transformers": "^3.7.0",
32
+ "@shikijs/twoslash": "^3.7.0",
33
+ "@shikijs/types": "^3.7.0",
34
34
  "@types/hast": "^3.0.4",
35
35
  "astro-theme-toggle": "^0.6.1",
36
36
  "hast-util-is-element": "^3.0.0",
37
37
  "rehype": "^13.0.2",
38
+ "remark-custom-header-id": "^1.0.0",
38
39
  "shiki-twoslash-renderer": "0.0.4"
39
40
  },
40
41
  "peerDependencies": {
@@ -46,17 +47,17 @@
46
47
  }
47
48
  },
48
49
  "devDependencies": {
49
- "@astrojs/starlight": "^0.34.3",
50
+ "@astrojs/starlight": "^0.34.4",
50
51
  "@iconify-json/bxl": "^1.2.2",
51
52
  "@iconify-json/logos": "^1.2.4",
52
- "@iconify-json/lucide": "^1.2.46",
53
+ "@iconify-json/lucide": "^1.2.54",
53
54
  "@iconify-json/tabler": "^1.2.19",
54
55
  "@ocavue/tsconfig": "^0.3.7",
55
56
  "@types/node": "^20.17.30",
56
- "@unocss/cli": "^66.1.0",
57
- "astro": "^5.8.2",
57
+ "@unocss/cli": "^66.1.3",
58
+ "astro": "^5.10.1",
58
59
  "typescript": "^5.8.3",
59
- "unocss": "^66.1.0",
60
+ "unocss": "^66.1.3",
60
61
  "unocss-preset-animations": "^1.2.1"
61
62
  },
62
63
  "scripts": {
@@ -11,6 +11,28 @@ import options from 'virtual:starlight-theme-nova/user-config'
11
11
  import MobileMenuToggle from './MobileMenuToggle.astro'
12
12
 
13
13
  const nav = options.nav ?? []
14
+
15
+ const { locale } = Astro.locals.starlightRoute
16
+
17
+ const getLocalizedValue = (
18
+ value: string | { [local: string]: string },
19
+ ): string => {
20
+ if (typeof value === 'string') {
21
+ return value
22
+ }
23
+
24
+ if (typeof locale === 'string' && value[locale]) {
25
+ return value[locale]
26
+ }
27
+
28
+ // Use the same "root" convention as the Starlight docs to get the default value.
29
+ // https://github.com/withastro/starlight/blob/9d3ba179c5d524c1c61d771ceb1a7b4e754bee16/docs/src/content/docs/guides/i18n.mdx?plain=1#L72-L75
30
+ if (value['root']) {
31
+ return value['root']
32
+ }
33
+
34
+ return Object.values(value)[0] ?? ''
35
+ }
14
36
  ---
15
37
 
16
38
  <div class="nova-header">
@@ -20,8 +42,8 @@ const nav = options.nav ?? []
20
42
  <nav class="nova-header-nav">
21
43
  {
22
44
  nav.map((item) => (
23
- <a class="nova-header-nav-link" href={item.href}>
24
- {item.label}
45
+ <a class="nova-header-nav-link" href={getLocalizedValue(item.href)}>
46
+ {getLocalizedValue(item.label)}
25
47
  </a>
26
48
  ))
27
49
  }
package/src/index.ts CHANGED
@@ -2,6 +2,7 @@ import type {
2
2
  StarlightPlugin,
3
3
  StarlightUserConfig,
4
4
  } from '@astrojs/starlight/types'
5
+ import remarkCustomHeaderId from 'remark-custom-header-id'
5
6
 
6
7
  import { createShikiConfig } from './shiki-config'
7
8
  import type { ThemeNovaOptions } from './user-options'
@@ -59,6 +60,7 @@ export default function starlightThemeNova(
59
60
  updateConfig({
60
61
  markdown: {
61
62
  shikiConfig: createShikiConfig({ twoslash: true }),
63
+ remarkPlugins: [remarkCustomHeaderId],
62
64
  },
63
65
  vite: {
64
66
  plugins: [
@@ -12,7 +12,6 @@ import type { ShikiConfig } from 'astro'
12
12
  import { createRenderer } from 'shiki-twoslash-renderer'
13
13
 
14
14
  import { transformerContainer } from './shiki-transformer-container'
15
- import { transformerCopyButton } from './shiki-transformer-copy-button'
16
15
 
17
16
  export function createShikiConfig(options: { twoslash: boolean }): ShikiConfig {
18
17
  const transformers: ShikiTransformer[] = [
@@ -23,7 +22,6 @@ export function createShikiConfig(options: { twoslash: boolean }): ShikiConfig {
23
22
  transformerNotationWordHighlight(),
24
23
  transformerRemoveNotationEscape(),
25
24
 
26
- transformerCopyButton(),
27
25
  transformerContainer(),
28
26
  options.twoslash
29
27
  ? transformerTwoslash({
@@ -55,7 +55,21 @@ export function transformerContainer(): ShikiTransformer {
55
55
  [CODE_PROPERTY_TITLE]: title || undefined,
56
56
  class: 'nova-code-container not-content',
57
57
  },
58
- children,
58
+ children: [
59
+ ...children,
60
+ {
61
+ type: 'element',
62
+ tagName: 'nova-code-copy-button',
63
+ properties: {
64
+ type: 'button',
65
+ 'data-code': this.source,
66
+ title: 'Copy code',
67
+ 'aria-label': 'Copy code',
68
+ class: 'nova-code-copy-button',
69
+ },
70
+ children: [],
71
+ },
72
+ ],
59
73
  },
60
74
  ]
61
75
 
@@ -1,6 +1,6 @@
1
1
  export interface NavItem {
2
- label: string
3
- href: string
2
+ label: string | Record<string, string>
3
+ href: string | Record<string, string>
4
4
  }
5
5
 
6
6
  export interface ThemeNovaOptions {
@@ -1,32 +0,0 @@
1
- import type { ShikiTransformer } from '@shikijs/types'
2
-
3
- const name = 'starlight-theme-nova-shiki-transformer-copy-button'
4
-
5
- /**
6
- * A transformer that adds a copy button to code blocks.
7
- */
8
- export function transformerCopyButton(): ShikiTransformer {
9
- return {
10
- name: name,
11
- pre(node) {
12
- return {
13
- ...node,
14
- children: [
15
- ...node.children,
16
- {
17
- type: 'element',
18
- tagName: 'nova-code-copy-button',
19
- properties: {
20
- type: 'button',
21
- 'data-code': this.source,
22
- title: 'Copy code',
23
- 'aria-label': 'Copy code',
24
- class: 'nova-code-copy-button',
25
- },
26
- children: [],
27
- },
28
- ],
29
- }
30
- },
31
- }
32
- }