webketje / metalsmith-taxonomy Goto Github PK
View Code? Open in Web Editor NEWA Metalsmith plugin to organize files into taxonomy trees and auto-generate index pages for them
License: GNU Lesser General Public License v3.0
A Metalsmith plugin to organize files into taxonomy trees and auto-generate index pages for them
License: GNU Lesser General Public License v3.0
Note: this is a minor issue (but I thought I'd file so others can search for and find the error message).
Repository to reproduce the error on Windows is here:
https://github.com/jaredkrinke/metalsmith-taxonomy-test
When building with Metalsmith on Windows, the native path separator is used to identify files in the files
collection, e.g. "posts\test.md" (instead of "posts/test.md", as you'd see for POSIX). This probably breaks metalsmith-taxonomy when building on both platforms with identical code. The error is below, but it's basically saying "the matched file path isn't a key on files
" (which is true because the path separators don't exactly match):
TypeError: Cannot read property 'category' of undefined
at C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\metalsmith-taxonomy\lib\taxonomy-set.js:77:18
at C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\metalsmith-taxonomy\lib\index.js:88:24
at Array.forEach (<anonymous>)
at C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\metalsmith-taxonomy\lib\index.js:85:27
at Array.forEach (<anonymous>)
at C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\metalsmith-taxonomy\lib\index.js:80:36
at Array.forEach (<anonymous>)
at Ware.plugin (C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\metalsmith-taxonomy\lib\index.js:67:18)
at Ware.<anonymous> (C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\wrap-fn\index.js:45:19)
at Immediate.next (C:\Users\jared\Code\metalsmith-taxonomy-test\node_modules\ware\lib\index.js:85:20)
In this case (repository linked above), I'm using the default options (so "/*.{md,html}") and I get the error above when building on Windows. If I change the pattern to "\*.{md,html}", then it builds fine on Windows. I suspect (but have not confirmed) that would then break on Linux.
Ideally, the same pattern (especially the default pattern) should work on any platform.
Fortunately, this issue is easily worked around by just adding another plugin to normalize slashes to "/".
For what it's worth, I'd argue that the multimatch behavior here is the correct behavior. It's debatable if a fix would be more appropriate in this plugin or Metalsmith itself, but I'd lean toward this plugin, since I haven't encountered this sort of problem with other plugins I've used (e.g. the "root path" plugin handles Windows fine).
And one last note: thanks for sharing this plugin! I had a custom plugin to do something similar, but this is a much more general design (and it includes some features I hadn't thought of). Nice work!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.