查看 metalsmith 管道 JSON

Viewing the metalsmith pipeline JSON

Metalsmith 有一种显示管道内容的内置方式,即通过使用像这样的简单函数:

    function(files, ms, done) {
        console.log('Files: ');
        console.log(files);
        console.log();
        console.log('Metalsmith ');
        console.log(ms);
        done();
    }

metalsmith-logger

logger(['title', 'tags', 'contents')

然而,在这两种情况下,我得到的输出都是 [object Object],我需要完整的输出。 (即 JSON.stringify 我可能得到的结果)

更重要的是,我想知道是否有任何方法可以在每次转换后获得管道和内容的格式良好的输出,就像使用 gatsbyjs 和 graphQL 一样。

metalsmith-debug-ui会有帮助吗?格式精美的 React 工具…

您可以使用 JSON.stringify() 包裹 filesms 打印出对象内容,像这样 JSON.stringify(files,null,3) 其中 3 是深度数对象