scavold 0.2.0-rc.6 → 0.2.0-rc.7

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
@@ -9,6 +9,14 @@ changes may occur in any release.
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [0.2.0-rc.7] — 2026-09-29
13
+
14
+ ### Fixed
15
+
16
+ - A link to a media file whose extension VitePress does not know, such as `.diff`,
17
+ pointed at the file name with `.html` appended and therefore at nothing. It now names
18
+ the file as published.
19
+
12
20
  ## [0.2.0-rc.6] — 2026-09-13
13
21
 
14
22
  ### Added
@@ -250,6 +258,9 @@ First published release. Version `0.1.0` existed in-tree only.
250
258
  - Only images are processed out of `media_folder`; other file types (video, documents)
251
259
  are never copied into the build output and have to live in the static folder.
252
260
 
261
+ [Unreleased]: https://gitlab.com/cratly/scavold/-/compare/v0.2.0-rc.7...main
262
+ [0.2.0-rc.7]: https://gitlab.com/cratly/scavold/-/compare/v0.2.0-rc.6...v0.2.0-rc.7
263
+ [0.2.0-rc.6]: https://gitlab.com/cratly/scavold/-/compare/v0.2.0-rc.5...v0.2.0-rc.6
253
264
  [0.2.0-rc.5]: https://gitlab.com/cratly/scavold/-/compare/v0.2.0-rc.4...v0.2.0-rc.5
254
265
  [0.2.0-rc.4]: https://gitlab.com/cratly/scavold/-/compare/v0.2.0-rc.3...v0.2.0-rc.4
255
266
  [0.2.0-rc.3]: https://gitlab.com/cratly/scavold/-/compare/v0.2.0-rc.2...v0.2.0-rc.3
package/lib/config.js CHANGED
@@ -653,7 +653,7 @@ export async function augmentConfig( rawConfig, options = {} ) {
653
653
  // during in-app use.
654
654
  //
655
655
  // The redirect value can be either:
656
- // - a site-relative URL ("/de/jobs") — written by the Cratly editor
656
+ // - a site-relative URL ("/de/jobs") — written by the cratly editor
657
657
  // - a relative .md path ("jobs.md") — written by hand in frontmatter
658
658
  // - an absolute external URL — e.g. "https://example.com"
659
659
  const redirect = pageData.frontmatter?.redirect;
@@ -714,14 +714,31 @@ export async function augmentConfig( rawConfig, options = {} ) {
714
714
  // offers, which is relative to that folder. Rewrite it to the URL the
715
715
  // built site serves. Targets that are not media files (ordinary page
716
716
  // links, anchors, remote URLs) resolve to null and stay untouched.
717
- patchRenderer( md, "link_open", ( defaultHandler, tokens, idx, ...args ) => {
718
- const published = media.collectAsset( tokens[idx].attrGet( "href" ) );
717
+ //
718
+ // VitePress then takes any extension missing from its own list of file
719
+ // types (`.diff`, say) for part of a page name and appends `.html`. The
720
+ // published URL is final, so that suffix is taken back — after VitePress
721
+ // ran, which leaves prefixing the site's base to it.
722
+ patchRenderer( md, "link_open", ( defaultHandler, tokens, idx, mdOptions, env, slf ) => {
723
+ const token = tokens[idx];
724
+ const published = media.collectAsset( token.attrGet( "href" ) );
725
+
726
+ if ( !published ) {
727
+ return defaultHandler( tokens, idx, mdOptions, env, slf );
728
+ }
729
+
730
+ token.attrSet( "href", published );
731
+
732
+ const rendered = defaultHandler( tokens, idx, mdOptions, env, slf );
733
+ const href = token.attrGet( "href" );
734
+
735
+ if ( !published.endsWith( ".html" ) && href?.endsWith( published + ".html" ) ) {
736
+ token.attrSet( "href", href.slice( 0, -".html".length ) );
719
737
 
720
- if ( published ) {
721
- tokens[idx].attrSet( "href", published );
738
+ return slf.renderToken( tokens, idx, mdOptions );
722
739
  }
723
740
 
724
- return defaultHandler( tokens, idx, ...args );
741
+ return rendered;
725
742
  } );
726
743
 
727
744
  registerContainers( md, containerMap, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scavold",
3
- "version": "0.2.0-rc.6",
3
+ "version": "0.2.0-rc.7",
4
4
  "type": "module",
5
5
  "description": "VitePress theme framework — a scaffold for building custom VitePress themes with Vue at the core",
6
6
  "keywords": [
@@ -53,7 +53,7 @@ function linkSelf() {
53
53
 
54
54
  /**
55
55
  * Creates the fixture's media files. Images are real (the pipeline reads their
56
- * dimensions); the other two only ever get copied, so a few bytes carrying the right
56
+ * dimensions); the others only ever get copied, so a few bytes carrying the right
57
57
  * extension are enough.
58
58
  */
59
59
  async function writeMedia() {
@@ -76,6 +76,8 @@ async function writeMedia() {
76
76
 
77
77
  writeFileSync( join( media, "doc.pdf" ), "%PDF-1.4\n% fixture placeholder\n" );
78
78
  writeFileSync( join( media, "clip.mp4" ), "fixture placeholder\n" );
79
+ // An extension VitePress does not know, so its link rules take the file for a page.
80
+ writeFileSync( join( media, "patch.diff" ), "--- a\n+++ b\n" );
79
81
  }
80
82
 
81
83
  /**
@@ -194,6 +196,8 @@ console.log( "\nmedia that is not an image" );
194
196
  expect( published.includes( "doc.pdf" ), "copies a document into the site output" );
195
197
  expect( published.includes( "clip.mp4" ), "copies a video into the site output" );
196
198
  expect( media.includes( 'href="/media/doc.pdf"' ), "rewrites a link to a media file" );
199
+ expect( media.includes( 'href="/media/patch.diff"' ),
200
+ "links a media file of an extension VitePress does not know as that file, not as a page" );
197
201
  // On the entry page, where the fixture's page links live. VitePress resolves them to
198
202
  // .html; what matters is that the media pipeline did not touch them.
199
203
  expect( built( "index.html" ).includes( 'href="/containers.html"' ), "leaves a link to a page alone" );