3

Wintersmith api 文档谈到:

getPluginColor() Return vanity color used to identify the plugin when printing the content tree choices are: bold, italic, underline, inverse, yellow, cyan, white, magenta, green, red, grey, blue, rainbow, zebra or none.

我该怎么做print[ing] the content tree?我想假设我可以通过 cli 做到这一点。

4

2 回答 2

2

每次使用 构建 Wintersmith 时都会打印 ContentTree wintersmith build,因此您的假设是正确的。寻找,rendering tree:然后是什么。下面的所有文件/content都将出现并显示源文件和生成的输出文件,包括它们在目录结构中的位置。

示例输出:

rendering tree:
    articles/
      another-test/
        index.md (url: /articles/another-test/)
      bamboo-cutter/
        index.md (url: /articles/bamboo-cutter/)
        taketori_monogatari.jpg (url: /articles/bamboo-cutter/taketori_monogatari.jpg)
      hello-world/
        index.md (url: /articles/hello-world/)
      markdown-syntax/
        index.md (url: /articles/markdown-syntax/)
      red-herring/
        banana.png (url: /articles/red-herring/banana.png)
        index.md (url: /articles/red-herring/)
      test.md (url: /articles/test.html)
    authors/
      baker.json (url: /authors/baker.html)
      the-wintersmith.json (url: /authors/the-wintersmith.html)
    css/
      main.css (url: /css/main.css)
    posts/
      test.md (url: /posts/test.html)
    .DS_Store (url: /.DS_Store)
    about.md (url: /about.html)
    archive.json (url: /archive.html)
    feed.json (url: /feed.xml)
    index.json (url: /)

如果您好奇,可以在这里找到执行此操作的代码:https ://github.com/jnordberg/wintersmith/blob/master/src/core/renderer.coffee#L36

关于getPluginColor(),这是在内容插件上公开的功能。您应该看到以青色打印的源文件,对应于以下代码行:https ://github.com/jnordberg/wintersmith/blob/master/src/core/content.coffee#L60

其他内容插件可以选择返回不同的颜色,这可以增强通过 CLI 打印的可视化效果。

我希望这会有所帮助!

于 2014-02-08T07:25:53.297 回答
2

如果不进行构建,则无法从 CLI 执行此操作。但是这个小脚本会做到这一点:

var wintersmith = require('wintersmith')
var env = wintersmith('/path/to/your/projects/config.json')
env.load(function(error, result) {
  console.log(wintersmith.ContentTree.inspect(result.contents))
})
于 2015-12-11T16:36:00.603 回答