Skip to content

Commit

Permalink
doc(sitemap): improve filtering doc
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw committed Sep 5, 2024
1 parent 26adec7 commit 19c27d3
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions docs/content/2.sitemap/2.guides/0.filtering-urls.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,25 @@ export default defineNuxtConfig({
})
```

These can be regex or a string path.
Either option supports either an array of strings, RegExp objects or a `{ regex: string }` object.

It's important to know that when providing a string, you can't use variable path segments in front of static ones.
Providing strings will use the [route rules path matching](https://nuxt.com/docs/guide/concepts/rendering#hybrid-rendering) which
does not support variable path segments in front of static ones.

For example, `/foo/**` will work but `/foo/**/bar` will not. To get around this you should use regex.

### Regex Filtering

Filtering using regex is more powerful and can be used to match more complex patterns. It's recommended to pass a
`RegExp` object explicitly.

```ts [nuxt.config.ts]
export default defineNuxtConfig({
sitemap: {
exclude: ['/**/secret-pages'], // this won't work
exclude: [
// exclude /foo/**/bar using regex
new RegExp('/foo/.*/bar')
],
}
})
```

0 comments on commit 19c27d3

Please sign in to comment.