@larkiny/astro-github-loader 0.14.4 → 0.14.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.
|
@@ -199,7 +199,7 @@ function transformLink(linkText, linkUrl, context) {
|
|
|
199
199
|
const globalMappings = context.global.linkMappings.filter((m) => m.global);
|
|
200
200
|
if (globalMappings.length > 0) {
|
|
201
201
|
const rawMapped = applyLinkMappings(linkPath + anchor, globalMappings, context);
|
|
202
|
-
if (rawMapped !== linkPath + anchor) {
|
|
202
|
+
if (rawMapped !== linkPath + anchor && rawMapped.startsWith("/")) {
|
|
203
203
|
return `[${linkText}](${rawMapped})`;
|
|
204
204
|
}
|
|
205
205
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@larkiny/astro-github-loader",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.14.
|
|
4
|
+
"version": "0.14.5",
|
|
5
5
|
"description": "Load content from GitHub repositories into Astro content collections with asset management and content transformations",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"astro",
|
|
@@ -244,6 +244,39 @@ describe("globalLinkTransform", () => {
|
|
|
244
244
|
expect(result[0].content).toBe("[See B](/api/page-b/#section)");
|
|
245
245
|
});
|
|
246
246
|
|
|
247
|
+
it("should not early-return multi-segment bare-path sibling references with .md", () => {
|
|
248
|
+
// Multi-segment bare paths like "types/subscription.md" are file-relative
|
|
249
|
+
// sibling references (e.g., from subscriber.md to types/subscription.md).
|
|
250
|
+
// The .md-stripping global mapping should NOT cause an early return — the
|
|
251
|
+
// link must flow through normalizePath() + sourceToTargetMap to resolve.
|
|
252
|
+
const files: ImportedFile[] = [
|
|
253
|
+
createImportedFile(
|
|
254
|
+
"latest/api/subscriber.md",
|
|
255
|
+
"src/content/docs/docs/algokit-subscriber/typescript/latest/api/subscriber.md",
|
|
256
|
+
"[`AlgorandSubscriberConfig`](types/subscription.md#algorandsubscriberconfig)",
|
|
257
|
+
),
|
|
258
|
+
createImportedFile(
|
|
259
|
+
"latest/api/types/subscription.md",
|
|
260
|
+
"src/content/docs/docs/algokit-subscriber/typescript/latest/api/types/subscription.md",
|
|
261
|
+
"# subscription",
|
|
262
|
+
),
|
|
263
|
+
];
|
|
264
|
+
|
|
265
|
+
const result = globalLinkTransform(files, {
|
|
266
|
+
stripPrefixes: ["src/content/docs"],
|
|
267
|
+
linkMappings: [
|
|
268
|
+
{ pattern: /\.md(#|$)/, replacement: "$1", global: true },
|
|
269
|
+
{ pattern: /\/index(\.md)?$/, replacement: "/", global: true },
|
|
270
|
+
],
|
|
271
|
+
logger,
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// Should resolve via sourceToTargetMap to absolute URL, NOT leave as relative
|
|
275
|
+
expect(result[0].content).toBe(
|
|
276
|
+
"[`AlgorandSubscriberConfig`](/docs/algokit-subscriber/typescript/latest/api/types/subscription/#algorandsubscriberconfig)",
|
|
277
|
+
);
|
|
278
|
+
});
|
|
279
|
+
|
|
247
280
|
it("should preserve anchors in transformed links", () => {
|
|
248
281
|
const files: ImportedFile[] = [
|
|
249
282
|
createImportedFile(
|