starlight-versions 0.5.3 → 0.5.5

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,19 @@
1
1
  # starlight-versions
2
2
 
3
+ ## 0.5.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#42](https://github.com/HiDeoo/starlight-versions/pull/42) [`3b68fbc`](https://github.com/HiDeoo/starlight-versions/commit/3b68fbc511dbe80c7d4b79ebe5ebc0b9f8d06c9d) Thanks [@mkurapov](https://github.com/mkurapov)! - Fixes potential issue with link generation in multilingual projects.
8
+
9
+ ## 0.5.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [#37](https://github.com/HiDeoo/starlight-versions/pull/37) [`7812488`](https://github.com/HiDeoo/starlight-versions/commit/7812488c665786bcfb6256cc9d3e342f9090cbcb) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fix an issue where public assets could fail to be versioned correctly.
14
+
15
+ - [#35](https://github.com/HiDeoo/starlight-versions/pull/35) [`6014403`](https://github.com/HiDeoo/starlight-versions/commit/60144036971ee871c3195bc2a6567b6aa33734b7) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes an issue with asides using custom titles not being rendered correctly when versioned.
16
+
3
17
  ## 0.5.3
4
18
 
5
19
  ### Patch Changes
package/libs/markdown.ts CHANGED
@@ -4,6 +4,7 @@ import type { Image, Link, Root } from 'mdast'
4
4
  import type { MdxJsxFlowElement, MdxJsxTextElement } from 'mdast-util-mdx-jsx'
5
5
  import type { MdxjsEsm } from 'mdast-util-mdxjs-esm'
6
6
  import { remark } from 'remark'
7
+ import remarkDirective from 'remark-directive'
7
8
  import remarkFrontmatter from 'remark-frontmatter'
8
9
  import remarkMdx from 'remark-mdx'
9
10
  import { CONTINUE, SKIP, visit } from 'unist-util-visit'
@@ -18,7 +19,7 @@ const astroAssetRegex = /\.(png|jpg|jpeg|tiff|webp|gif|svg|avif)$/i
18
19
 
19
20
  const mediaElements = new Set(['img', 'source', 'Image', 'audio', 'video'])
20
21
 
21
- const processor = remark().use(remarkMdx).use(remarkFrontmatter).use(remarkStarlightVersions)
22
+ const processor = remark().use(remarkDirective).use(remarkMdx).use(remarkFrontmatter).use(remarkStarlightVersions)
22
23
 
23
24
  export async function transformMarkdown(markdown: string, context: TransformContext) {
24
25
  const file = await processor.process({
@@ -195,7 +196,11 @@ function addVersionToLink(link: string, file: VFile) {
195
196
  }
196
197
 
197
198
  const segments = link.split('/')
198
- segments.splice(1, 0, file.data.version.slug)
199
+
200
+ let slugVersionIndex = 1
201
+ if (file.data.locale && segments[1] === file.data.locale) slugVersionIndex = 2
202
+
203
+ segments.splice(slugVersionIndex, 0, file.data.version.slug)
199
204
 
200
205
  if (hasBase) {
201
206
  segments.splice(1, 0, stripLeadingSlash(base))
@@ -222,12 +227,12 @@ function addVersionToAstroAsset(asset: string, file: VFile) {
222
227
  function addVersionToPublicAsset(asset: string, file: VFile) {
223
228
  assert(file.data.version, 'A version must be provided to add a version to an public asset.')
224
229
 
225
- const source = new URL(asset, file.data.url)
230
+ const source = new URL(`.${asset}`, file.data.publicDir)
226
231
 
227
232
  const segments = asset.split('/')
228
233
  segments.splice(-1, 0, file.data.version.slug)
229
234
 
230
- addVersionAsset(file, { source, dest: new URL(segments.join('/'), file.data.url) })
235
+ addVersionAsset(file, { source, dest: new URL(`.${segments.join('/')}`, file.data.publicDir) })
231
236
 
232
237
  return segments.join('/')
233
238
  }
@@ -248,6 +253,7 @@ export interface TransformContext {
248
253
  assets: VersionAsset[]
249
254
  base: string
250
255
  locale: string | undefined
256
+ publicDir: URL
251
257
  slug: string
252
258
  url: URL
253
259
  version: Version
package/libs/versions.ts CHANGED
@@ -108,6 +108,7 @@ export async function ensureNewVersion(
108
108
  assets: [],
109
109
  base: stripTrailingSlash(astroConfig.base),
110
110
  locale: getDocLocale(slug, starlightConfig),
111
+ publicDir: astroConfig.publicDir,
111
112
  slug,
112
113
  url: entry.url,
113
114
  version: newVersion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "starlight-versions",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "license": "MIT",
5
5
  "description": "Starlight plugin to version documentation pages.",
6
6
  "author": "HiDeoo <github@hideoo.dev> (https://hideoo.dev)",
@@ -25,6 +25,7 @@
25
25
  "mdast-util-mdx-jsx": "^3.1.3",
26
26
  "mdast-util-mdxjs-esm": "^2.0.1",
27
27
  "remark": "^15.0.1",
28
+ "remark-directive": "^4.0.0",
28
29
  "remark-frontmatter": "^5.0.0",
29
30
  "remark-mdx": "^3.1.0",
30
31
  "unist-util-visit": "^5.0.0",