For dynamic routes, use the populate option in scanURLs to map route patterns to specific values. This allows the validator to know which dynamic paths actually exist.
- For single parameter routes, provide an array of objects with a
value property. - For routes with multiple parameters, provide an array of objects where
value is an object containing all parameter keys. - You can also specify allowed
hashes and queries for specific parameter values.
import { scanURLs } from 'next-validate-link';
const scanned = await scanURLs({
populate: {
// Single parameter route
'docs/[...slug]': [
{
value: ['hello', 'world'],
hashes: ['fragment'],
queries: [{ search: 'fumadocs' }],
},
],
// Multiple parameter route
'[lang]/blog/[slug]': [
{
value: { lang: 'en', slug: 'blog-1' },
},
{
value: { lang: 'cn', slug: 'blog-1' },
},
],
},
});