2

In Wintersmith, the default blog template generates posts from content/articles/<article>/index.md. This is fine as it allows associated files like images to be included with the article. But in practice, most "blog posts" are just text content associated with a template. Having to create subdirs is a minor annoyance, and if editing multiple entries in a tabbed editor, it's annoying having everything named index.md.

The site generator will spit out articles/basic-post.html files, but does not include these in the generated index or archive pages. How can I get the latter to work without breaking anything?

This may or may not be a simple problem, but I'm new to Wintersmith and haven't seen how to do this. I'm not sure it's as trivial as editing the default paginator (and I am not that used to CoffeeScript, which maybe it's time to address that :)

In 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

This looks like the place, however it seems like a bad idea to directly edit a plugin, for potential future updates to work.

Wintersmith is pretty awesome btw.

4

1 回答 1

3

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

Wintersmith 将不断地观察contents文件夹,建立一个ContentTree阵列。该对象数组将包含 . 中每个文件和文件夹的描述符contents

只需过滤这些getArticles可能的候选者,您只需对其进行增强即可在contents/articles文件夹中获取普通的降价文件。

  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
于 2014-03-03T19:27:53.793 回答