Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion content/terms/how-to/apply-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ For filters that don’t require parameters, add the filter name as a string:
}
```

Built-in filters declared this way use their default parameters. For example, `removeQueryParams` alone removes the well-known tracking parameters described in its [reference]({{< relref "terms/reference/built-in-filters/#ref-removequeryparams" >}}).

### Filter with parameters

For filters that take parameters, use an object format, for example with the built-in filter `removeQueryParams` to remove query parameters from URLs:
For filters that take parameters, use an object format, for example with the built-in filter `removeQueryParams` to choose which query parameters to remove from URLs:

```json
{
Expand Down
51 changes: 50 additions & 1 deletion content/terms/reference/built-in-filters.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,24 @@ This reference details all available built-in [filters]({{< relref "terms/explan

{{< refItem
name="removeQueryParams"
description="Removes specified query parameters from URLs in links and images."
description="Removes query parameters from URLs in links and images. Without parameters, removes well-known tracking parameters such as `utm_source` or `fbclid`, listed in the [engine source code](https://github.com/OpenTermsArchive/engine/blob/main/src/archivist/extract/exposedFilters.js). Declaring parameters replaces this default list."
>}}

With the default parameters:

```json
"filter": [
"removeQueryParams"
]
```

```diff
- <p>Read the <a href="https://example.com/example-page?utm_source=OGB&fbclid=IwAR2xK9&lang=en">list of our affiliates</a>.</p>
+ <p>Read the <a href="https://example.com/example-page?lang=en">list of our affiliates</a>.</p>
```

With explicit parameters:

```json
"filter": [
{
Expand All @@ -24,4 +39,38 @@ This reference details all available built-in [filters]({{< relref "terms/explan
+ <p>Read the <a href="https://example.com/example-page?lang=en">list of our affiliates</a>.</p>
```

To keep the default parameters and remove additional ones, declare the filter twice, as filters are applied in order:

```json
"filter": [
"removeQueryParams",
{
"removeQueryParams": ["ref"]
}
]
```

```diff
- <p>Read the <a href="https://example.com/example-page?utm_source=OGB&ref=footer&lang=en">list of our affiliates</a>.</p>
+ <p>Read the <a href="https://example.com/example-page?lang=en">list of our affiliates</a>.</p>
```

{{< /refItem >}}

{{< refItem
name="convertSpacesToStandard"
description="Replaces Unicode space separators, such as non-breaking spaces or narrow no-break spaces, with a regular space in text content."
>}}

```json
"filter": [
"convertSpacesToStandard"
]
```

```diff
- <p>Read the list of our&nbsp;affiliates.</p>
+ <p>Read the list of our affiliates.</p>
```

{{< /refItem >}}
Loading