starlight-versions 0.1.0 → 0.2.0

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.
Files changed (2) hide show
  1. package/libs/starlight.ts +12 -1
  2. package/package.json +2 -2
package/libs/starlight.ts CHANGED
@@ -41,7 +41,9 @@ export function addPrefixToSidebarConfig(
41
41
  sidebar: NonNullable<StarlightSidebarUserConfig>,
42
42
  ): NonNullable<StarlightSidebarUserConfig> {
43
43
  return sidebar.map((item) => {
44
- if ('items' in item) {
44
+ if (typeof item === 'string') {
45
+ return addPrefixToSlug(prefix, item)
46
+ } else if ('items' in item) {
45
47
  return {
46
48
  ...item,
47
49
  items: addPrefixToSidebarConfig(prefix, item.items),
@@ -54,6 +56,11 @@ export function addPrefixToSidebarConfig(
54
56
  directory: path.posix.join(prefix, item.autogenerate.directory),
55
57
  },
56
58
  }
59
+ } else if ('slug' in item) {
60
+ return {
61
+ ...item,
62
+ slug: addPrefixToSlug(prefix, item.slug),
63
+ }
57
64
  } else if (isAbsoluteLink(item.link)) {
58
65
  return item
59
66
  }
@@ -68,6 +75,10 @@ export function addPrefixToSidebarConfig(
68
75
  })
69
76
  }
70
77
 
78
+ function addPrefixToSlug(prefix: string, slug: string) {
79
+ return `${prefix}/${slug}`
80
+ }
81
+
71
82
  type StarlightFrontmatter = z.input<ReturnType<ReturnType<typeof docsSchema>>> & {
72
83
  slug?: string
73
84
  hero?: StarlightFrontmatteHero
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-versions",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "description": "Starlight plugin to version documentation pages.",
6
6
  "author": "HiDeoo <github@hideoo.dev> (https://hideoo.dev)",
@@ -40,7 +40,7 @@
40
40
  "vitest": "^1.6.0"
41
41
  },
42
42
  "peerDependencies": {
43
- "@astrojs/starlight": ">=0.23.0"
43
+ "@astrojs/starlight": ">=0.25.0"
44
44
  },
45
45
  "engines": {
46
46
  "node": ">=18"