awoojs / core

:cd: officially supported plugins for awoo
4 stars 2 forks source link

Filter does not seem to work #8

Closed freder closed 6 years ago

freder commented 6 years ago

with

const mdFilesFilter = (file, options, files) => {
    return file.path.endsWith('.md');
};

// [...]

site.use(matter, { filter: mdFilesFilter });

.DS_Store still makes it through, even though the filter function return false.

zipang commented 6 years ago

Hi @freder As stated in the plugin's README : the filter param can be used to select files on which the transformation is applied, leaving the others unchanged (so they are still inside the files array). So i guess that if you want to get rid of every non-markdown files before passing them to matter, you should first apply an Array filter like so :

function excludeJunkFiles() {
  return files => files.filter(file => file.extname === '.md');
}
site.use(excludeJunkFiles);
// now files should only contains markdown files
site.use(matter);
freder commented 6 years ago

ah, I see. + yes, that's what I ended up doing. — thx!