Skip to content

Commit f73e46f

Browse files
committed
chore: Trying things
1 parent 25ec84e commit f73e46f

File tree

6 files changed

+39
-23
lines changed

6 files changed

+39
-23
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ yarn-error.log
88
package-lock.json
99
.next/
1010
.turbo/
11+
.vercel
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
import { CodeBlock } from '@/src/components/code-block'
22
import { FileCode2 } from 'lucide-react'
33
import fs from 'node:fs/promises'
4-
import path from 'node:path'
54

65
type SourceOnGitHubProps = {
76
path: string
87
}
98

109
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')
1212
return (
1313
<footer className="mt-2 space-y-2 border-t py-4">
1414
<div className="flex items-baseline">
1515
<span className="flex items-center gap-1 text-zinc-500">
1616
<FileCode2 size={16} />
17-
{path.split('/').slice(1).join('/')}
17+
{localPath.split('/').slice(1).join('/')}
1818
</span>
1919
<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}`}
2121
className="ml-auto text-sm"
2222
>
2323
Source on GitHub
@@ -29,15 +29,3 @@ export async function SourceOnGitHub({ path }: SourceOnGitHubProps) {
2929
</footer>
3030
)
3131
}
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-
}

packages/docs/src/app/playground/(demos)/basic-counter/page.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ export default function BasicCounterDemoPage() {
1616
<Suspense>
1717
<Client />
1818
</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+
/>
2024
</>
2125
)
2226
}

packages/docs/src/app/playground/(demos)/batching/page.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ export default function BuilderPatternDemoPage() {
1414
<Suspense>
1515
<Client />
1616
</Suspense>
17-
<SourceOnGitHub path="batching/client.tsx" />
17+
<SourceOnGitHub
18+
path={process.cwd() + '/src/app/playground/(demos)/batching/client.tsx'}
19+
/>
1820
</>
1921
)
2022
}

packages/docs/src/app/playground/(demos)/hex-colors/page.tsx

+5-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ export default function HexColorsDemoPage() {
1414
<Suspense>
1515
<Client />
1616
</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+
/>
1822
</>
1923
)
2024
}

packages/docs/src/app/playground/(demos)/pagination/page.tsx

+21-4
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,27 @@ export default async function PaginationDemoPage({ searchParams }: PageProps) {
3333
<Suspense>
3434
<ProductSection />
3535
</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+
/>
4057
</>
4158
)
4259
}

0 commit comments

Comments
 (0)