@redocly/theme 0.63.0-next.2 → 0.63.0-next.3
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.
|
@@ -23,6 +23,7 @@ const use_mcp_config_1 = require("./use-mcp-config");
|
|
|
23
23
|
const clipboard_service_1 = require("../utils/clipboard-service");
|
|
24
24
|
const dom_1 = require("../utils/dom");
|
|
25
25
|
const mcp_1 = require("../utils/mcp");
|
|
26
|
+
const urls_1 = require("../utils/urls");
|
|
26
27
|
function createPageActionResource(pageSlug, pageUrl) {
|
|
27
28
|
return {
|
|
28
29
|
id: pageSlug,
|
|
@@ -79,9 +80,12 @@ function usePageActions(pageSlug, mcpUrl, actions) {
|
|
|
79
80
|
const origin = dom_1.IS_BROWSER
|
|
80
81
|
? window.location.origin
|
|
81
82
|
: ((_a = globalThis['SSR_HOSTNAME']) !== null && _a !== void 0 ? _a : '');
|
|
82
|
-
const
|
|
83
|
-
const pageUrl =
|
|
84
|
-
const
|
|
83
|
+
const pathname = (0, urls_1.addTrailingSlash)(pageSlug);
|
|
84
|
+
const pageUrl = (0, urls_1.combineUrls)(origin, pathname);
|
|
85
|
+
const isRoot = (0, urls_1.withoutPathPrefix)(pathname) === '/';
|
|
86
|
+
const mdPageUrl = isRoot
|
|
87
|
+
? (0, urls_1.combineUrls)(origin, pathname, 'index.html.md')
|
|
88
|
+
: (0, urls_1.combineUrls)(origin, (0, urls_1.removeTrailingSlash)(pathname) + '.md');
|
|
85
89
|
const actionHandlers = {
|
|
86
90
|
'docs-mcp-cursor': createMCPHandler('cursor', false),
|
|
87
91
|
'docs-mcp-vscode': createMCPHandler('vscode', false),
|
|
@@ -119,7 +123,6 @@ function usePageActions(pageSlug, mcpUrl, actions) {
|
|
|
119
123
|
telemetry.sendPageActionsButtonClickedMessage([
|
|
120
124
|
Object.assign(Object.assign({}, createPageActionResource(pageSlug, pageUrl)), { action_type: 'view' }),
|
|
121
125
|
]);
|
|
122
|
-
window.location.href = mdPageUrl;
|
|
123
126
|
},
|
|
124
127
|
}),
|
|
125
128
|
chatgpt: () => {
|
package/package.json
CHANGED
|
@@ -16,6 +16,12 @@ import { useMCPConfig } from './use-mcp-config';
|
|
|
16
16
|
import { ClipboardService } from '../utils/clipboard-service';
|
|
17
17
|
import { IS_BROWSER } from '../utils/dom';
|
|
18
18
|
import { generateMCPDeepLink } from '../utils/mcp';
|
|
19
|
+
import {
|
|
20
|
+
addTrailingSlash,
|
|
21
|
+
combineUrls,
|
|
22
|
+
removeTrailingSlash,
|
|
23
|
+
withoutPathPrefix,
|
|
24
|
+
} from '../utils/urls';
|
|
19
25
|
|
|
20
26
|
function createPageActionResource(pageSlug: string, pageUrl: string) {
|
|
21
27
|
return {
|
|
@@ -108,11 +114,12 @@ export function usePageActions(
|
|
|
108
114
|
const origin = IS_BROWSER
|
|
109
115
|
? window.location.origin
|
|
110
116
|
: ((globalThis as { SSR_HOSTNAME?: string })['SSR_HOSTNAME'] ?? '');
|
|
111
|
-
const
|
|
112
|
-
const pageUrl =
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
117
|
+
const pathname = addTrailingSlash(pageSlug);
|
|
118
|
+
const pageUrl = combineUrls(origin, pathname);
|
|
119
|
+
const isRoot = withoutPathPrefix(pathname) === '/';
|
|
120
|
+
const mdPageUrl = isRoot
|
|
121
|
+
? combineUrls(origin, pathname, 'index.html.md')
|
|
122
|
+
: combineUrls(origin, removeTrailingSlash(pathname) + '.md');
|
|
116
123
|
|
|
117
124
|
const actionHandlers: Record<PageActionType, () => PageAction | null> = {
|
|
118
125
|
'docs-mcp-cursor': createMCPHandler('cursor', false),
|
|
@@ -158,7 +165,6 @@ export function usePageActions(
|
|
|
158
165
|
action_type: 'view',
|
|
159
166
|
},
|
|
160
167
|
]);
|
|
161
|
-
window.location.href = mdPageUrl;
|
|
162
168
|
},
|
|
163
169
|
}),
|
|
164
170
|
|