Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
webketje committed Jan 19, 2024
1 parent 4b60c50 commit 0cbaaf1
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 21 deletions.
6 changes: 6 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ export type Linkset = {
pattern?: string;
/**
* [Slugify options](https://github.com/simov/slugify) or a custom slug function of the form `(pathpart) => string`
* @default
* {
* lower: true,
* remove: /[^\\w\\s$_+~.()!\\-@/]|[<>:"|?*]/g,
* extend: {':': '-', '|': '-', '<': '', '>': ''}
* }
*/
slug?: SlugifyOptions | slugFunction;
/**
Expand Down
36 changes: 18 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const dupeHandlers = {
// These are the invalid path chars on Windows, on *nix systems all are valid except forward slash.
// However, it is highly unlikely that anyone would want these to appear in a file path and they can still be overridden if necessary
const invalidPathChars = '[<>:"|?*]'
const defaultSlugifyRemoveChars = '[^\\w\\s$_+~.()!\\-@\\/]+'
const defaultSlugifyRemoveChars = `[^\\w\\s$_+~.()!\\-@/]+`
const emptyStr = ''
const dash = '-'

Expand All @@ -94,7 +94,6 @@ const defaultLinkset = {
// by default slugify strips these, resulting in word concatenation. Map these chars to dash to force a word break
':': dash,
'|': dash,
'/': dash,
// by default slugify translates these to "smaller" & "greater", unwanted when a <html> tag is in the permalink
'<': emptyStr,
'>': emptyStr
Expand Down Expand Up @@ -203,7 +202,6 @@ const replace = ({ pattern, ...options }, data) => {
ret[key] = options.slug(val.toString())
}
}

let transformed = route.inject(remapped, ret)
if (path.basename(transformed) === path.basename(options.directoryIndex, path.extname(options.directoryIndex)))
transformed = path.dirname(transformed)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nested
1 change: 1 addition & 0 deletions test/fixtures/no-pattern/src/two/levels/deep.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nested

0 comments on commit 0cbaaf1

Please sign in to comment.