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.
- package/lib/styles.gen.css +2 -1
- package/package.json +10 -9
- package/src/components/Header.astro +24 -2
- package/src/index.ts +2 -0
- package/src/shiki-config.ts +0 -2
- package/src/shiki-transformer-container.ts +15 -1
- package/src/user-options.ts +2 -2
- package/src/shiki-transformer-copy-button.ts +0 -32
package/lib/styles.gen.css
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "starlight-theme-nova",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
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.
|
|
32
|
-
"@shikijs/twoslash": "^3.
|
|
33
|
-
"@shikijs/types": "^3.
|
|
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.
|
|
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.
|
|
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.
|
|
57
|
-
"astro": "^5.
|
|
57
|
+
"@unocss/cli": "^66.1.3",
|
|
58
|
+
"astro": "^5.10.1",
|
|
58
59
|
"typescript": "^5.8.3",
|
|
59
|
-
"unocss": "^66.1.
|
|
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: [
|
package/src/shiki-config.ts
CHANGED
|
@@ -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
|
|
package/src/user-options.ts
CHANGED
|
@@ -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
|
-
}
|