{"id":24983723,"url":"https://github.com/posthtml/posthtml-url-parameters","last_synced_at":"2025-04-11T20:52:45.558Z","repository":{"id":38843919,"uuid":"250585433","full_name":"posthtml/posthtml-url-parameters","owner":"posthtml","description":"Add parameters to URLs with PostHTML.","archived":false,"fork":false,"pushed_at":"2025-04-11T15:59:22.000Z","size":2199,"stargazers_count":3,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-11T20:52:32.275Z","etag":null,"topics":["posthtml","posthtml-plugin","query-string","url-parameters"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/posthtml.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":null,"patreon":"posthtml","open_collective":"posthtml","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"mailviews.com"}},"created_at":"2020-03-27T16:28:29.000Z","updated_at":"2025-04-05T10:28:54.000Z","dependencies_parsed_at":"2023-12-04T08:02:42.816Z","dependency_job_id":"f5a46c1f-b641-4763-8e14-be418545d76b","html_url":"https://github.com/posthtml/posthtml-url-parameters","commit_stats":{"total_commits":159,"total_committers":6,"mean_commits":26.5,"dds":0.5283018867924528,"last_synced_commit":"2c3d4d57ea2960ca15cd9d839a1196fd93e8a002"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-url-parameters","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-url-parameters/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-url-parameters/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posthtml%2Fposthtml-url-parameters/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posthtml","download_url":"https://codeload.github.com/posthtml/posthtml-url-parameters/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248480515,"owners_count":21110936,"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":["posthtml","posthtml-plugin","query-string","url-parameters"],"created_at":"2025-02-04T09:20:46.296Z","updated_at":"2025-04-11T20:52:45.535Z","avatar_url":"https://github.com/posthtml.png","language":"JavaScript","readme":"\u003cdiv align=\"center\"\u003e\r\n  \u003cimg width=\"150\" height=\"150\" title=\"PostHTML\" src=\"https://posthtml.github.io/posthtml/logo.svg\"\u003e\r\n  \u003ch1\u003eURL Parameters\u003c/h1\u003e\r\n  \u003cp\u003eAdd parameters to URLs\u003c/p\u003e\r\n\r\n  [![Version][npm-version-shield]][npm]\r\n  [![Build][github-ci-shield]][github-ci]\r\n  [![License][license-shield]][license]\r\n  [![Downloads][npm-stats-shield]][npm-stats]\r\n\u003c/div\u003e\r\n\r\n## About\r\n\r\nThis is a PostHTML plugin that allows you to add query string parameters to URLs.\r\n\r\n## Install\r\n\r\n```\r\nnpm i posthtml posthtml-url-parameters\r\n```\r\n\r\n## Usage\r\n\r\n```js\r\nimport posthtml from 'posthtml'\r\nimport urlParams from 'posthtml-url-parameters'\r\n\r\nposthtml([\r\n  urlParams({\r\n    parameters: { foo: 'bar', baz: 'qux' }\r\n  })\r\n])\r\n  .process('\u003ca href=\"https://example.com\"\u003eTest\u003c/div\u003e')\r\n  .then(result =\u003e console.log(result.html)))\r\n\r\n// \u003ca href=\"https://example.com?baz=qux\u0026foo=bar\"\u003eTest\u003c/div\u003e\r\n```\r\n\r\n## Configuration\r\n\r\n### `parameters`\r\n\r\nType: `Object`\\\r\nDefault: `undefined`\r\n\r\nObject containing parameter name (key) and its value.\r\n\r\nExample:\r\n\r\n```js\r\nimport posthtml from 'posthtml'\r\nimport urlParams from 'posthtml-url-parameters'\r\n\r\nposthtml([\r\n  urlParams({\r\n    parameters: {\r\n      utm_source: 'Campaign',\r\n      '1stDraft': true\r\n    }\r\n  })\r\n])\r\n  .process('\u003ca href=\"https://example.com\"\u003eTest\u003c/a\u003e')\r\n  .then(result =\u003e console.log(result.html))\r\n```\r\n\r\n### `tags`\r\n\r\nType: `Array`\\\r\nDefault: `['a']`\r\n\r\nArray of tag names to process. \r\n\r\nBy default, only URLs inside [known attributes](#attributes) of tags in this array will be processed.\r\n\r\nExample:\r\n\r\n```js\r\nimport posthtml from 'posthtml'\r\nimport urlParams from 'posthtml-url-parameters'\r\n\r\nposthtml([\r\n  urlParams({\r\n    tags: ['a', 'img']\r\n  })\r\n])\r\n  .process(`\r\n    \u003ca href=\"https://example.com\"\u003eTest\u003c/a\u003e\r\n    \u003cimg src=\"https://example.com/image.jpg\"\u003e\r\n  `)\r\n  .then(result =\u003e console.log(result.html))\r\n```\r\n\r\nYou may use some CSS selectors when specifying tags:\r\n\r\n```js\r\nposthtml([\r\n  urlParams({\r\n    tags: ['a.button', 'a[href*=\"example.com\"]' 'link'],\r\n  })\r\n])\r\n  .process(/*...*/)\r\n```\r\n\r\nAll [`posthtml-match-helper` selectors](https://github.com/posthtml/posthtml-match-helper) are supported.\r\n\r\n### attributes\r\n\r\nType: `Array`\\\r\nDefault: `['src', 'href', 'poster', 'srcset', 'background']`\r\n\r\nArray of attributes to process for the given tags.\r\n\r\nYou may override this with your own list of attributes - the plugin will only process URLs in _these_ attributes.\r\n\r\n```js\r\nposthtml([\r\n  urlParams({\r\n    parameters: {foo: 'bar'},\r\n    attributes: ['data-href']\r\n  })\r\n])\r\n  .process('\u003ca href=\"foo.html\" data-href=\"https://example.com\"\u003eTest\u003c/a\u003e')\r\n  .then(result =\u003e console.log(result.html)))\r\n\r\n// \u003ca href=\"foo.html\" data-href=\"https://example.com?foo=bar\"\u003eTest\u003c/a\u003e\r\n```\r\n\r\n### `strict`\r\n\r\nType: `Boolean`\\\r\nDefault: `false`\r\n\r\nBy default, the plugin will append query parameters only to valid URLs.\r\n\r\nYou may disable `strict` mode to append parameters to any string:\r\n\r\n```js\r\nimport posthtml from 'posthtml'\r\nimport urlParams from 'posthtml-url-parameters'\r\n\r\nposthtml([\r\n  urlParams({\r\n    parameters: { foo: 'bar' },\r\n    strict: false,\r\n  })\r\n])\r\n  .process('\u003ca href=\"https://example.com/campaigns/{{ id }}\"\u003eDetails\u003c/a\u003e')\r\n  .then(result =\u003e console.log(result.html)))\r\n\r\n// \u003ca href=\"https://example.com/campaigns/{{ id }}?foo=bar\"\u003eDetails\u003c/a\u003e\r\n```\r\n\r\n### `qs`\r\n\r\nType: `Object`\\\r\nDefault: `undefined`\r\n\r\nOptions to pass to `query-string` - see available options [here](https://github.com/sindresorhus/query-string#stringifyobject-options).\r\n\r\nFor example, you may disable encoding:\r\n\r\n```js\r\nimport posthtml from 'posthtml'\r\nimport urlParams from 'posthtml-url-parameters'\r\n\r\nposthtml([\r\n  urlParams({\r\n    parameters: { foo: '@Bar@' },\r\n    qs: {\r\n      encode: false\r\n    }\r\n  })\r\n])\r\n  .process('\u003ca href=\"https://example.com\"\u003eTest\u003c/a\u003e')\r\n  .then(result =\u003e console.log(result.html)))\r\n\r\n// \u003ca href=\"https://example.com?foo=@Bar@\"\u003eTest\u003c/a\u003e\r\n```\r\n\r\n[npm]: https://www.npmjs.com/package/posthtml-url-parameters\r\n[npm-version-shield]: https://img.shields.io/npm/v/posthtml-url-parameters.svg\r\n[npm-stats]: http://npm-stat.com/charts.html?package=posthtml-url-parameters\r\n[npm-stats-shield]: https://img.shields.io/npm/dt/posthtml-url-parameters.svg\r\n[github-ci]: https://github.com/posthtml/posthtml-url-parameters/actions\r\n[github-ci-shield]: https://github.com/posthtml/posthtml-url-parameters/actions/workflows/nodejs.yml/badge.svg\r\n[license]: ./LICENSE\r\n[license-shield]: https://img.shields.io/npm/l/posthtml-url-parameters.svg\r\n","funding_links":["https://patreon.com/posthtml","https://opencollective.com/posthtml","mailviews.com"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-url-parameters","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposthtml%2Fposthtml-url-parameters","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposthtml%2Fposthtml-url-parameters/lists"}