Skip to content

Commit 66418ca

Browse files
committed
chore: Read from cache
1 parent 041714e commit 66418ca

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

packages/docs/src/app/(pages)/_landing/dependents/crawler.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ enum PackageId {
55
nextUseQueryState = 'UGFja2FnZS0xMTYwOTg5NDIx'
66
}
77

8-
type Result = {
8+
export type Result = {
99
repo: string
1010
stars: number
1111
pkg: string
@@ -47,7 +47,9 @@ async function crawlDependentsPage(url: string) {
4747
new URLSearchParams(url.split('?')[1]).get('package_id') === PackageId.nuqs
4848
? 'nuqs'
4949
: 'next-usequerystate'
50-
const html = await fetch(url).then(res => res.text())
50+
const html = await fetch(url, {
51+
cache: 'no-store'
52+
}).then(res => res.text())
5153
const $ = cheerio.load(html)
5254
const results: Result[] = []
5355
$('[data-test-id="dg-repo-pkg-dependent"]').each((index, element) => {

packages/docs/src/app/(pages)/_landing/dependents/dependents.tsx

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import { cn } from '@/src/lib/utils'
22
import Image from 'next/image'
3-
import { crawlDependents } from './crawler'
3+
import type { Result } from './crawler'
44

55
export async function DependentsSection() {
6-
const dependents = await crawlDependents()
6+
const dependents: Result[] = await fetch(
7+
'https://nuqs.47ng.com/api/dependents',
8+
{
9+
next: {
10+
revalidate: 86_400
11+
}
12+
}
13+
).then(res => res.json())
714
return (
815
<section className="container">
916
<h2 className="mb-8 text-center text-3xl font-bold tracking-tighter dark:text-white md:text-4xl xl:text-5xl">

0 commit comments

Comments
 (0)