Skip to content

Commit 228011e

Browse files
committed
Add scraper tooltip
1 parent 8a25c34 commit 228011e

File tree

1 file changed

+10
-25
lines changed

1 file changed

+10
-25
lines changed

apps/web/content/blog/build-time-components.mdx

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Build-time Components
33
description: Why React Server Components are a leap forward for content-driven websites
44
date: 2024-09-04
55
authors: [pomber]
6-
draft: true
6+
draft: false
77
---
88

99
import {
@@ -236,29 +236,14 @@ We also have a <WithTooltip name="two">_`function LinkWithCard({ href, children,
236236
!isCode true
237237

238238
```jsx scraper.js
239-
function LinkWithCard({
240-
href,
241-
children,
242-
image,
243-
}: {
244-
href: string
245-
children: React.ReactNode
246-
image: string
247-
}) {
248-
return (
249-
<HoverCard openDelay={200} closeDelay={100}>
250-
<HoverCardTrigger
251-
className="text-zinc-900 decoration-zinc-700"
252-
href={href}
253-
>
254-
{children}
255-
<img src={image} alt={href} className="hidden" fetchPriority="low" />
256-
</HoverCardTrigger>
257-
<HoverCardContent className="p-0 overflow-hidden [&>*]:m-0">
258-
<img src={image} alt={href} />
259-
</HoverCardContent>
260-
</HoverCard>
261-
)
239+
const regex = /<meta property="og:image" content="([^"]+)"/
240+
export async function scrape(url) {
241+
const res = await fetch(url)
242+
const html = await res.text()
243+
const match = html.match(regex)
244+
return {
245+
image: match ? match[1] : null,
246+
}
262247
}
263248
```
264249

@@ -537,7 +522,7 @@ In the talk [Mind the Gap](https://www.youtube.com/watch?v=zqhE-CepH2g), Ryan Fl
537522

538523
This same technology that abstracted the network layer is also abstracting the build-time layer.
539524

540-
I hope these wins in developer experience translate in [richer](/blog/rich-content-websites) content-driven websites.
525+
I hope these wins in developer experience translate into [richer](/blog/rich-content-websites) content-driven websites.
541526

542527
---
543528

0 commit comments

Comments
 (0)