File tree 6 files changed +39
-23
lines changed
packages/docs/src/app/playground/(demos)
6 files changed +39
-23
lines changed Original file line number Diff line number Diff line change @@ -8,3 +8,4 @@ yarn-error.log
8
8
package-lock.json
9
9
.next /
10
10
.turbo /
11
+ .vercel
Original file line number Diff line number Diff line change 1
1
import { CodeBlock } from '@/src/components/code-block'
2
2
import { FileCode2 } from 'lucide-react'
3
3
import fs from 'node:fs/promises'
4
- import path from 'node:path'
5
4
6
5
type SourceOnGitHubProps = {
7
6
path : string
8
7
}
9
8
10
9
export async function SourceOnGitHub ( { path } : SourceOnGitHubProps ) {
11
- const source = await readSourceCode ( path )
10
+ const localPath = path . replace ( process . cwd ( ) , '' )
11
+ const source = await fs . readFile ( path , 'utf8' )
12
12
return (
13
13
< footer className = "mt-2 space-y-2 border-t py-4" >
14
14
< div className = "flex items-baseline" >
15
15
< span className = "flex items-center gap-1 text-zinc-500" >
16
16
< FileCode2 size = { 16 } />
17
- { path . split ( '/' ) . slice ( 1 ) . join ( '/' ) }
17
+ { localPath . split ( '/' ) . slice ( 1 ) . join ( '/' ) }
18
18
</ span >
19
19
< a
20
- href = { `https://github.com/47ng/nuqs/tree/next/packages/docs/src/app/playground/(demos)/ ${ path } ` }
20
+ href = { `https://github.com/47ng/nuqs/tree/next/packages/docs${ localPath } ` }
21
21
className = "ml-auto text-sm"
22
22
>
23
23
Source on GitHub
@@ -29,15 +29,3 @@ export async function SourceOnGitHub({ path }: SourceOnGitHubProps) {
29
29
</ footer >
30
30
)
31
31
}
32
-
33
- function readSourceCode ( demoPath : string ) {
34
- const demoFilePath = path . resolve (
35
- process . cwd ( ) ,
36
- 'src' ,
37
- 'app' ,
38
- 'playground' ,
39
- '(demos)' ,
40
- demoPath
41
- )
42
- return fs . readFile ( demoFilePath , 'utf8' )
43
- }
Original file line number Diff line number Diff line change @@ -16,7 +16,11 @@ export default function BasicCounterDemoPage() {
16
16
< Suspense >
17
17
< Client />
18
18
</ Suspense >
19
- < SourceOnGitHub path = "basic-counter/client.tsx" />
19
+ < SourceOnGitHub
20
+ path = {
21
+ process . cwd ( ) + '/src/app/playground/(demos)/basic-counter/client.tsx'
22
+ }
23
+ />
20
24
</ >
21
25
)
22
26
}
Original file line number Diff line number Diff line change @@ -14,7 +14,9 @@ export default function BuilderPatternDemoPage() {
14
14
< Suspense >
15
15
< Client />
16
16
</ Suspense >
17
- < SourceOnGitHub path = "batching/client.tsx" />
17
+ < SourceOnGitHub
18
+ path = { process . cwd ( ) + '/src/app/playground/(demos)/batching/client.tsx' }
19
+ />
18
20
</ >
19
21
)
20
22
}
Original file line number Diff line number Diff line change @@ -14,7 +14,11 @@ export default function HexColorsDemoPage() {
14
14
< Suspense >
15
15
< Client />
16
16
</ Suspense >
17
- < SourceOnGitHub path = "hex-colors/client.tsx" />
17
+ < SourceOnGitHub
18
+ path = {
19
+ process . cwd ( ) + '/src/app/playground/(demos)/hex-colors/client.tsx'
20
+ }
21
+ />
18
22
</ >
19
23
)
20
24
}
Original file line number Diff line number Diff line change @@ -33,10 +33,27 @@ export default async function PaginationDemoPage({ searchParams }: PageProps) {
33
33
< Suspense >
34
34
< ProductSection />
35
35
</ Suspense >
36
- < SourceOnGitHub path = "pagination/searchParams.ts" />
37
- < SourceOnGitHub path = "pagination/page.tsx" />
38
- < SourceOnGitHub path = "pagination/pagination-controls.server.tsx" />
39
- < SourceOnGitHub path = "pagination/pagination-controls.client.tsx" />
36
+ < SourceOnGitHub
37
+ path = {
38
+ process . cwd ( ) +
39
+ '/src/app/playground/(demos)/pagination/searchParams.ts'
40
+ }
41
+ />
42
+ < SourceOnGitHub
43
+ path = { process . cwd ( ) + '/src/app/playground/(demos)/pagination/page.tsx' }
44
+ />
45
+ < SourceOnGitHub
46
+ path = {
47
+ process . cwd ( ) +
48
+ '/src/app/playground/(demos)/pagination/pagination-controls.server.tsx'
49
+ }
50
+ />
51
+ < SourceOnGitHub
52
+ path = {
53
+ process . cwd ( ) +
54
+ '/src/app/playground/(demos)/pagination/pagination-controls.client.tsx'
55
+ }
56
+ />
40
57
</ >
41
58
)
42
59
}
You can’t perform that action at this time.
0 commit comments