{"id":21571559,"url":"https://github.com/zheeeng/insert-style-link","last_synced_at":"2026-01-26T19:23:17.910Z","repository":{"id":57274454,"uuid":"407388018","full_name":"zheeeng/insert-style-link","owner":"zheeeng","description":"Insert, switch or shift a stylesheet \u003clink /\u003e","archived":false,"fork":false,"pushed_at":"2022-07-15T00:08:31.000Z","size":7,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-08-11T08:49:28.098Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/insert-style-link","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/zheeeng.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}},"created_at":"2021-09-17T03:09:36.000Z","updated_at":"2023-05-04T07:04:03.000Z","dependencies_parsed_at":"2022-08-26T13:40:57.210Z","dependency_job_id":null,"html_url":"https://github.com/zheeeng/insert-style-link","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Finsert-style-link","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Finsert-style-link/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Finsert-style-link/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zheeeng%2Finsert-style-link/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zheeeng","download_url":"https://codeload.github.com/zheeeng/insert-style-link/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226154296,"owners_count":17581944,"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":[],"created_at":"2024-11-24T11:16:41.381Z","updated_at":"2026-01-26T19:23:17.870Z","avatar_url":"https://github.com/zheeeng.png","language":"TypeScript","readme":"# insert-style-link\n\n[![NPM](https://nodei.co/npm/insert-style-link.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://nodei.co/npm/insert-style-link/)\n\n![publish workflow](https://github.com/zheeeng/insert-style-link/actions/workflows/publish.yml/badge.svg)\n[![npm version](https://img.shields.io/npm/v/insert-style-link.svg)](https://www.npmjs.com/package/insert-style-link)\n\nInsert, switch or shift a stylesheet `\u003clink /\u003e`\n\n## Install\n\n```bash\nyarn add inject-style-link (or by npm/pnpm)\n```\n\n## Usage\n\n```ts\nimport { insertStyleLink, switchStyleLink } from 'inject-style-link'\n\nconst inserter = insertStyleLink('https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css')\n\n// execute insert\ninserter.use()\n\n// execute shift, safe for multiple times execution\ninserter.unuse()\n\n// switcher holds the singleton for style `\u003clink /\u003e` \nconst switcher = switchStyleLink()\n\n// the first time call `use(url)` execute inserting\nswitcher.use('https://cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/css/bootstrap.min.css')\n\n// switch to other link\nswitcher.use('https://cdn.jsdelivr.net/npm/normalize-css@2.3.1/normalize.min.css')\n\n// execute shift, safe for multiple times execution\nswitcher.unuse()\n```\n\n## Signature\n\n```ts\nexport type InsertStyleLinkOption = {\n    isSameLink?: (link1: string, link2: string) =\u003e boolean,\n}\n\nexport type Inserter = {\n    use: () =\u003e void,\n    unuse: () =\u003e void,\n}\n\nexport type Switcher = {\n    use: (link: string) =\u003e void,\n    unuse: () =\u003e void,\n}\n\ndeclare const insertStyleLink: (url: string, option?: insertStyleLinkOption): Inserter\n\ndeclare const switchStyleLink: (option?: insertStyleLinkOption): Switcher\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzheeeng%2Finsert-style-link","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzheeeng%2Finsert-style-link","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzheeeng%2Finsert-style-link/lists"}