Skip to content

Commit 81d6ec3

Browse files
committed
add buttons
1 parent ab4ee5f commit 81d6ec3

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

layouts/partials/md-dropdown.html

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,32 @@
5757
<div class="text-base">Ask questions with Docs AI</div>
5858
</div>
5959
</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" "search" }}
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" "search" }}
80+
</span>
81+
<div class="leading-tight">
82+
<div class="text-base">Open in Claude</div>
83+
</div>
84+
</button>
85+
6086
</div>
6187
</details>
6288

@@ -105,6 +131,32 @@
105131
}
106132
}
107133

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/chat?contextUrl=${currentUrl}`;
153+
window.open(claudeUrl, '_blank');
154+
})
155+
.catch((err) => {
156+
console.error("Error opening in Claude:", err);
157+
});
158+
}
159+
108160
document.addEventListener("click", function (event) {
109161
const dropdown = document.getElementById("markdownDropdown");
110162

0 commit comments

Comments
 (0)