@@ -8,25 +8,15 @@ import { notFound } from '@tanstack/react-router'
88import { createServerFn } from '@tanstack/react-start'
99import { z } from 'zod'
1010import { setResponseHeader } from '@tanstack/react-start/server'
11- // import {
12- // getContributorStats,
13- // getContributorStatsForLibrary,
14- // getBatchContributorStats,
15- // type ContributorStats,
16- // } from '~/server/github'
1711
1812export const loadDocs = async ( {
1913 repo,
2014 branch,
21- // currentPath,
22- // redirectPath,
2315 docsPath,
2416} : {
2517 repo : string
2618 branch : string
2719 docsPath : string
28- currentPath : string
29- redirectPath : string
3020} ) => {
3121 if ( ! branch || ! docsPath ) {
3222 throw notFound ( {
@@ -43,8 +33,6 @@ export const loadDocs = async ({
4333 repo,
4434 branch,
4535 filePath,
46- // currentPath,
47- // redirectPath,
4836 } ,
4937 } )
5038}
@@ -58,15 +46,6 @@ export const fetchDocs = createServerFn({ method: 'GET' })
5846
5947 if ( ! file ) {
6048 throw notFound ( )
61- // if (currentPath === redirectPath) {
62- // // console.log('not found')
63- // throw notFound()
64- // } else {
65- // // console.log('redirect')
66- // throw redirect({
67- // to: redirectPath,
68- // })
69- // }
7049 }
7150
7251 const frontMatter = extractFrontMatter ( file )
@@ -134,86 +113,3 @@ export const fetchRepoDirectoryContents = createServerFn({
134113
135114 return githubContents
136115 } )
137-
138- // GitHub contribution stats server functions - commented out due to performance/accuracy concerns
139- /*
140- export const fetchContributorStats = createServerFn({ method: 'GET' })
141- .inputValidator(z.object({ username: z.string() }))
142- .handler(async ({ data: { username } }) => {
143- const stats = await getContributorStats(username)
144-
145- // Cache for 30 minutes on shared cache
146- // Revalidate in the background
147- setResponseHeader('Cache-Control', 'public, max-age=0, must-revalidate')
148- setResponseHeader(
149- 'CDN-Cache-Control',
150- 'max-age=1800, stale-while-revalidate=1800, durable'
151- )
152-
153- return stats
154- })
155-
156- export const fetchContributorStatsForLibrary = createServerFn({ method: 'GET' })
157- .inputValidator(
158- z.object({
159- username: z.string(),
160- libraryRepo: z.string(),
161- })
162- )
163- .handler(async ({ data: { username, libraryRepo } }) => {
164- const stats = await getContributorStatsForLibrary(username, libraryRepo)
165-
166- // Cache for 30 minutes on shared cache
167- // Revalidate in the background
168- setResponseHeader('Cache-Control', 'public, max-age=0, must-revalidate')
169- setResponseHeader(
170- 'CDN-Cache-Control',
171- 'max-age=1800, stale-while-revalidate=1800, durable'
172- )
173-
174- return stats
175- })
176-
177- export const fetchBatchContributorStats = createServerFn({ method: 'GET' })
178- .inputValidator(z.object({ usernames: z.array(z.string()) }))
179- .handler(async ({ data: { usernames } }) => {
180- const stats = await getBatchContributorStats(usernames)
181-
182- // Cache for 30 minutes on shared cache
183- // Revalidate in the background
184- setResponseHeader('Cache-Control', 'public, max-age=0, must-revalidate')
185- setResponseHeader(
186- 'CDN-Cache-Control',
187- 'max-age=1800, stale-while-revalidate=1800, durable'
188- )
189-
190- return stats
191- })
192-
193- // Helper function to get stats for all maintainers
194- export const fetchAllMaintainerStats = createServerFn({
195- method: 'GET',
196- }).handler(async () => {
197- try {
198- // Import maintainers data
199- const { allMaintainers } = await import('~/libraries/maintainers')
200-
201- const usernames = allMaintainers.map((maintainer) => maintainer.github)
202- const stats = await getBatchContributorStats(usernames)
203-
204- // Cache for 30 minutes on shared cache
205- // Revalidate in the background
206- setResponseHeader('Cache-Control', 'public, max-age=0, must-revalidate')
207- setResponseHeader(
208- 'CDN-Cache-Control',
209- 'max-age=1800, stale-while-revalidate=1800, durable'
210- )
211-
212- return stats
213- } catch (error) {
214- console.error('Error fetching all maintainer stats:', error)
215- // Return empty array if there's an error
216- return []
217- }
218- })
219- */
0 commit comments