starlight-versions 0.7.1 → 0.8.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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # starlight-versions
2
2
 
3
+ ## 0.8.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#62](https://github.com/HiDeoo/starlight-versions/pull/62) [`3b6b14a`](https://github.com/HiDeoo/starlight-versions/commit/3b6b14a1e55f13aaf289e822f10dcead916e6c12) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Improves the error message logged when the plugin configuration is invalid.
8
+
9
+ ## 0.8.0
10
+
11
+ ### Minor Changes
12
+
13
+ - [#60](https://github.com/HiDeoo/starlight-versions/pull/60) [`059b573`](https://github.com/HiDeoo/starlight-versions/commit/059b57361b2295fc72a79e805c3c44a33902d566) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Adds support for Astro v6, drops support for Astro v5.
14
+
15
+ ⚠️ **BREAKING CHANGE:** The minimum supported version of Starlight is now `0.38.0`.
16
+
17
+ Please follow the [upgrade guide](https://github.com/withastro/starlight/releases/tag/%40astrojs%2Fstarlight%400.38.0) to update your project.
18
+
3
19
  ## 0.7.1
4
20
 
5
21
  ### Patch Changes
@@ -7,7 +7,7 @@ import { getVersionFromSlug, getVersionURL } from '../libs/versions'
7
7
  const { entry } = Astro.locals.starlightRoute
8
8
  const { template } = Astro.locals.starlightRoute.entry.data
9
9
 
10
- const pageVersion = getVersionFromSlug(starlightVersionsConfig, starlightConfig, entry.slug)
10
+ const pageVersion = getVersionFromSlug(starlightVersionsConfig, starlightConfig, entry.id)
11
11
  ---
12
12
 
13
13
  {
@@ -5,7 +5,7 @@ import starlightVersionsConfig from 'virtual:starlight-versions-config'
5
5
 
6
6
  import { getVersionFromSlug, getVersionURL } from '../libs/versions'
7
7
 
8
- const pageVersion = getVersionFromSlug(starlightVersionsConfig, starlightConfig, Astro.locals.starlightRoute.entry.slug)
8
+ const pageVersion = getVersionFromSlug(starlightVersionsConfig, starlightConfig, Astro.locals.starlightRoute.entry.id)
9
9
  ---
10
10
 
11
11
  {
@@ -23,7 +23,7 @@ const pagefindTranslations = {
23
23
  ),
24
24
  }
25
25
 
26
- const pageVersion = getVersionFromSlug(starlightVersionsConfig, starlightConfig, entry.slug)
26
+ const pageVersion = getVersionFromSlug(starlightVersionsConfig, starlightConfig, entry.id)
27
27
  const pageVersionIdentifier = getVersionIdentifier(pageVersion)
28
28
 
29
29
  const dataAttributes: DOMStringMap = {
package/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { StarlightPlugin } from '@astrojs/starlight/types'
2
+ import { z } from 'astro/zod'
2
3
 
3
4
  import { StarlightVersionsConfigSchema, type StarlightVersionsUserConfig } from './libs/config'
4
5
  import { overrideComponents, throwPluginError } from './libs/plugin'
@@ -13,7 +14,10 @@ export default function starlightVersionsPlugin(userConfig: StarlightVersionsUse
13
14
 
14
15
  if (!parsedConfig.success) {
15
16
  throwPluginError(
16
- `The provided plugin configuration is invalid.\n${parsedConfig.error.issues.map((issue) => issue.message).join('\n')}`,
17
+ `Invalid starlight-versions configuration:
18
+
19
+ ${z.prettifyError(parsedConfig.error)}
20
+ `,
17
21
  )
18
22
  }
19
23
 
package/libs/config.ts CHANGED
@@ -9,6 +9,7 @@ export const StarlightVersionsConfigSchema = z
9
9
  */
10
10
  current: z
11
11
  .object({
12
+ ...VersionBaseSchema.shape,
12
13
  /**
13
14
  * The label used in the UI to represent the current version.
14
15
  *
@@ -16,8 +17,7 @@ export const StarlightVersionsConfigSchema = z
16
17
  */
17
18
  label: z.string().default('Latest'),
18
19
  })
19
- .merge(VersionBaseSchema)
20
- .default({}),
20
+ .prefault({}),
21
21
  /**
22
22
  * A list of all archived versions of the documentation.
23
23
  */
package/libs/markdown.ts CHANGED
@@ -186,7 +186,7 @@ function handleImports(node: MdxjsEsm, file: VFile) {
186
186
  }
187
187
 
188
188
  function addVersionToLink(link: string, file: VFile) {
189
- assert(file.data.version, 'A version must be provided to add a version to an Astro asset.')
189
+ assert.ok(file.data.version, 'A version must be provided to add a version to an Astro asset.')
190
190
 
191
191
  const base = file.data.base ?? ''
192
192
  const hasBase = file.data.base && link.startsWith(file.data.base)
@@ -210,7 +210,7 @@ function addVersionToLink(link: string, file: VFile) {
210
210
  }
211
211
 
212
212
  function addVersionToAstroAsset(asset: string, file: VFile) {
213
- assert(file.data.version, 'A version must be provided to add a version to an Astro asset.')
213
+ assert.ok(file.data.version, 'A version must be provided to add a version to an Astro asset.')
214
214
 
215
215
  const source = new URL(asset, file.data.url)
216
216
 
@@ -225,7 +225,7 @@ function addVersionToAstroAsset(asset: string, file: VFile) {
225
225
  }
226
226
 
227
227
  function addVersionToPublicAsset(asset: string, file: VFile) {
228
- assert(file.data.version, 'A version must be provided to add a version to an public asset.')
228
+ assert.ok(file.data.version, 'A version must be provided to add a version to an public asset.')
229
229
 
230
230
  const source = new URL(`.${asset}`, file.data.publicDir)
231
231
 
package/libs/versions.ts CHANGED
@@ -40,25 +40,24 @@ export const VersionBaseSchema = z.object({
40
40
  redirect: z.union([z.literal('root'), z.literal('same-page')]).default('same-page'),
41
41
  })
42
42
 
43
- export const VersionSchema = z
44
- .object({
45
- /**
46
- * An optional label used in the UI when displaying the version.
47
- * If not provided, the version slug is used.
48
- *
49
- * @example 'v2.0'
50
- * @example 'v3.1.2'
51
- */
52
- label: z.string().optional(),
53
- /**
54
- * The version slug used in URLs to identify the version and its content.
55
- *
56
- * @example '2.0'
57
- * @example '3-1-2'
58
- */
59
- slug: z.string().refine((value) => stripLeadingSlash(stripTrailingSlash(value))),
60
- })
61
- .merge(VersionBaseSchema)
43
+ export const VersionSchema = z.object({
44
+ ...VersionBaseSchema.shape,
45
+ /**
46
+ * An optional label used in the UI when displaying the version.
47
+ * If not provided, the version slug is used.
48
+ *
49
+ * @example 'v2.0'
50
+ * @example 'v3.1.2'
51
+ */
52
+ label: z.string().optional(),
53
+ /**
54
+ * The version slug used in URLs to identify the version and its content.
55
+ *
56
+ * @example '2.0'
57
+ * @example '3-1-2'
58
+ */
59
+ slug: z.string().refine((value) => stripLeadingSlash(stripTrailingSlash(value))),
60
+ })
62
61
 
63
62
  export async function ensureNewVersion(
64
63
  config: StarlightVersionsConfig,
package/middleware.ts CHANGED
@@ -9,11 +9,11 @@ export const onRequest = defineRouteMiddleware((context) => {
9
9
  const { entry, locale, pagination, sidebar } = starlightRoute
10
10
 
11
11
  starlightRoute.sidebar = getVersionSidebar(
12
- getVersionFromSlug(starlightVersionsConfig, starlightConfig, entry.slug),
12
+ getVersionFromSlug(starlightVersionsConfig, starlightConfig, entry.id),
13
13
  sidebar,
14
14
  )
15
15
 
16
- const pageVersion = getVersionFromSlug(starlightVersionsConfig, starlightConfig, entry.slug)
16
+ const pageVersion = getVersionFromSlug(starlightVersionsConfig, starlightConfig, entry.id)
17
17
 
18
18
  starlightRoute.pagination.prev = getPaginationLink(locale, pageVersion, pagination.prev)
19
19
  starlightRoute.pagination.next = getPaginationLink(locale, pageVersion, pagination.next)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-versions",
3
- "version": "0.7.1",
3
+ "version": "0.8.1",
4
4
  "license": "MIT",
5
5
  "description": "Starlight plugin to version documentation pages.",
6
6
  "author": "HiDeoo <github@hideoo.dev> (https://hideoo.dev)",
@@ -20,28 +20,28 @@
20
20
  "./package.json": "./package.json"
21
21
  },
22
22
  "dependencies": {
23
- "@pagefind/default-ui": "^1.2.0",
23
+ "@pagefind/default-ui": "^1.3.0",
24
24
  "github-slugger": "^2.0.0",
25
- "mdast-util-mdx-jsx": "^3.1.3",
25
+ "mdast-util-mdx-jsx": "^3.2.0",
26
26
  "mdast-util-mdxjs-esm": "^2.0.1",
27
27
  "remark": "^15.0.1",
28
28
  "remark-directive": "^4.0.0",
29
29
  "remark-frontmatter": "^5.0.0",
30
- "remark-mdx": "^3.1.0",
31
- "unist-util-visit": "^5.0.0",
30
+ "remark-mdx": "^3.1.1",
31
+ "unist-util-visit": "^5.1.0",
32
32
  "vfile": "^6.0.3",
33
- "yaml": "^2.6.1"
33
+ "yaml": "^2.8.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/mdast": "^4.0.4",
37
- "fast-glob": "^3.3.2",
38
- "vitest": "2.1.6"
37
+ "fast-glob": "^3.3.3",
38
+ "vitest": "^4.0.18"
39
39
  },
40
40
  "peerDependencies": {
41
- "@astrojs/starlight": ">=0.32.0"
41
+ "@astrojs/starlight": ">=0.38.0"
42
42
  },
43
43
  "engines": {
44
- "node": ">=18"
44
+ "node": ">=22.12.0"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public"