markdown-magic-directory-tree icon indicating copy to clipboard operation
markdown-magic-directory-tree copied to clipboard

Error when using options

Open JulianCataldo opened this issue 2 years ago • 1 comments

When using options:

    DIRTREE: tree({}),
 const dir = path.resolve(path.dirname(config.originalPath), options.dir);
                                               ^


TypeError: Cannot read properties of undefined (reading 'originalPath')

JulianCataldo avatar Oct 16 '22 20:10 JulianCataldo

OK I understood, it seems you have to pass the args down to the plugin:


import path from 'path';
import markdownMagic from 'markdown-magic';
import tree from 'markdown-magic-directory-tree';
import vBadge from 'markdown-magic-version-badge';

const config = {
  transforms: {
    DIRTREE: (content, options, config) =>
      tree(
        content,
        { ...options, ignore: [...options.ignore, '.DS_Store'], depth: 1 },
        config,
      ),
    VERSIONBADGE: (content, options, config) =>
      vBadge(content, options, config),
  },
};

const markdownPath = path.join(__dirname, 'README.md');
markdownMagic(markdownPath, config);



JulianCataldo avatar Oct 16 '22 20:10 JulianCataldo