starlight-theme-nova 0.0.2 → 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/markdown.css +14 -4
- package/lib/shiki.css +17 -1
- package/package.json +9 -7
- package/src/astro.d.ts +6 -0
- package/src/components/Code.astro +4 -1
- package/src/components/CodePackageManagers.astro +55 -0
- package/src/components/MarkdownContent.astro +1 -1
- package/src/components/SocialIcons.astro +6 -8
- package/src/components/index.ts +6 -0
- package/src/index.ts +2 -2
- package/src/shiki-config.ts +16 -12
package/lib/markdown.css
CHANGED
|
@@ -20,8 +20,18 @@
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/* <code> inside asides */
|
|
23
|
-
@supports (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
@supports (
|
|
24
|
+
border-color: color-mix(
|
|
25
|
+
in srgb,
|
|
26
|
+
var(--sl-color-asides-text-accent) 12%,
|
|
27
|
+
transparent
|
|
28
|
+
)
|
|
29
|
+
) {
|
|
30
|
+
.sl-markdown-content .starlight-aside code:not(:where(.not-content *)) {
|
|
31
|
+
border-color: color-mix(
|
|
32
|
+
in srgb,
|
|
33
|
+
var(--sl-color-asides-text-accent) 12%,
|
|
34
|
+
transparent
|
|
35
|
+
);
|
|
36
|
+
}
|
|
27
37
|
}
|
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.4",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "ocavue <ocavue@gmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
"exports": {
|
|
19
19
|
".": "./src/index.ts",
|
|
20
20
|
"./*.css": "./lib/*.css",
|
|
21
|
+
"./components": "./src/components/index.ts",
|
|
21
22
|
"./components/*.astro": "./src/components/*.astro"
|
|
22
23
|
},
|
|
23
24
|
"files": [
|
|
@@ -25,20 +26,21 @@
|
|
|
25
26
|
"src"
|
|
26
27
|
],
|
|
27
28
|
"dependencies": {
|
|
28
|
-
"@shikijs/transformers": "^1.29.
|
|
29
|
+
"@shikijs/transformers": "^1.29.2",
|
|
30
|
+
"@shikijs/twoslash": "^1.29.2",
|
|
29
31
|
"astro-theme-toggle": "^0.5.1",
|
|
30
32
|
"hast-util-is-element": "^3.0.0"
|
|
31
33
|
},
|
|
32
34
|
"devDependencies": {
|
|
33
35
|
"@astrojs/starlight": "^0.32.2",
|
|
34
|
-
"@iconify-json/bxl": "^1.
|
|
36
|
+
"@iconify-json/bxl": "^1.2.2",
|
|
35
37
|
"@iconify-json/logos": "^1.2.4",
|
|
36
|
-
"@iconify-json/lucide": "^1.2.
|
|
37
|
-
"@iconify-json/tabler": "^1.
|
|
38
|
+
"@iconify-json/lucide": "^1.2.30",
|
|
39
|
+
"@iconify-json/tabler": "^1.2.17",
|
|
38
40
|
"@ocavue/tsconfig": "^0.2.0",
|
|
39
|
-
"@types/node": "^20.
|
|
41
|
+
"@types/node": "^20.17.24",
|
|
40
42
|
"@unocss/cli": "^66.0.0",
|
|
41
|
-
"astro": "^5.
|
|
43
|
+
"astro": "^5.5.2",
|
|
42
44
|
"typescript": "^5.7.2",
|
|
43
45
|
"unocss": "^66.0.0",
|
|
44
46
|
"unocss-preset-animations": "^1.1.1"
|
package/src/astro.d.ts
ADDED
|
@@ -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} />
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
---
|
|
2
|
+
import { CodeTabItem, CodeTabs } from 'starlight-theme-nova/components'
|
|
3
|
+
|
|
4
|
+
type PackageManager = 'pnpm' | 'npm' | 'yarn' | 'bun'
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
/**
|
|
8
|
+
* The package managers to use.
|
|
9
|
+
*
|
|
10
|
+
* @default ['pnpm', 'npm', 'yarn', 'bun']
|
|
11
|
+
*/
|
|
12
|
+
packageManagers?: PackageManager[]
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The packages to install. If you want to install multiple packages, you can pass a space-separated string.
|
|
16
|
+
*/
|
|
17
|
+
packages: string
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Whether to install the packages as dev dependencies.
|
|
21
|
+
*
|
|
22
|
+
* @default false
|
|
23
|
+
*/
|
|
24
|
+
dev?: boolean
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const props: Props = Astro.props
|
|
28
|
+
|
|
29
|
+
const packageManagers = props.packageManagers ?? ['pnpm', 'npm', 'yarn', 'bun']
|
|
30
|
+
|
|
31
|
+
function getCode(packageManager: PackageManager) {
|
|
32
|
+
const parts: string[] = [
|
|
33
|
+
{
|
|
34
|
+
pnpm: 'pnpm add',
|
|
35
|
+
npm: 'npm install',
|
|
36
|
+
yarn: 'yarn add',
|
|
37
|
+
bun: 'bun add',
|
|
38
|
+
}[packageManager],
|
|
39
|
+
|
|
40
|
+
props.dev ? '-D' : '',
|
|
41
|
+
|
|
42
|
+
props.packages,
|
|
43
|
+
]
|
|
44
|
+
|
|
45
|
+
return parts.filter(Boolean).join(' ')
|
|
46
|
+
}
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
<CodeTabs syncKey="code-group-installation">
|
|
50
|
+
{
|
|
51
|
+
packageManagers.map((pkg) => (
|
|
52
|
+
<CodeTabItem label={pkg} lang="shell" code={getCode(pkg)} />
|
|
53
|
+
))
|
|
54
|
+
}
|
|
55
|
+
</CodeTabs>
|
|
@@ -10,14 +10,12 @@ const links = Object.entries(config.social || {}) as [Platform, SocialConfig][]
|
|
|
10
10
|
{
|
|
11
11
|
links.length > 0 && (
|
|
12
12
|
<>
|
|
13
|
-
{
|
|
14
|
-
|
|
15
|
-
<
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
))
|
|
20
|
-
}
|
|
13
|
+
{links.map(([platform, { label, url }]) => (
|
|
14
|
+
<a href={url} rel="me" class="nova-social-icons-link">
|
|
15
|
+
<span class="sr-only">{label}</span>
|
|
16
|
+
<Icon name={platform} size="1rem" color="currentColor" />
|
|
17
|
+
</a>
|
|
18
|
+
))}
|
|
21
19
|
</>
|
|
22
20
|
)
|
|
23
21
|
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Code } from './Code.astro'
|
|
2
|
+
export { default as CodePackageManagers } from './CodePackageManagers.astro'
|
|
3
|
+
export { default as CodeTabs } from './CodeTabs.astro'
|
|
4
|
+
export { default as CodeTabItem } from './CodeTabItem.astro'
|
|
5
|
+
export { default as LinkButton } from './LinkButton.astro'
|
|
6
|
+
export { default as LinkCard } from './LinkCard.astro'
|
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,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
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
}
|