{"id":18051926,"url":"https://github.com/shhdharmen/github-link","last_synced_at":"2025-10-25T11:32:04.771Z","repository":{"id":85133005,"uuid":"344103510","full_name":"shhdharmen/github-link","owner":"shhdharmen","description":"⚓ Get links to code in your GitHub files based on text, and forget the line numbers!","archived":false,"fork":false,"pushed_at":"2025-01-24T05:44:31.000Z","size":476,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-24T06:26:18.426Z","etag":null,"topics":["code-link","github","link","link-to-code","links","readme","snippet-link"],"latest_commit_sha":null,"homepage":"https://github-link.vercel.app/","language":"HTML","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/shhdharmen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2021-03-03T11:28:49.000Z","updated_at":"2025-01-24T05:44:34.000Z","dependencies_parsed_at":"2023-03-06T14:45:41.986Z","dependency_job_id":null,"html_url":"https://github.com/shhdharmen/github-link","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shhdharmen%2Fgithub-link","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shhdharmen%2Fgithub-link/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shhdharmen%2Fgithub-link/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shhdharmen%2Fgithub-link/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shhdharmen","download_url":"https://codeload.github.com/shhdharmen/github-link/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238132890,"owners_count":19421904,"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":["code-link","github","link","link-to-code","links","readme","snippet-link"],"created_at":"2024-10-30T22:57:48.114Z","updated_at":"2025-10-25T11:32:04.299Z","avatar_url":"https://github.com/shhdharmen.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n \u003cimg width=\"100px\" src=\"./github-link.svg\" align=\"center\" alt=\"GitHub Link\" /\u003e\n \u003ch2 align=\"center\"\u003eGitHub Link\u003c/h2\u003e\n \u003cp align=\"center\"\u003eGet links for your GitHub files based on text, and forget the line numbers!\u003c/p\u003e\n\u003c/p\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --\u003e\n[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)\n\u003c!-- ALL-CONTRIBUTORS-BADGE:END --\u003e\n\n## Why GitHub Link?\n\n### In Short\n\nWe usually create link-to-code to point our readers, users or developers to the exact code. But such links are created based on line-number and if you're updating the file regularly, those links will not point to correct line or you will need to keep updating your links. GitHub Link helps you to get the right link-to-code, based on text you give, so that it always points to contextually right definition. Jump to [usage](#usage)\n\n### In Long\n\nWe generally create [permanent link](https://docs.github.com/en/github/managing-your-work-on-github/creating-a-permanent-link-to-a-code-snippet) to code snippet. As they are for specific commit, they work great when referred in issues/PRs.\n\nBut what if you want to give such links in your README or such files? Like you have already defined a coded file with proper comments and you want to give link to same in README, so that you can keep your README short and concise, and have links to all the extra definitions in it. Because you will always want up-to-date reference in README, permanent links will not work, as it shows file from specific commit.\n\nYou may use \"Copy Link\" feature, that links to the latest version of file, but then it may point to wrong definition, because you might have added/removed more lines of code in the file.\n\nThis is where GitHub Link comes into the picture. It gives you the link to code line, based on the text, so that it always points to contextually right definition.\n\n#### Example\n\n1. You have all of your types defined in `hot-toast.model.ts`\n2. It looks something like below:\n\n```typescript\nexport type ToastType = 'success' | 'error' | 'loading' | 'blank' | 'warning';\n```\n\n3. You are create a `READEME.md` and add a link by creating [permanent link](https://docs.github.com/en/github/managing-your-work-on-github/creating-a-permanent-link-to-a-code-snippet)\n4. It works, great!\n5. Now, you added a feature and you introduced a new type in `hot-toast.model.ts`\n\n```diff\n+ export type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';\nexport type ToastType = 'success' | 'error' | 'loading' | 'blank' | 'warning';\n```\n\n6. As the line for previous type is changed, the link on your `README` will point to `export type ToastPosition...`, instead of `export type ToastType...`.\n7. So, to resolve this problem, you can create github-link\n8. Let's take this URL for example: `https://github.com/ngneat/hot-toast/blob/master/projects/ngneat/hot-toast/src/lib/hot-toast.model.ts`\n9. Now the text to which we want to generate link is: `export type ToastType`\n10. Considering points 8 \u0026 9, below will be your link:\n\n```\nhttps://github-link.vercel.app/api?ghUrl=https://github.com/ngneat/hot-toast/blob/master/projects/ngneat/hot-toast/src/lib/hot-toast.model.ts\u0026q=export type ToastType\n```\n\n11. Above link will find first occurance of `export type ToastType` in given URL, get it's line and will redirect there!\n\n## Usage\n\n1. Open the file in browser and copy it's URL, let's call it: `URL_TO_FILE`\n2. Find the text to which you want to generate the link, let's call it: `SEARCH`\n3. Use both of above and create the link using GitHub Link API:\n\n```\nhttps://github-link.vercel.app/api?ghUrl=\u003cURL_TO_FILE\u003e\u0026q=\u003cSEARCH\u003e\n```\n\nYou can use it markdown:\n\n```markdown\n[link to code line](https://github-link.vercel.app/api?ghUrl=\u003cURL_TO_FILE\u003e\u0026q=\u003cSEARCH\u003e)\n```\n\nor HTML:\n\n```\n\u003ca href=\"https://github-link.vercel.app/api?ghUrl=\u003cURL_TO_FILE\u003e\u0026q=\u003cSEARCH\u003e\"\u003elink to code line\u003c/a\u003e\n```\n\nBy default, API will return a `redirect` response and user will be redirected to matched line on GitHub.\n\nIf you don't want redirection, just add `noRedirect`:\n\n```\nhttps://github-link.vercel.app/api?ghUrl=\u003cURL_TO_FILE\u003e\u0026q=\u003cSEARCH\u003e\u0026noRedirect\n```\n\n### Supported Query Params\n\n| Query Param | Type                      | Description                                                                   | Required |\n| ----------- | ------------------------- | ----------------------------------------------------------------------------- | -------- |\n| ghUrl       | `string`                  | URL of file hosted on github.com\u003cbr\u003e*Validations: `URL` \u0026\u0026 `Host=github.com`* | Yes      |\n| q           | `string`                  | Query text, to which link will be generated\u003cbr\u003e*Validations: `MinLength=3`*   | Yes      |\n| noRedirect  | `'true' \\| 'false' \\| ''` | If set, will not redirect to code link                                        | No       |\n\n## Deploy Your Own Instance\n\n[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/git/external?repository-url=https%3A%2F%2Fgithub.com%2Fshhdharmen%2Fgithub-link)\n\n## Helper\n\nI have also created a helper at: \u003chttps://github-link.vercel.app/#create\u003e\n\n[![https://github-link.vercel.app/#create](https://user-images.githubusercontent.com/6831283/110798424-2b6eec00-82a0-11eb-8b9e-ba552aceb6f6.png)](https://github-link.vercel.app/#create)\n\n## Contributors ✨\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section --\u003e\n\u003c!-- prettier-ignore-start --\u003e\n\u003c!-- markdownlint-disable --\u003e\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003ctd align=\"center\"\u003e\u003ca href=\"https://github.com/shhdharmen\"\u003e\u003cimg src=\"https://avatars.githubusercontent.com/u/6831283?v=4?s=100\" width=\"100px;\" alt=\"\"/\u003e\u003cbr /\u003e\u003csub\u003e\u003cb\u003eDharmen Shah\u003c/b\u003e\u003c/sub\u003e\u003c/a\u003e\u003cbr /\u003e\u003ca href=\"https://github.com/shhdharmen/github-link/commits?author=shhdharmen\" title=\"Code\"\u003e💻\u003c/a\u003e \u003ca href=\"#content-shhdharmen\" title=\"Content\"\u003e🖋\u003c/a\u003e \u003ca href=\"https://github.com/shhdharmen/github-link/commits?author=shhdharmen\" title=\"Documentation\"\u003e📖\u003c/a\u003e \u003ca href=\"#example-shhdharmen\" title=\"Examples\"\u003e💡\u003c/a\u003e \u003ca href=\"#ideas-shhdharmen\" title=\"Ideas, Planning, \u0026 Feedback\"\u003e🤔\u003c/a\u003e \u003ca href=\"#infra-shhdharmen\" title=\"Infrastructure (Hosting, Build-Tools, etc)\"\u003e🚇\u003c/a\u003e \u003ca href=\"#maintenance-shhdharmen\" title=\"Maintenance\"\u003e🚧\u003c/a\u003e \u003ca href=\"#research-shhdharmen\" title=\"Research\"\u003e🔬\u003c/a\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\u003c!-- markdownlint-restore --\u003e\n\u003c!-- prettier-ignore-end --\u003e\n\n\u003c!-- ALL-CONTRIBUTORS-LIST:END --\u003e\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n\n## Credits 🙌\n\n- This is built on top of [nestjs](https://nestjs.com/) and deployed freely using [vercel](https://vercel.com/), thanks to their teams!\n- Logo is inspired from [file-symlink-file](https://octicons-primer.vercel.app/octicons/file-symlink-file-24) of [Octicons](https://primer.style/octicons/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshhdharmen%2Fgithub-link","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshhdharmen%2Fgithub-link","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshhdharmen%2Fgithub-link/lists"}