blogs - 如何让 Wintersmith 中的文章不在其自己的子目录中?

标签 blogs wintersmith

在 Wintersmith 中,默认博客模板从 content/articles/

/index.md 生成帖子。这很好,因为它允许将图像等关联文件包含在文章中。但实际上,大多数“博客文章”只是与模板关联的文本内容。必须创建子目录是一个小烦恼,如果在选项卡式编辑器中编辑多个条目,则将所有内容命名为 index.md 会很烦人。

站点生成器将生成articles/basic-post.html 文件,但不会将这些文件包含在生成的索引或存档页面中。我怎样才能让后者在不破坏任何东西的情况下工作?

这可能是也可能不是一个简单的问题,但我是 Wintersmith 的新手,还没有看到如何做到这一点。我不确定它是否像编辑默认分页器一样简单(而且我不太习惯 CoffeeScript,也许是时候解决这个问题了:)

在 paginator.coffee 中:

getArticles = (contents) ->
  # helper that returns a list of articles found in *contents*
  # note that each article is assumed to have its own directory in the articles directory
  articles = contents[options.articles]._.directories.map (item) -> item.index
  articles.sort (a, b) -> b.date - a.date
  return articles

这看起来像这个地方,但是直接编辑插件似乎是一个坏主意,以便将来可能进行更新工作。

顺便说一句,温特史密斯非常棒。

最佳答案

你是对的:答案在于paginator插件。

Wintersmith 将持续监视 contents 文件夹,构建 ContentTree 数组。 该对象数组将包含 contents 中每个文件和文件夹的描述符。

getArticles 只是过滤这些可能的候选者,您只需增强它即可在 contents/articles 文件夹中获取纯 Markdown 文件。

  getArticles = (contents) ->
    # helper that returns a list of articles found in *contents*
    # include articles with dedicated directory
    articles = contents[options.articles]._.directories.map (item) -> item.index
    # add articles that are in the *contents/articles* folder 
    articles = articles.concat contents[options.articles]._.pages
    articles.sort (a, b) -> b.date - a.date
    return articles

关于blogs - 如何让 Wintersmith 中的文章不在其自己的子目录中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22153778/

相关文章:

coffeescript - Wintersmith:错误加载插件 './node_modules/wintersmith-coffee/' 时出错:找不到模块 './plugin'

Jekyll:在同一页面显示所有帖子

python - 将我的简历作为 PDF 文件添加到 Pelican 静态博客网站

blogs - *免费*截屏应用程序和实用程序

python - Django:Modelform 在模板中自动创建表单

css - 为博主显示移动设备的 Logo 图像

wintersmith:可视化内容树

coffeescript - 如何自定义 Wintersmith 分页器?