Skip to content

Commit c7f64f3

Browse files
authored
ui: add 'open in Claude/Chatgpt' to page options (#23110)
1 parent 3075778 commit c7f64f3

File tree

5 files changed

+65
-5
lines changed

5 files changed

+65
-5
lines changed

assets/css/utilities.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,11 @@
234234
}
235235

236236
@utility sub-button {
237-
@apply flex w-full items-start gap-2 rounded-sm px-2 py-2 text-left text-gray-700 transition-colors hover:bg-gray-50 dark:text-gray-100 dark:hover:bg-gray-800;
237+
@apply flex w-full items-center gap-2 rounded-sm px-2 py-2 text-left text-gray-600 transition-colors hover:bg-gray-50 dark:text-gray-100 dark:hover:bg-gray-800;
238+
}
239+
240+
@utility dropdown-base {
241+
@apply rounded-sm border border-gray-300 bg-white text-gray-600 dark:border-gray-300 dark:bg-gray-900 dark:text-gray-100;
238242
}
239243

240244
@utility toc {

assets/icons/claude.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/icons/openai.svg

Lines changed: 1 addition & 0 deletions
Loading

hugo_stats.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
"Okta",
9898
"Okta-SAML",
9999
"Old-Dockerfile",
100+
"On-Unix-environments",
101+
"On-Windows",
100102
"Other-providers",
101103
"PHP",
102104
"PowerShell",
@@ -193,7 +195,6 @@
193195
"border-gray-200",
194196
"border-gray-300",
195197
"border-gray-400",
196-
"border-gray-600",
197198
"border-green-400",
198199
"border-l-2",
199200
"border-l-magenta-light",
@@ -279,6 +280,7 @@
279280
"download-links",
280281
"download-links-subcontainer",
281282
"drop-shadow",
283+
"dropdown-base",
282284
"duration-300",
283285
"fill-blue",
284286
"fixed",
@@ -578,6 +580,7 @@
578580
"w-2",
579581
"w-5",
580582
"w-56",
583+
"w-65",
581584
"w-8",
582585
"w-[1200px]",
583586
"w-fit",

layouts/partials/md-dropdown.html

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<details id="markdownDropdown" class="ml-3 group relative z-10 inline-block" data-heap-id="markdown-dropdown">
22
<summary
3-
class="inline-flex cursor-pointer items-center gap-0 rounded-sm border border-gray-600 bg-white py-1 pl-2
4-
text-base font-semibold text-gray-600 transition-colors hover:bg-gray-50 dark:border-gray-50 dark:bg-gray-950 dark:text-gray-100 dark:hover:bg-gray-900"
3+
class="dropdown-base hover:bg-gray-50 dark:hover:bg-gray-900 inline-flex cursor-pointer items-center gap-0 py-1 pl-2 text-sm font-semibold transition-colors"
54
data-heap-id="markdown-dropdown-toggle"
65
>
76
<span class="font-normal">Page options</span>
@@ -14,7 +13,7 @@
1413

1514
<!-- Dropdown menu -->
1615
<div
17-
class="absolute right-0 z-50 mt-1 w-56 origin-top-right rounded-sm border border-gray-300 bg-white p-2 text-sm text-black shadow-md [display:none] group-open:[display:block] dark:border-gray-100 dark:text-gray-100 dark:bg-gray-950"
16+
class="dropdown-base absolute right-0 z-50 mt-1 w-65 origin-top-right p-2 text-sm shadow-md [display:none] group-open:[display:block]"
1817
data-heap-id="markdown-dropdown-menu"
1918
>
2019
<button
@@ -58,6 +57,32 @@
5857
<div class="text-base">Ask questions with Docs AI</div>
5958
</div>
6059
</button>
60+
<button
61+
onclick="openInChatGPT()"
62+
data-heap-id="search-docs-ai-button"
63+
class="sub-button"
64+
>
65+
<span class="icon-svg mt-[2px] text-base leading-none">
66+
{{ partial "icon" "/icons/openai.svg" }}
67+
</span>
68+
<div class="leading-tight">
69+
<div class="text-base">Open in ChatGPT</div>
70+
</div>
71+
</button>
72+
73+
<button
74+
onclick="openInClaude()"
75+
data-heap-id="search-docs-ai-button"
76+
class="sub-button"
77+
>
78+
<span class="icon-svg mt-[2px] text-base leading-none">
79+
{{ partial "icon" "/icons/claude.svg" }}
80+
</span>
81+
<div class="leading-tight">
82+
<div class="text-base">Open in Claude</div>
83+
</div>
84+
</button>
85+
6186
</div>
6287
</details>
6388

@@ -106,6 +131,32 @@
106131
}
107132
}
108133

134+
function openInChatGPT() {
135+
fetch(getCurrentPlaintextUrl())
136+
.then((response) => response.text())
137+
.then((text) => {
138+
const encodedText = encodeURIComponent(text);
139+
const chatGPTUrl = `https://chat.openai.com/?q=${encodedText}`;
140+
window.open(chatGPTUrl, "_blank");
141+
})
142+
.catch((err) => {
143+
console.error("Error opening in ChatGPT:", err);
144+
});
145+
}
146+
147+
function openInClaude() {
148+
fetch(getCurrentPlaintextUrl())
149+
.then((response) => response.text())
150+
.then((text) => {
151+
const encodedText = encodeURIComponent(text);
152+
const claudeUrl = `https://claude.ai/new?q=${encodedText}`;https://claude.ai/new?q=%22hey%22
153+
window.open(claudeUrl, '_blank');
154+
})
155+
.catch((err) => {
156+
console.error("Error opening in Claude:", err);
157+
});
158+
}
159+
109160
document.addEventListener("click", function (event) {
110161
const dropdown = document.getElementById("markdownDropdown");
111162

0 commit comments

Comments
 (0)