Skip to content

Commit c92b2a2

Browse files
committed
chore: update readme.md
1 parent 8001b6b commit c92b2a2

File tree

1 file changed

+39
-2
lines changed

1 file changed

+39
-2
lines changed

readme.md

+39-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ require('posthtml-url-parameters')({
5959

6060
Default: `[a]`
6161

62-
Array of tag names to process. Only URLs inside `href=""` attributes of tags in this array will be processed.
62+
Array of tag names to process.
63+
64+
By default, only URLs inside `href=""` attributes of tags in this array will be processed.
6365

6466
Example:
6567

@@ -70,13 +72,48 @@ require('posthtml-url-parameters')({
7072
})
7173
```
7274

75+
You may use some CSS selectors when specifying tags:
76+
77+
```js
78+
require('posthtml-url-parameters')({
79+
tags: ['a.button', 'a[href*="example.com"]' 'link'],
80+
// ...
81+
})
82+
```
83+
84+
All [`posthtml-match-helper` selectors](https://github.com/posthtml/posthtml-match-helper) are supported.
85+
86+
### `strict`
87+
88+
Default: `false`
89+
90+
By default, the plugin will append query parameters only to valid URLs.
91+
92+
You may disable `strict` mode to append parameters to any string:
93+
94+
```js
95+
const posthtml = require('posthtml')
96+
const urlParams = require('posthtml-url-parameters')
97+
98+
posthtml([
99+
urlParams({
100+
parameters: { foo: 'bar' },
101+
strict: false,
102+
})
103+
])
104+
.process('<a href="https://example.com/campaigns/{{ id }}">Details</div>')
105+
.then(result => console.log(result.html)))
106+
107+
// <a href="https://example.com/campaigns/{{ id }}?foo=bar">Details</div>
108+
```
109+
73110
### `qs`
74111

75112
Default: `undefined`
76113

77114
Options to pass to `query-string` - see available options [here](https://github.com/sindresorhus/query-string#stringifyobject-options).
78115

79-
For example, you can disable encoding:
116+
For example, you may disable encoding:
80117

81118
```js
82119
const posthtml = require('posthtml')

0 commit comments

Comments
 (0)