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.

Jason Boyd
  • 1,192
  • 1
  • 9
  • 19
  • I'm sorry, but I do not fully understand what you're trying to do. Is it about associating a rendering template with a given article content ? Or is it about content directory organization ? – Feugy Mar 03 '14 at 18:14
  • Id like to be able to have content/articles/foo/index.md as well as content/articles/bar.md both be put into the output (which does work out of the box) AND have the main listing (index and archive) pages include these generated files (which does not work). Does that clarify the question? – Jason Boyd Mar 03 '14 at 18:18

1 Answers1

3

You were right: theanswer lies into the paginator plugin.

Wintersmith will constently watch the contents folder, building a ContentTree array. That objet array will contain a descriptor for each file and folder within contents.

The getArticles just filter this possible candidates, and you just need to enhance it to get plain markdown files in the contents/articles folder.

  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
Feugy
  • 1,898
  • 14
  • 18
  • Nice! I was so close, had the exact same line but with `files` instead of `pages`. Not bad for not knowing coffee script and not finding any current docs on this. I'm sure I can root around eventually when I have time, but what's the best way to figure out what all is going on here? Either it's a bit too much magic, or I need to learn Coffeescript, or the docs need to be updated, but the plugin stuff is very hard to penetrate. I can tell its fairly elegant and flexible, but wish there were some overview docs. – Jason Boyd Mar 04 '14 at 02:32