我怎么能让温特史密斯的文章不在自己的子目录中



在Wintersmith中,默认的博客模板从content/articles/<文章>这很好,因为它允许像图像这样的相关文件包含在文章中。但在实践中,大多数"博客文章"只是与模板相关联的文本内容。必须创建子目录是一个小麻烦,如果在选项卡编辑器中编辑多个条目,那么将所有内容命名为index.md会很麻烦。

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

这可能是一个简单的问题,也可能不是,但我是温特史密斯的新手,还没有见过如何做到这一点。我不确定它是否像编辑默认分页器那样微不足道(而且我不太习惯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数组。该objet数组将包含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

最新更新