Skip to content

Commit decb893

Browse files
committed
Add 'Open in Cursor' link
1 parent 85b639a commit decb893

File tree

2 files changed

+52
-14
lines changed

2 files changed

+52
-14
lines changed

public/cursor.svg

Lines changed: 12 additions & 0 deletions
Loading

src/components/react/CopyPageButton.tsx

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
DropdownMenu,
1010
DropdownMenuContent,
1111
DropdownMenuItem,
12+
DropdownMenuSeparator,
1213
DropdownMenuTrigger,
1314
} from '@/components/ui/dropdown-menu';
1415

@@ -27,9 +28,7 @@ const ChatGPTIcon = () => (
2728

2829
// Claude logo
2930
const ClaudeIcon = () => (
30-
<svg viewBox="0 0 24 24" className="size-4" fill="currentColor">
31-
<path d="M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z" />
32-
</svg>
31+
<img src="/claude.svg" alt="" className="size-4 dark:invert" />
3332
);
3433

3534
// Markdown logo
@@ -49,6 +48,11 @@ const MarkdownIcon = () => (
4948
</svg>
5049
);
5150

51+
// Cursor logo
52+
const CursorIcon = () => (
53+
<img src="/cursor.svg" alt="" className="size-4 dark:invert" />
54+
);
55+
5256
export function CopyPageButton({
5357
pageMarkdown,
5458
pageUrl,
@@ -79,6 +83,14 @@ export function CopyPageButton({
7983
);
8084
};
8185

86+
const handleOpenCursor = () => {
87+
const mdUrl = `${pageUrl.replace(/\/$/, '')}.md`;
88+
const prompt = `Load the contents of ${mdUrl} into this chat's context so we can discuss it.`;
89+
window.location.href =
90+
'cursor://anysphere.cursor-deeplink/prompt?text=' +
91+
encodeURIComponent(prompt);
92+
};
93+
8294
const handleViewMarkdown = () => {
8395
const url = new URL(pageUrl);
8496
const path = url.pathname.replace(/\/$/, '');
@@ -107,42 +119,56 @@ export function CopyPageButton({
107119
</DropdownMenuTrigger>
108120
<DropdownMenuContent align="end" className="w-64">
109121
<DropdownMenuItem
110-
onClick={handleViewMarkdown}
122+
onClick={handleOpenChatGPT}
111123
className="flex flex-col items-start gap-0.5 py-2"
112124
>
113125
<div className="flex items-center gap-2">
114-
<MarkdownIcon />
115-
<span className="font-medium">View as Markdown</span>
126+
<ChatGPTIcon />
127+
<span className="font-medium">Open in ChatGPT</span>
116128
<ArrowUpRight className="size-3 opacity-50" />
117129
</div>
118130
<span className="text-xs text-muted-foreground pl-6">
119-
Open raw markdown in new tab
131+
Ask questions about this page
120132
</span>
121133
</DropdownMenuItem>
122134
<DropdownMenuItem
123-
onClick={handleOpenChatGPT}
135+
onClick={handleOpenClaude}
124136
className="flex flex-col items-start gap-0.5 py-2"
125137
>
126138
<div className="flex items-center gap-2">
127-
<ChatGPTIcon />
128-
<span className="font-medium">Open in ChatGPT</span>
139+
<ClaudeIcon />
140+
<span className="font-medium">Open in Claude</span>
129141
<ArrowUpRight className="size-3 opacity-50" />
130142
</div>
131143
<span className="text-xs text-muted-foreground pl-6">
132144
Ask questions about this page
133145
</span>
134146
</DropdownMenuItem>
135147
<DropdownMenuItem
136-
onClick={handleOpenClaude}
148+
onClick={handleOpenCursor}
149+
className="hidden sm:flex flex-col items-start gap-0.5 py-2"
150+
>
151+
<div className="flex items-center gap-2">
152+
<CursorIcon />
153+
<span className="font-medium">Open in Cursor</span>
154+
<ArrowUpRight className="size-3 opacity-50" />
155+
</div>
156+
<span className="text-xs text-muted-foreground pl-6">
157+
Open page context in Cursor
158+
</span>
159+
</DropdownMenuItem>
160+
<DropdownMenuSeparator />
161+
<DropdownMenuItem
162+
onClick={handleViewMarkdown}
137163
className="flex flex-col items-start gap-0.5 py-2"
138164
>
139165
<div className="flex items-center gap-2">
140-
<ClaudeIcon />
141-
<span className="font-medium">Open in Claude</span>
166+
<MarkdownIcon />
167+
<span className="font-medium">View as Markdown</span>
142168
<ArrowUpRight className="size-3 opacity-50" />
143169
</div>
144170
<span className="text-xs text-muted-foreground pl-6">
145-
Ask questions about this page
171+
Open raw markdown in new tab
146172
</span>
147173
</DropdownMenuItem>
148174
</DropdownMenuContent>

0 commit comments

Comments
 (0)