@open-agent-toolkit/docs-transforms 0.0.43 → 0.0.51
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/dist/remark-links.d.ts +4 -3
- package/dist/remark-links.d.ts.map +1 -1
- package/dist/remark-links.js +48 -24
- package/package.json +1 -1
package/dist/remark-links.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ import type { Plugin } from 'unified';
|
|
|
6
6
|
* slashes.
|
|
7
7
|
*
|
|
8
8
|
* URL rewriting:
|
|
9
|
-
* - `quickstart.md` from `docs/index.md` → `./quickstart
|
|
9
|
+
* - `quickstart.md` from `docs/index.md` → `./quickstart/`
|
|
10
10
|
* - `documentation/commands.md` from `docs/guide/cli-reference.md`
|
|
11
|
-
* → `../documentation/commands
|
|
12
|
-
* - `../reference/index.md` from `docs/guide/concepts.md` → `../../reference
|
|
11
|
+
* → `../documentation/commands/`
|
|
12
|
+
* - `../reference/index.md` from `docs/guide/concepts.md` → `../../reference/`
|
|
13
|
+
* - `quickstart.md#setup` → `./quickstart/#setup`
|
|
13
14
|
* - Absolute URLs and anchors are left unchanged.
|
|
14
15
|
*
|
|
15
16
|
* Display text cleanup:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"remark-links.d.ts","sourceRoot":"","sources":["../src/remark-links.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,IAAI,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"remark-links.d.ts","sourceRoot":"","sources":["../src/remark-links.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoB,IAAI,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AA4FtC;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,EAAE,EAAE,IAAI,CA2CxC,CAAC"}
|
package/dist/remark-links.js
CHANGED
|
@@ -40,6 +40,29 @@ function routePathFromDocsFile(filePath) {
|
|
|
40
40
|
return '/';
|
|
41
41
|
return path.normalize(`/${cleaned}`);
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Append a trailing slash to the path portion of a rewritten URL so it works
|
|
45
|
+
* on static hosts (e.g., S3) where pages live at `<route>/index.html` and
|
|
46
|
+
* `/foo` returns 403 — only `/foo/` resolves the index file. Skips URLs
|
|
47
|
+
* whose last segment looks like a file with an extension (e.g., `.png`),
|
|
48
|
+
* URLs that already end in `/`, and empty paths. Preserves any `#fragment`
|
|
49
|
+
* or `?query` suffix.
|
|
50
|
+
*
|
|
51
|
+
* Assumes markdown slugs are dot-free (kebab-case). A page named
|
|
52
|
+
* `release-1.0.md` would rewrite to `./release-1.0` and be treated as an
|
|
53
|
+
* asset by the extension check, leaving it without a trailing slash.
|
|
54
|
+
*/
|
|
55
|
+
function appendTrailingSlash(url) {
|
|
56
|
+
const suffixIndex = url.search(/[#?]/);
|
|
57
|
+
const pathPortion = suffixIndex >= 0 ? url.slice(0, suffixIndex) : url;
|
|
58
|
+
const suffix = suffixIndex >= 0 ? url.slice(suffixIndex) : '';
|
|
59
|
+
if (!pathPortion || pathPortion.endsWith('/'))
|
|
60
|
+
return url;
|
|
61
|
+
const lastSegment = pathPortion.slice(pathPortion.lastIndexOf('/') + 1);
|
|
62
|
+
if (/\.[^.]+$/.test(lastSegment))
|
|
63
|
+
return url;
|
|
64
|
+
return `${pathPortion}/${suffix}`;
|
|
65
|
+
}
|
|
43
66
|
function resolveRelativeDocsLink(sourceFilePath, targetPath) {
|
|
44
67
|
const sourceDocsFile = docsRelativeFilePath(sourceFilePath);
|
|
45
68
|
if (!sourceDocsFile)
|
|
@@ -60,10 +83,11 @@ function resolveRelativeDocsLink(sourceFilePath, targetPath) {
|
|
|
60
83
|
* slashes.
|
|
61
84
|
*
|
|
62
85
|
* URL rewriting:
|
|
63
|
-
* - `quickstart.md` from `docs/index.md` → `./quickstart
|
|
86
|
+
* - `quickstart.md` from `docs/index.md` → `./quickstart/`
|
|
64
87
|
* - `documentation/commands.md` from `docs/guide/cli-reference.md`
|
|
65
|
-
* → `../documentation/commands
|
|
66
|
-
* - `../reference/index.md` from `docs/guide/concepts.md` → `../../reference
|
|
88
|
+
* → `../documentation/commands/`
|
|
89
|
+
* - `../reference/index.md` from `docs/guide/concepts.md` → `../../reference/`
|
|
90
|
+
* - `quickstart.md#setup` → `./quickstart/#setup`
|
|
67
91
|
* - Absolute URLs and anchors are left unchanged.
|
|
68
92
|
*
|
|
69
93
|
* Display text cleanup:
|
|
@@ -80,30 +104,30 @@ export const remarkLinks = function remarkLinks() {
|
|
|
80
104
|
if (/^[a-z]+:/i.test(url) || url.startsWith('#')) {
|
|
81
105
|
return;
|
|
82
106
|
}
|
|
83
|
-
// Split off any anchor fragment
|
|
84
|
-
const
|
|
85
|
-
const path =
|
|
86
|
-
const fragment =
|
|
107
|
+
// Split off any anchor fragment or query string
|
|
108
|
+
const suffixIndex = url.search(/[#?]/);
|
|
109
|
+
const path = suffixIndex >= 0 ? url.slice(0, suffixIndex) : url;
|
|
110
|
+
const fragment = suffixIndex >= 0 ? url.slice(suffixIndex) : '';
|
|
87
111
|
const cleaned = cleanMdPath(path);
|
|
88
|
-
if (cleaned
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
code.value = cleanedText;
|
|
112
|
+
if (cleaned !== null) {
|
|
113
|
+
const rewrittenPath = typeof file?.path === 'string'
|
|
114
|
+
? (resolveRelativeDocsLink(file.path, path) ?? cleaned)
|
|
115
|
+
: cleaned;
|
|
116
|
+
const prefix = rewrittenPath.startsWith('.') || rewrittenPath.startsWith('/')
|
|
117
|
+
? ''
|
|
118
|
+
: './';
|
|
119
|
+
node.url = prefix + rewrittenPath + fragment;
|
|
120
|
+
// Clean display text when it's a single inlineCode child with a .md path
|
|
121
|
+
const firstChild = node.children[0];
|
|
122
|
+
if (node.children.length === 1 && firstChild?.type === 'inlineCode') {
|
|
123
|
+
const code = firstChild;
|
|
124
|
+
const cleanedText = cleanMdPath(code.value);
|
|
125
|
+
if (cleanedText !== null) {
|
|
126
|
+
code.value = cleanedText;
|
|
127
|
+
}
|
|
105
128
|
}
|
|
106
129
|
}
|
|
130
|
+
node.url = appendTrailingSlash(node.url);
|
|
107
131
|
});
|
|
108
132
|
};
|
|
109
133
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@open-agent-toolkit/docs-transforms",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.51",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Remark/unified transforms for OAT documentation",
|
|
6
6
|
"homepage": "https://github.com/voxmedia/open-agent-toolkit/tree/main/packages/docs-transforms",
|