diff --git a/packages/docs/src/app/playground/(demos)/_components/source-on-github.tsx b/packages/docs/src/app/playground/(demos)/_components/source-on-github.tsx index ef7cdc0fe..7da56ef66 100644 --- a/packages/docs/src/app/playground/(demos)/_components/source-on-github.tsx +++ b/packages/docs/src/app/playground/(demos)/_components/source-on-github.tsx @@ -1,8 +1,6 @@ import { CodeBlock } from '@/src/components/code-block' import { FileCode2 } from 'lucide-react' import fs from 'node:fs/promises' -import path from 'node:path' -import { fileURLToPath } from 'url' type SourceOnGitHubProps = { path: string @@ -32,25 +30,7 @@ export async function SourceOnGitHub({ path }: SourceOnGitHubProps) { } function readSourceCode(demoPath: string) { - const demoFilePath = resolve(import.meta.url, '..', demoPath) + const demoFilePath = process.cwd() + '/src/app/playground/(demos)/' + demoPath console.log(demoFilePath) return fs.readFile(demoFilePath, 'utf8') } - -const __dirname = path.dirname(fileURLToPath(import.meta.url)) -const nextJsRootDir = path.resolve(__dirname, '../../../../..') - -function resolve(importMetaUrl: string, ...paths: string[]) { - const filePath = fileURLToPath(importMetaUrl) - const dirname = path.dirname(filePath) - const fileName = path.basename(filePath) - const absPath = path.resolve( - dirname, - // This makes sure that if only the import.meta.url is passed, - // we resolve to the same file. Otherwise, allow relative paths. - ...(paths.length === 0 ? [fileName] : paths) - ) - // Required for ISR serverless functions to pick up the file path - // as a dependency to bundle. - return path.resolve(process.cwd(), absPath.replace(nextJsRootDir, '.')) -}