Skip to content

Commit 5af5a69

Browse files
committed
feat: integrate SWR for data fetching and update GitHub API authorization method
1 parent 2098e1e commit 5af5a69

2 files changed

Lines changed: 15 additions & 6 deletions

File tree

pages/_app.tsx

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import type { AppProps } from 'next/app';
22
import { ThemeProvider } from 'next-themes';
33
import { Analytics } from '@vercel/analytics/react';
44
import { SpeedInsights } from '@vercel/speed-insights/next';
5+
import { SWRConfig } from 'swr';
56

67
import { isProduction } from '@/lib/utils';
78

@@ -16,11 +17,19 @@ function MyApp({ Component, pageProps }: AppProps) {
1617
{isProduction() && <GoogleAnalytics />}
1718

1819
<ThemeProvider attribute="class">
19-
<Layout>
20-
<Component {...pageProps} />
21-
<SpeedInsights />
22-
<Analytics />
23-
</Layout>
20+
<SWRConfig
21+
value={{
22+
revalidateOnFocus: false,
23+
revalidateOnReconnect: false,
24+
dedupingInterval: 60000, // 1 minute
25+
}}
26+
>
27+
<Layout>
28+
<Component {...pageProps} />
29+
<SpeedInsights />
30+
<Analytics />
31+
</Layout>
32+
</SWRConfig>
2433
</ThemeProvider>
2534
</>
2635
);

pages/api/github.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NextApiRequest, NextApiResponse } from 'next';
22

33
const GH_HEADERS = new Headers({
4-
Authorization: `Bauer ${process.env.GITHUB_TOKEN}`,
4+
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`,
55
});
66

77
const starReducer = (acc: number, repo: { stargazers_count: number }) => {

0 commit comments

Comments
 (0)