-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dirs can be omitted from the url by using parenthesis. Example …
…(dashboard)/home -> /home
- Loading branch information
1 parent
da6bf45
commit 3050080
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/** @type {RoutifyBuildtimePlugin} */ | ||
export const omitDirFromPathPlugin = { | ||
name: 'omitDirFromPath', | ||
after: 'filemapper', | ||
before: 'bundler', | ||
build: ({ instance }) => { | ||
// find file names that are enclosed in a parenthesis | ||
const omittedDir = node => node.file.name.match(/\(([^)]+)\)/) | ||
|
||
// remove the node and move its children to the parent | ||
instance.nodeIndex.filter(omittedDir).forEach(node => { | ||
node.children.forEach(child => { | ||
child.parent = node.parent | ||
node.remove() | ||
}) | ||
}) | ||
}, | ||
} |