Skip to content

Commit fc5278a

Browse files
committed
2 parents c7c4d60 + ebbdfdc commit fc5278a

File tree

2 files changed

+49
-21
lines changed

2 files changed

+49
-21
lines changed

src/components/CopyPageDropdown.tsx

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ function ChatGPTIcon({ className }: { className?: string }) {
4747
)
4848
}
4949

50+
// Cursor icon
51+
function CursorIcon({ className }: { className?: string }) {
52+
return (
53+
<svg viewBox="0 0 24 24" fill="currentColor" className={className}>
54+
<path d="M22.106 5.68L12.5.135a.998.998 0 00-.998 0L1.893 5.68a.84.84 0 00-.419.726v11.186c0 .3.16.577.42.727l9.607 5.547a.999.999 0 00.998 0l9.608-5.547a.84.84 0 00.42-.727V6.407a.84.84 0 00-.42-.726zm-.603 1.176L12.228 22.92c-.063.108-.228.064-.228-.061V12.34a.59.59 0 00-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264 0 .428.286.296.514z"></path>
55+
</svg>
56+
)
57+
}
58+
5059
// Cache for fetched markdown content
5160
const markdownCache = new Map<string, string>()
5261

@@ -153,6 +162,17 @@ export function CopyPageDropdown({
153162
window.open(`https://chatgpt.com/?q=${prompt}`, '_blank')
154163
}
155164

165+
const handleOpenInCursor = () => {
166+
const pageUrl = window.location.href
167+
const prompt = `Read from this URL:\n${pageUrl}\nand explain it to me`
168+
window.open(
169+
`cursor://anysphere.cursor-deeplink/prompt?text=${encodeURIComponent(
170+
prompt,
171+
)}`,
172+
'_blank',
173+
)
174+
}
175+
156176
const menuItems = [
157177
{
158178
icon: MarkdownIcon,
@@ -172,6 +192,12 @@ export function CopyPageDropdown({
172192
description: 'Ask questions about this page',
173193
onSelect: handleOpenInChatGPT,
174194
},
195+
{
196+
icon: CursorIcon,
197+
label: 'Open in Cursor',
198+
description: 'Ask questions about this page',
199+
onSelect: handleOpenInCursor,
200+
},
175201
]
176202

177203
return (
@@ -246,7 +272,7 @@ export function CopyPageDropdown({
246272
)}
247273
onSelect={item.onSelect}
248274
>
249-
<div className="flex-shrink-0 w-5 h-5 flex items-center justify-center text-gray-500 dark:text-gray-400">
275+
<div className="flex-shrink-0 w-5 h-5 flex items-center justify-center text-gray-700 dark:text-gray-400">
250276
<item.icon className="w-4 h-4" />
251277
</div>
252278
<div className="flex flex-col gap-0.5">

src/components/Navbar.tsx

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import {
2626
Unauthenticated,
2727
AuthLoading,
2828
} from '~/components/AuthComponents'
29-
import { libraries } from '~/libraries'
29+
import { libraries, findLibrary } from '~/libraries'
3030
import { useCapabilities } from '~/hooks/useCapabilities'
3131
import { useClickOutside } from '~/hooks/useClickOutside'
3232
import { GithubIcon } from '~/components/icons/GithubIcon'
@@ -40,9 +40,15 @@ export function Navbar({ children }: { children: React.ReactNode }) {
4040
const matches = useMatches()
4141
const capabilities = useCapabilities()
4242

43-
const Title =
44-
[...matches].reverse().find((m) => m.staticData.Title)?.staticData.Title ??
45-
null
43+
const { Title, library } = React.useMemo(() => {
44+
const match = [...matches].reverse().find((m) => m.staticData.Title)
45+
const libraryId = match?.params?.libraryId
46+
47+
return {
48+
Title: match?.staticData.Title ?? null,
49+
library: libraryId ? findLibrary(libraryId) : null,
50+
}
51+
}, [matches])
4652

4753
const canAdmin = capabilities.includes('admin')
4854

@@ -133,34 +139,30 @@ export function Navbar({ children }: { children: React.ReactNode }) {
133139
)
134140

135141
const socialLinks = (
136-
<div className="flex items-center">
142+
<div className="flex items-center [&_a]:p-1.5 [&_a]:opacity-50 [&_a:hover]:opacity-100 [&_a]:transition-opacity [&_svg]:text-sm">
137143
<a
138-
href="https://x.com/tan_stack"
139-
className="p-1.5 opacity-50 hover:opacity-100 transition-opacity"
140-
aria-label="Follow TanStack on X.com"
144+
href={`https://github.com/${library?.repo ?? 'tanstack'}`}
145+
aria-label={`Follow ${library?.name ?? 'TanStack'} on GitHub`}
141146
>
142-
<BrandXIcon className="text-sm" />
147+
<GithubIcon />
148+
</a>
149+
<a href="https://x.com/tan_stack" aria-label="Follow TanStack on X.com">
150+
<BrandXIcon />
143151
</a>
144152
<a
145153
href="https://bsky.app/profile/tanstack.com"
146-
className="p-1.5 opacity-50 hover:opacity-100 transition-opacity"
147-
aria-label="Follow TanStack on Bluesky"
154+
aria-label="Follow TanStack on Besky"
148155
>
149-
<BSkyIcon className="text-sm" />
156+
<BSkyIcon />
150157
</a>
151158
<a
152159
href="https://instagram.com/tan_stack"
153-
className="p-1.5 opacity-50 hover:opacity-100 transition-opacity"
154160
aria-label="Follow TanStack on Instagram"
155161
>
156-
<InstagramIcon className="text-sm" />
162+
<InstagramIcon />
157163
</a>
158-
<a
159-
href="https://tlinz.com/discord"
160-
className="p-1.5 opacity-50 hover:opacity-100 transition-opacity"
161-
aria-label="Join TanStack Discord"
162-
>
163-
<DiscordIcon className="text-sm" />
164+
<a href="https://tlinz.com/discord" aria-label="Join TanStack Discord">
165+
<DiscordIcon />
164166
</a>
165167
</div>
166168
)

0 commit comments

Comments
 (0)