posthtml / posthtml-url-parameters

Add parameters to URLs with PostHTML.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support other tags/attributes

cossssmin opened this issue · comments

Would be useful to be able to add parameters to URLs in img tags, for example. Right now the plugin only looks for the href attribute, which means using it on img or other tags that use src/srcset/source is impossible.

posthtml([
    urlParams({
      parameters: { utm_source: 'maizzle', utm_campaign: 'Campaign Name', utm_medium: 'email', }
    })
  ])
  .process('<img src="https://example.com/image.png">')
  .then(result => console.log(result.html)))

Result:

<img src="https://example.com/image.png?utm_campaign=Campaign%20Name&utm_medium=email&utm_source=maizzle">