Skip to content

Commit

Permalink
Fixes #139: don't slugify dirname, add nested file test, document def…
Browse files Browse the repository at this point in the history
…ault slug options in types
  • Loading branch information
webketje committed Jan 19, 2024
1 parent 4b60c50 commit e0c7f28
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 18 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.

2 changes: 2 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ const replace = ({ pattern, ...options }, data) => {
}
if (val instanceof Date) {
ret[key] = options.date(val)
} else if (key === 'dirname') {
ret[key] = val
} else {
ret[key] = options.slug(val.toString())
}
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 e0c7f28

Please sign in to comment.