mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-23 15:41:32 +00:00
rename create_matchers -> create_routes
This commit is contained in:
@@ -8,6 +8,8 @@ module.exports = function create_matchers(files) {
|
|||||||
const parts = file.replace(/\.(html|js|mjs)$/, '').split(path.sep);
|
const parts = file.replace(/\.(html|js|mjs)$/, '').split(path.sep);
|
||||||
if (parts[parts.length - 1] === 'index') parts.pop();
|
if (parts[parts.length - 1] === 'index') parts.pop();
|
||||||
|
|
||||||
|
const id = parts.join('_').replace(/[[\]]/g, '$');
|
||||||
|
|
||||||
const dynamic = parts
|
const dynamic = parts
|
||||||
.filter(part => part[0] === '[')
|
.filter(part => part[0] === '[')
|
||||||
.map(part => part.slice(1, -1));
|
.map(part => part.slice(1, -1));
|
||||||
@@ -31,6 +33,8 @@ module.exports = function create_matchers(files) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
id,
|
||||||
|
type: path.extname(file) === '.html' ? 'page' : 'route',
|
||||||
file,
|
file,
|
||||||
pattern,
|
pattern,
|
||||||
test,
|
test,
|
||||||
Reference in New Issue
Block a user