Skip to content

Commit fadb518

Browse files
committed
fix: enhance type safety for sidebar and navigation links
1 parent 62fdb1f commit fadb518

File tree

1 file changed

+11
-6
lines changed
  • packages/nimiq-vitepress-theme/src

1 file changed

+11
-6
lines changed

packages/nimiq-vitepress-theme/src/types.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,33 @@
11
import type { Theme } from 'vitepress'
22

3-
export interface NimiqVitepressSidebar {
3+
export interface NimiqVitepressSidebar<T extends `/${string}/` = any> {
44
label?: string
55
items: {
66
text: string
7-
link?: string
7+
link?: `${T}${string}`
88
icon: string
9-
items?: { text: string, link: string }[]
9+
items?: { text: string, link: `${T}${string}` }[]
1010
}[]
1111
}
1212

13-
export interface NimiqVitepressThemeNav {
13+
export interface NimiqVitepressThemeNav<T extends `/${string}/` = any> {
1414
/**
1515
* The string displayed in the selector.
1616
*/
1717
text: string
1818
/**
1919
* The path to the sub-module. If you want to link to the root of the module, use `/`.
20+
* Needs to match the folder name in your vitepress project.
2021
*/
2122
subpath: string
2223
icon?: string
23-
defaultPageLink: string
24+
/**
25+
* The default page link for the module. This is used to open the page when the module is selected.
26+
* You need to use something like `/your-page/` or `/your-page/not-index-page`.
27+
*/
28+
defaultPageLink: T
2429
description?: string
25-
sidebar: NimiqVitepressSidebar[]
30+
sidebar: NimiqVitepressSidebar<T>[]
2631
}
2732

2833
export interface NimiqVitepressThemeConfig {

0 commit comments

Comments
 (0)