Skip to content

Commit 9db650a

Browse files
authored
Add pages (#6)
* add layout * add docs * fix layout * add layout * add endpoints * add pages * fix loader * add indexed * add cross-app wallets * fix RegExpExecArray
1 parent 4ca174b commit 9db650a

24 files changed

Lines changed: 3981 additions & 124 deletions

File tree

src/app/api/docs/route.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { NextRequest, NextResponse } from 'next/server'
2+
import fs from 'fs'
3+
import path from 'path'
4+
5+
export async function GET(request: NextRequest) {
6+
try {
7+
const { searchParams } = new URL(request.url)
8+
const file = searchParams.get('file')
9+
10+
if (!file) {
11+
// 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'))
14+
15+
return NextResponse.json({ files })
16+
}
17+
18+
// Return specific file content
19+
const docsPath = path.join(process.cwd(), '../w3pk/docs', file)
20+
const content = fs.readFileSync(docsPath, 'utf-8')
21+
22+
return NextResponse.json({ content, filename: file })
23+
} catch (error) {
24+
console.error('Error reading docs:', error)
25+
return NextResponse.json(
26+
{ error: 'Failed to read documentation' },
27+
{ status: 500 }
28+
)
29+
}
30+
}

src/app/docs/error.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
'use client'
2+
3+
import { Box, Heading, Text, VStack } from '@chakra-ui/react'
4+
import { Button } from '@/components/ui/button'
5+
import { useEffect } from 'react'
6+
import { brandColors } from '@/theme'
7+
8+
export default function Error({
9+
error,
10+
reset,
11+
}: {
12+
error: Error & { digest?: string }
13+
reset: () => void
14+
}) {
15+
useEffect(() => {
16+
console.error('Documentation page error:', error)
17+
}, [error])
18+
19+
return (
20+
<Box py={20}>
21+
<VStack gap={6} align="center" maxW="600px" mx="auto" p={6}>
22+
<Heading as="h2" size="xl" color="red.400">
23+
Something went wrong!
24+
</Heading>
25+
<Text fontSize="lg" color="gray.400" textAlign="center">
26+
An error occurred while loading the documentation.
27+
</Text>
28+
{error.message && (
29+
<Box
30+
p={4}
31+
bg="red.900"
32+
borderRadius="md"
33+
borderWidth="1px"
34+
borderColor="red.700"
35+
w="full"
36+
>
37+
<Text fontSize="sm" color="red.200" fontFamily="mono" wordBreak="break-word">
38+
{error.message}
39+
</Text>
40+
</Box>
41+
)}
42+
<Button
43+
bg={brandColors.accent}
44+
color="white"
45+
_hover={{ bg: '#3691e7' }}
46+
onClick={reset}
47+
>
48+
Try again
49+
</Button>
50+
</VStack>
51+
</Box>
52+
)
53+
}

src/app/docs/layout.tsx

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { Metadata } from 'next'
2+
3+
export const metadata: Metadata = {
4+
title: 'Docs | w3pk',
5+
description:
6+
'Complete technical documentation for W3PK, the passwordless Web3 authentication SDK',
7+
8+
openGraph: {
9+
title: 'Docs | w3pk',
10+
description:
11+
'Complete technical documentation for W3PK, the passwordless Web3 authentication SDK',
12+
url: 'https://w3pk.w3hc.org/docs',
13+
siteName: 'w3pk Playground',
14+
images: [
15+
{
16+
url: '/huangshan.png',
17+
width: 1200,
18+
height: 630,
19+
alt: 'W3PK Documentation',
20+
},
21+
],
22+
locale: 'en_US',
23+
type: 'website',
24+
},
25+
26+
twitter: {
27+
card: 'summary_large_image',
28+
title: 'Docs | w3pk',
29+
description:
30+
'Complete technical documentation for W3PK, the passwordless Web3 authentication SDK',
31+
images: ['/huangshan.png'],
32+
creator: '@julienbrg',
33+
},
34+
}
35+
36+
export default function DocsLayout({ children }: { children: React.ReactNode }) {
37+
return <>{children}</>
38+
}

0 commit comments

Comments
 (0)