@larkiny/astro-github-loader 0.14.5 → 0.14.6

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.
@@ -1,4 +1,3 @@
1
- import { slug } from "github-slugger";
2
1
  import path from "node:path";
3
2
  /**
4
3
  * Extract anchor fragment from a link
@@ -148,12 +147,11 @@ function generateSiteUrl(targetPath, stripPrefixes) {
148
147
  else if (url === "index") {
149
148
  url = "";
150
149
  }
151
- // Split path into segments and slugify each
152
- const segments = url
150
+ // Filter empty segments (from double slashes etc.)
151
+ url = url
153
152
  .split("/")
154
- .map((segment) => (segment ? slug(segment) : ""));
155
- // Reconstruct URL
156
- url = segments.filter((s) => s).join("/");
153
+ .filter((s) => s)
154
+ .join("/");
157
155
  // Ensure leading slash
158
156
  if (url && !url.startsWith("/")) {
159
157
  url = "/" + url;
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.5",
4
+ "version": "0.14.6",
5
5
  "description": "Load content from GitHub repositories into Astro content collections with asset management and content transformations",
6
6
  "keywords": [
7
7
  "astro",
@@ -46,7 +46,6 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@octokit/auth-app": "^8.1.1",
49
- "github-slugger": "^2.0.0",
50
49
  "octokit": "^5.0.4",
51
50
  "picomatch": "^4.0.2"
52
51
  },
@@ -277,6 +277,36 @@ describe("globalLinkTransform", () => {
277
277
  );
278
278
  });
279
279
 
280
+ it("should preserve dots and case in generated site URLs", () => {
281
+ // TypeDoc output uses dot-separated filenames like types_account_manager.AccountManager.md
282
+ // The generated URL should preserve dots and case to match Starlight's generateId
283
+ const files: ImportedFile[] = [
284
+ createImportedFile(
285
+ "latest/api/classes/types_account_manager.AccountManager.md",
286
+ "src/content/docs/docs/algokit-utils/typescript/latest/api/classes/types_account_manager.AccountManager.md",
287
+ "# AccountManager",
288
+ ),
289
+ createImportedFile(
290
+ "latest/api/classes/types_app_factory.AppFactory.md",
291
+ "src/content/docs/docs/algokit-utils/typescript/latest/api/classes/types_app_factory.AppFactory.md",
292
+ "[AccountManager](types_account_manager.AccountManager.md)",
293
+ ),
294
+ ];
295
+
296
+ const result = globalLinkTransform(files, {
297
+ stripPrefixes: ["src/content/docs"],
298
+ linkMappings: [
299
+ { pattern: /\.md(#|$)/, replacement: "$1", global: true },
300
+ ],
301
+ logger,
302
+ });
303
+
304
+ // URL should preserve dots and case — NOT slugify to types_account_manageraccountmanager
305
+ expect(result[1].content).toBe(
306
+ "[AccountManager](/docs/algokit-utils/typescript/latest/api/classes/types_account_manager.AccountManager/)",
307
+ );
308
+ });
309
+
280
310
  it("should preserve anchors in transformed links", () => {
281
311
  const files: ImportedFile[] = [
282
312
  createImportedFile(
@@ -1,4 +1,3 @@
1
- import { slug } from "github-slugger";
2
1
  import path from "node:path";
3
2
  import type {
4
3
  LinkMapping,
@@ -270,13 +269,11 @@ function generateSiteUrl(targetPath: string, stripPrefixes: string[]): string {
270
269
  url = "";
271
270
  }
272
271
 
273
- // Split path into segments and slugify each
274
- const segments = url
272
+ // Filter empty segments (from double slashes etc.)
273
+ url = url
275
274
  .split("/")
276
- .map((segment) => (segment ? slug(segment) : ""));
277
-
278
- // Reconstruct URL
279
- url = segments.filter((s) => s).join("/");
275
+ .filter((s) => s)
276
+ .join("/");
280
277
 
281
278
  // Ensure leading slash
282
279
  if (url && !url.startsWith("/")) {