{"id":14970795,"url":"https://github.com/ovyerus/astro-worker-links","last_synced_at":"2025-06-17T04:39:27.646Z","repository":{"id":65447813,"uuid":"591953413","full_name":"Ovyerus/astro-worker-links","owner":"Ovyerus","description":"Automatically create shortened urls for your Astro project via worker-links!","archived":false,"fork":false,"pushed_at":"2024-01-13T07:34:24.000Z","size":2872,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-23T11:32:08.373Z","etag":null,"topics":["astro","cloudflare","cloudflare-workers","link-shortener","worker-links"],"latest_commit_sha":null,"homepage":"","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/Ovyerus.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}},"created_at":"2023-01-22T13:20:44.000Z","updated_at":"2024-03-03T18:51:58.000Z","dependencies_parsed_at":"2024-01-13T10:40:30.212Z","dependency_job_id":null,"html_url":"https://github.com/Ovyerus/astro-worker-links","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Ovyerus/astro-worker-links","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ovyerus%2Fastro-worker-links","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ovyerus%2Fastro-worker-links/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ovyerus%2Fastro-worker-links/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ovyerus%2Fastro-worker-links/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ovyerus","download_url":"https://codeload.github.com/Ovyerus/astro-worker-links/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ovyerus%2Fastro-worker-links/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260294188,"owners_count":22987600,"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":["astro","cloudflare","cloudflare-workers","link-shortener","worker-links"],"created_at":"2024-09-24T13:44:09.745Z","updated_at":"2025-06-17T04:39:27.608Z","avatar_url":"https://github.com/Ovyerus.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# astro-worker-links\n\nAutomatically create [worker-links](https://github.com/erisa/worker-links)\nredirects for your [Astro](https://astro.build/) pages at build time!\n\nBetter docs will come soon, it's late rn and I'm just getting this out the door.\n\n## Example usage\n\n```js\n// astro.config.mjs\nimport { defineConfig } from \"astro/config\";\nimport workerLinks from \"astro-worker-links\";\n\n// https://astro.build/config\nexport default defineConfig({\n  integrations: [\n    // ...\n    workerLinks({\n      domain: \"https://my-worker-links.example.com\",\n      secret: process.env.WORKER_LINKS_SECRET,\n      // Pages is an array of all the built pages from your project as URLs\n      getPageMapping(pages) {\n        // Filter to only generate links for pages matching `/blog/[id]` anywhere in them (but not the index page)\n        return pages\n          .filter(\n            (url) =\u003e url.pathname !== \"/blog/\" \u0026\u0026 url.pathname.includes(\"/blog\")\n          )\n          .map((url) =\u003e {\n            return {\n              page: url.href,\n              // Strip the `/blog` intermediate part so that short links are just `example.com/blog-post-name` instead of `example.com/blog/blog-post-name`\n              shortlink: url.pathname.replace(\"/blog\", \"\"),\n            };\n          });\n      },\n    }),\n  ],\n  // ...\n});\n```\n\nyou can also provide an async function for `getPageMapping` if you need to fetch\nexternal data\n\n```js\nexport default defineConfig({\n  integrations: [\n    // ...\n    workerLinks({\n      // ...\n      async getPageMapping(pages) {\n        const results = await Promise.all(\n          pages.map(async (url) =\u003e {\n            const resource = await fetch(...);\n            return {\n              page: url.href,\n              shortlink: resource.id, // or whatever\n            };\n          })\n        );\n\n        return results;\n      },\n    }),\n  ],\n});\n```\n\nOr you can just return a static object from the function\n\n```js\nexport default defineConfig({\n  integrations: [\n    // ...\n    workerLinks({\n      // ...\n      getPageMapping() {\n        return [\n          {\n            page: \"https://really-long-site.example.com/blog/my-awesome-post-please-read-it\",\n            shortlink: \"/my-awesome-post\",\n          },\n          {\n            page: \"https://really-long-site.example.com/about-us\",\n            shortlink: \"/about\",\n          },\n        ];\n      },\n    }),\n  ],\n});\n```\n\n## License\n\nThe source code in this repository is licensed under the\n[MIT License](./LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovyerus%2Fastro-worker-links","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovyerus%2Fastro-worker-links","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovyerus%2Fastro-worker-links/lists"}