【问题标题】:wintersmith: visualise the content treeWintersmith:可视化内容树
【发布时间】:2014-02-08 01:06:47
【问题描述】:

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 做到这一点。

【问题讨论】:

    标签: wintersmith


    【解决方案1】:

    如果不进行构建,则无法从 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))
    })
    

    【讨论】:

      【解决方案2】:

      每次您使用wintersmith build 构建 Wintersmith 时都会打印 ContentTree,因此您的假设是正确的。寻找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 打印的可视化效果。

      希望对你有帮助!

      【讨论】:

      • 我希望有一些方法不会对磁盘​​进行更改以提供此输出。
      • 我查看了源代码,但没有找到在不编写文件的情况下构建和打印内容树的方法。如果要保持构建目录完整,我建议指定不同的输出目录。例如:wintersmith build -o ./temp。文件将写入那里,但您可以删除或忽略该目录。
      猜你喜欢
      • 2019-12-18
      • 2017-03-15
      • 1970-01-01
      • 2013-12-22
      • 1970-01-01
      • 1970-01-01
      • 2012-07-03
      • 2023-03-15
      相关资源
      最近更新 更多