Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/astro-github-loader/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@larkiny/astro-github-loader",
"type": "module",
"version": "0.14.4",
"version": "0.14.5",
"description": "Load content from GitHub repositories into Astro content collections with asset management and content transformations",
"keywords": [
"astro",
Expand Down
33 changes: 33 additions & 0 deletions packages/astro-github-loader/src/github.link-transform.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,39 @@ describe("globalLinkTransform", () => {
expect(result[0].content).toBe("[See B](/api/page-b/#section)");
});

it("should not early-return multi-segment bare-path sibling references with .md", () => {
// Multi-segment bare paths like "types/subscription.md" are file-relative
// sibling references (e.g., from subscriber.md to types/subscription.md).
// The .md-stripping global mapping should NOT cause an early return — the
// link must flow through normalizePath() + sourceToTargetMap to resolve.
const files: ImportedFile[] = [
createImportedFile(
"latest/api/subscriber.md",
"src/content/docs/docs/algokit-subscriber/typescript/latest/api/subscriber.md",
"[`AlgorandSubscriberConfig`](types/subscription.md#algorandsubscriberconfig)",
),
createImportedFile(
"latest/api/types/subscription.md",
"src/content/docs/docs/algokit-subscriber/typescript/latest/api/types/subscription.md",
"# subscription",
),
];

const result = globalLinkTransform(files, {
stripPrefixes: ["src/content/docs"],
linkMappings: [
{ pattern: /\.md(#|$)/, replacement: "$1", global: true },
{ pattern: /\/index(\.md)?$/, replacement: "/", global: true },
],
logger,
});

// Should resolve via sourceToTargetMap to absolute URL, NOT leave as relative
expect(result[0].content).toBe(
"[`AlgorandSubscriberConfig`](/docs/algokit-subscriber/typescript/latest/api/types/subscription/#algorandsubscriberconfig)",
);
});

it("should preserve anchors in transformed links", () => {
const files: ImportedFile[] = [
createImportedFile(
Expand Down
2 changes: 1 addition & 1 deletion packages/astro-github-loader/src/github.link-transform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ function transformLink(
globalMappings,
context,
);
if (rawMapped !== linkPath + anchor) {
if (rawMapped !== linkPath + anchor && rawMapped.startsWith("/")) {
return `[${linkText}](${rawMapped})`;
}
}
Expand Down