|
57 | 57 | <div class="text-base">Ask questions with Docs AI</div>
|
58 | 58 | </div>
|
59 | 59 | </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 |
| - |
| 60 | + {{ if eq hugo.Environment "production" }} |
73 | 61 | <button
|
74 | 62 | onclick="openInClaude()"
|
75 | 63 | data-heap-id="search-docs-ai-button"
|
|
82 | 70 | <div class="text-base">Open in Claude</div>
|
83 | 71 | </div>
|
84 | 72 | </button>
|
| 73 | + {{ end }} |
85 | 74 |
|
86 | 75 | </div>
|
87 | 76 | </details>
|
88 | 77 |
|
89 |
| - <script> |
| 78 | +<script> |
90 | 79 | function getCurrentPlaintextUrl() {
|
91 | 80 | const url = window.location.href.split("#")[0].replace(/\/$/, "");
|
92 | 81 | return `${url}/index.md`;
|
|
131 | 120 | }
|
132 | 121 | }
|
133 | 122 |
|
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 | 123 | 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 |
| - }); |
| 124 | + const markdownUrl = getCurrentPlaintextUrl(); |
| 125 | + const prompt = `Read ${markdownUrl} so I can ask questions about it.`; |
| 126 | + const encodedText = encodeURIComponent(prompt); |
| 127 | + const claudeUrl = `https://claude.ai/new?q=${encodedText}`; |
| 128 | + window.open(claudeUrl, '_blank'); |
158 | 129 | }
|
159 |
| - |
160 |
| - document.addEventListener("click", function (event) { |
161 |
| - const dropdown = document.getElementById("markdownDropdown"); |
162 |
| - |
163 |
| - if (!dropdown) return; |
164 |
| - |
165 |
| - const isClickInside = dropdown.contains(event.target); |
166 |
| - |
167 |
| - if (!isClickInside && dropdown.hasAttribute("open")) { |
168 |
| - dropdown.removeAttribute("open"); |
169 |
| - } |
170 |
| - }); |
171 | 130 | </script>
|
0 commit comments