Skip to content

Commit 4e53ab1

Browse files
authored
Fix fetching the docs (#8)
* comment out voting app * fix fetching
1 parent 9db650a commit 4e53ab1

2 files changed

Lines changed: 26 additions & 10 deletions

File tree

src/app/api/docs/route.ts

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
import { NextRequest, NextResponse } from 'next/server'
2-
import fs from 'fs'
3-
import path from 'path'
2+
3+
const GITHUB_DOCS_URL = 'https://raw.githubusercontent.com/w3hc/w3pk/main/docs'
4+
5+
const DOC_FILES = [
6+
'QUICK_START.md',
7+
'API_REFERENCE.md',
8+
'INTEGRATION_GUIDELINES.md',
9+
'SECURITY.md',
10+
'ARCHITECTURE.md',
11+
'RECOVERY.md',
12+
'EIP-7951.md',
13+
'EIP_7702.md',
14+
'ZK.md',
15+
'BUILD_VERIFICATION.md',
16+
'BROWSER_COMPATIBILITY.md',
17+
]
418

519
export async function GET(request: NextRequest) {
620
try {
@@ -9,15 +23,17 @@ export async function GET(request: NextRequest) {
923

1024
if (!file) {
1125
// Return list of all docs
12-
const docsPath = path.join(process.cwd(), '../w3pk/docs')
13-
const files = fs.readdirSync(docsPath).filter(f => f.endsWith('.md'))
26+
return NextResponse.json({ files: DOC_FILES })
27+
}
28+
29+
// Fetch specific file content from GitHub
30+
const response = await fetch(`${GITHUB_DOCS_URL}/${file}`)
1431

15-
return NextResponse.json({ files })
32+
if (!response.ok) {
33+
throw new Error(`Failed to fetch ${file}: ${response.statusText}`)
1634
}
1735

18-
// Return specific file content
19-
const docsPath = path.join(process.cwd(), '../w3pk/docs', file)
20-
const content = fs.readFileSync(docsPath, 'utf-8')
36+
const content = await response.text()
2137

2238
return NextResponse.json({ content, filename: file })
2339
} catch (error) {

src/app/zk/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,7 @@ console.log('Is valid member?', isValid) // true
533533
</Box>
534534

535535
{/* Call to Action */}
536-
<Box
536+
{/* <Box
537537
p={8}
538538
borderColor={brandColors.accent}
539539
border="2px solid"
@@ -568,7 +568,7 @@ console.log('Is valid member?', isValid) // true
568568
<Text fontSize="sm" color="whiteAlpha.700" mt={4}>
569569
Experience passwordless authentication + anonymous voting
570570
</Text>
571-
</Box>
571+
</Box> */}
572572
</VStack>
573573
</Container>
574574
)

0 commit comments

Comments
 (0)