Using date in linksets throwing an exception
frkd-dev opened this issue · comments
Hi there,
I'm stuck with the simple usage of permalinks:
.use(
permalinks({
relative: false,
linksets: [
{
match: {collection: 'posts'},
pattern: 'post/:date/:title',
date: 'YYYY'
}
]
}
))
Which is almost the same as in the README example, but it throws out an error:
/Users/me/blog-metalsmith/node_modules/@metalsmith/permalinks/lib/index.js:236
ret[key] = options.date(val)
^
TypeError: options.date is not a function
at replace (/Users/me/blog-metalsmith/node_modules/@metalsmith/permalinks/lib/index.js:236:26)
at /Users/me/blog-metalsmith/node_modules/@metalsmith/permalinks/lib/index.js:318:19
at Array.forEach (<anonymous>)
at Ware.permalinks (/Users/me/blog-metalsmith/node_modules/@metalsmith/permalinks/lib/index.js:308:24)
at Ware.<anonymous> (/Users/me/blog-metalsmith/node_modules/wrap-fn/index.js:45:19)
at Immediate.next (/Users/me/blog-metalsmith/node_modules/ware/lib/index.js:85:20)
at Immediate.<anonymous> (/Users/me/blog-metalsmith/node_modules/wrap-fn/index.js:121:18)
at processImmediate (node:internal/timers:466:21)
at process.callbackTrampoline (node:internal/async_hooks:130:17)
The @metalsmith/permalinks/lib/index.js:236
points at this line:
Line 246 in 74c1820
I'm pretty sure I'm doing something wrong but I don't understand what, as I copy-pasted the example from the README.
I'm using:
Permalinks: 2.4.1
Node: 16.17.1
No, you're correct. It looks like permalinks > 2.4.0 introduced a bug with the :date
pattern. permalinks 2.3.0 works and I apparently fixed it in the current main branch of the repo too (I added a fix that aligns linkset & default options normalization). So you can revert to 2.3.0 for now, and the fix will be published as part of 2.5.0 before end of 2022.
Thanks for reporting!
So the fix is on the way, that's good news. Thank you!
Merry Christmas and Happy New Year! 🎄