{"id":13455694,"url":"https://github.com/aspida/pathpida","last_synced_at":"2025-05-14T12:12:44.374Z","repository":{"id":39152953,"uuid":"267703350","full_name":"aspida/pathpida","owner":"aspida","description":"TypeScript friendly internal link client for Next.js.","archived":false,"fork":false,"pushed_at":"2025-04-11T14:09:32.000Z","size":1143,"stargazers_count":513,"open_issues_count":11,"forks_count":33,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-13T08:58:43.657Z","etag":null,"topics":["nextjs","typescript"],"latest_commit_sha":null,"homepage":"https://github.com/aspida/pathpida","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aspida.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-05-28T21:45:59.000Z","updated_at":"2025-04-10T08:34:15.000Z","dependencies_parsed_at":"2024-06-19T00:14:07.297Z","dependency_job_id":"900d90a1-b4e3-46e2-9cd7-fcaa18cc03a3","html_url":"https://github.com/aspida/pathpida","commit_stats":{"total_commits":183,"total_committers":12,"mean_commits":15.25,"dds":0.2622950819672131,"last_synced_commit":"428e9f8b953d95473cc0ccaf844888c7d22ad477"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspida%2Fpathpida","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspida%2Fpathpida/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspida%2Fpathpida/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aspida%2Fpathpida/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aspida","download_url":"https://codeload.github.com/aspida/pathpida/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254140768,"owners_count":22021220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nextjs","typescript"],"created_at":"2024-07-31T08:01:09.513Z","updated_at":"2025-05-14T12:12:39.361Z","avatar_url":"https://github.com/aspida.png","language":"TypeScript","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"readme":"# pathpida\n\n\u003cbr /\u003e\n\u003cimg src=\"https://aspida.github.io/pathpida/logos/png/logo.png\" alt=\"pathpida\" title=\"pathpida\" /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://www.npmjs.com/package/pathpida\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/v/pathpida\" alt=\"npm version\" /\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/pathpida\"\u003e\n    \u003cimg src=\"https://img.shields.io/npm/dm/pathpida\" alt=\"npm download\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\u003cbr /\u003e\n\u003cp align=\"center\"\u003eTypeScript friendly pages and static path generator for Next.js.\u003c/p\u003e\n\u003cbr /\u003e\n\u003cbr /\u003e\n\n## Breaking change :warning:\n\n### 2024/12/14\n\nSince pathpida \u003e= `0.23.0` , removed Nuxt support.\n\n### 2022/11/25\n\nSince pathpida \u003e= `0.20.0` , removed Sapper support.\n\n## Features\n\n- **Type safety**. Automatically generate type definition files for manipulating internal links in Next.js.\n- **Zero configuration**. No configuration required can be used immediately after installation.\n- **Zero runtime**. Lightweight because runtime code is not included in the bundle.\n- **Support for static files**. Static files in public/ are also supported, so static assets can be safely referenced.\n- **Support for appDir of Next.js 13 Layout**.\n\n## Table of Contents\n\n- [Install](#Install)\n- [Command Line Interface Options](#CLI-options)\n- [Setup](#Setup)\n- [Usage](#Usage)\n- [Define query](#Define-query)\n- [Generate static files path](#Generate-static-files-path)\n- [License](#License)\n\n## Install\n\n- Using [npm](https://www.npmjs.com/):\n\n  ```sh\n  $ npm install pathpida npm-run-all --save-dev\n  ```\n\n- Using [Yarn](https://yarnpkg.com/):\n\n  ```sh\n  $ yarn add pathpida npm-run-all --dev\n  ```\n\n\u003ca id=\"CLI-options\"\u003e\u003c/a\u003e\n\n## Command Line Interface Options\n\n\u003ctable\u003e\n  \u003cthead\u003e\n    \u003ctr\u003e\n      \u003cth\u003eOption\u003c/th\u003e\n      \u003cth\u003eType\u003c/th\u003e\n      \u003cth width=\"100%\"\u003eDescription\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003ctd nowrap\u003e\u003ccode\u003e--enableStatic\u003c/code\u003e\u003cbr /\u003e\u003ccode\u003e-s\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003eGenerate static files path in \u003ccode\u003e$path.ts\u003c/code\u003e.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd nowrap\u003e\u003ccode\u003e--ignorePath\u003c/code\u003e\u003cbr /\u003e\u003ccode\u003e-p\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eSpecify the ignore pattern file path.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd nowrap\u003e\u003ccode\u003e--output\u003c/code\u003e\u003cbr /\u003e\u003ccode\u003e-o\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003ccode\u003estring\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003eSpecify the output directory for \u003ccode\u003e$path.ts\u003c/code\u003e.\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd nowrap\u003e\u003ccode\u003e--watch\u003c/code\u003e\u003cbr /\u003e\u003ccode\u003e-w\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003e\n        Enable watch mode.\u003cbr /\u003e\n        Regenerate \u003ccode\u003e$path.ts\u003c/code\u003e.\n      \u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003ctd nowrap\u003e\u003ccode\u003e--version\u003c/code\u003e\u003cbr /\u003e\u003ccode\u003e-v\u003c/code\u003e\u003c/td\u003e\n      \u003ctd\u003e\u003c/td\u003e\n      \u003ctd\u003ePrint pathpida version.\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\n## Setup\n\n`package.json`\n\n```json\n{\n  \"scripts\": {\n    \"dev\": \"run-p dev:*\",\n    \"dev:next\": \"next dev\",\n    \"dev:path\": \"pathpida --ignorePath .gitignore --watch\",\n    \"build\": \"pathpida --ignorePath .gitignore \u0026\u0026 next build\"\n  }\n}\n```\n\n## Usage\n\n```\npages/index.tsx\npages/post/create.tsx\npages/post/[pid].tsx\npages/post/[...slug].tsx\n\nlib/$path.ts or utils/$path.ts // Generated automatically by pathpida\n```\n\nor\n\n```\nsrc/pages/index.tsx\nsrc/pages/post/create.tsx\nsrc/pages/post/[pid].tsx\nsrc/pages/post/[...slug].tsx\n\nsrc/lib/$path.ts or src/utils/$path.ts // Generated automatically by pathpida\n```\n\n`pages/index.tsx`\n\n```tsx\nimport Link from 'next/link';\nimport { pagesPath } from '../lib/$path';\n\nconsole.log(pagesPath.post.create.$url()); // { pathname: '/post/create' }\nconsole.log(pagesPath.post._pid(1).$url()); // { pathname: '/post/[pid]', query: { pid: 1 }}\nconsole.log(pagesPath.post._slug(['a', 'b', 'c']).$url()); // { pathname: '/post//[...slug]', query: { slug: ['a', 'b', 'c'] }}\n\nexport default () =\u003e {\n  const onClick = useCallback(() =\u003e {\n    router.push(pagesPath.post._pid(1).$url());\n  }, []);\n\n  return (\n    \u003c\u003e\n      \u003cLink href={pagesPath.post._slug(['a', 'b', 'c']).$url()} /\u003e\n      \u003cdiv onClick={onClick} /\u003e\n    \u003c/\u003e\n  );\n};\n```\n\n\u003ca id=\"Define-query\"\u003e\u003c/a\u003e\n\n## Define query\n\n`pages/post/create.tsx`\n\n```tsx\nexport type Query = {\n  userId: number;\n  name?: string;\n};\n\nexport default () =\u003e \u003cdiv /\u003e;\n```\n\n`pages/post/[pid].tsx`\n\n```tsx\nexport type OptionalQuery = {\n  limit: number;\n  label?: string;\n};\n\nexport default () =\u003e \u003cdiv /\u003e;\n```\n\n`pages/index.tsx`\n\n```tsx\nimport Link from 'next/link';\nimport { pagesPath } from '../lib/$path';\n\nconsole.log(pagesPath.post.create.$url({ query: { userId: 1 } })); // { pathname: '/post/create', query: { userId: 1 }}\nconsole.log(pagesPath.post.create.$url()); // type error\nconsole.log(pagesPath.post._pid(1).$url()); // { pathname: '/post/[pid]', query: { pid: 1 }}\nconsole.log(pagesPath.post._pid(1).$url({ query: { limit: 10 }, hash: 'sample' })); // { pathname: '/post/[pid]', query: { pid: 1, limit: 10 }, hash: 'sample' }\n\nexport default () =\u003e {\n  const onClick = useCallback(() =\u003e {\n    router.push(pagesPath.post._pid(1).$url());\n  }, []);\n\n  return (\n    \u003c\u003e\n      \u003cLink href={pagesPath.post._slug(['a', 'b', 'c']).$url()} /\u003e\n      \u003cdiv onClick={onClick} /\u003e\n    \u003c/\u003e\n  );\n};\n```\n\n\u003ca id=\"Generate-static-files-path\"\u003e\u003c/a\u003e\n\n## Generate static files path\n\n`package.json`\n\n```json\n{\n  \"scripts\": {\n    \"dev\": \"run-p dev:*\",\n    \"dev:next\": \"next dev\",\n    \"dev:path\": \"pathpida --enableStatic --watch\",\n    \"build\": \"pathpida --enableStatic \u0026\u0026 next build\"\n  }\n}\n```\n\n```\npages/index.tsx\npages/post/create.tsx\npages/post/[pid].tsx\npages/post/[...slug].tsx\n\npublic/aa.json\npublic/bb/cc.png\n\nlib/$path.ts or utils/$path.ts // Generated automatically by pathpida\n```\n\nor\n\n```\nsrc/pages/index.tsx\nsrc/pages/post/create.tsx\nsrc/pages/post/[pid].tsx\nsrc/pages/post/[...slug].tsx\n\npublic/aa.json\npublic/bb/cc.png\n\nsrc/lib/$path.ts or src/utils/$path.ts // Generated automatically by pathpida\n```\n\n`pages/index.tsx`\n\n```tsx\nimport Link from 'next/link';\nimport { pagesPath, staticPath } from '../lib/$path';\n\nconsole.log(staticPath.aa_json); // /aa.json\n\nexport default () =\u003e {\n  return (\n    \u003c\u003e\n      \u003cLink href={pagesPath.post._slug(['a', 'b', 'c']).$url()} /\u003e\n      \u003cimg src={staticPath.bb.cc_png} /\u003e\n    \u003c/\u003e\n  );\n};\n```\n\n## License\n\npathpida is licensed under a [MIT License](https://github.com/aspida/pathpida/blob/main/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspida%2Fpathpida","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faspida%2Fpathpida","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faspida%2Fpathpida/lists"}