'How to split slugs in Svelte router in all possible options?
I want to build URL patter, like this [lang]/category/[name]-[suffix], where:
suffixis one of a few strings, for example:['super-product', 'great-gadget', 'ta-ta-ta']nameis a multiple word slug, likea-bb-ccc
To implement it, I decided to use Matching:
export function match(param) {
let result = /^(super-product|great-gadget|ta-ta-ta)/.test(param);
return a;
}
For the URL /en/category/a-bb-ccc-super-product/, param is bb-ccc-super-product.
Q: How to make Svelte splits URL into slugs in all possible options, like: a + bb-ccc-super-product, a-bb + ccc-super-product, ..., a-bb-ccc-super + product, and not just in one a + bb-ccc-super-product?
Also, I tried to use handlers to resolve this issue, failed as I was not able to change URL.
- "@sveltejs/kit": "1.0.0-next.310"
- "svelte": "3.47.0"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
