metalsmith / collections

A Metalsmith plugin that groups files together into collections, which it adds to the global metadata.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconstant contents

jondashkyle opened this issue · comments

Hey—unsure if this is a problem related to Metalsmith or this plugin. When I build the site the value of contents for each article sometimes changes.

For example, here's the value of contents of article one:
<p>A really short, rushed-feeling string of words.</p>

However, when I edit article two by adding a couple line breaks, the contents of article one becomes:

<html> <head> <title>My Blog</title> </head> <body> <h1>My Fourth Post</h1> <time>Thu Dec 06 2012 16:00:00 GMT-0800 (PST)</time> <p>A really short, rushed-feeling string of words.</p> </body> </html>

Any ideas?

hey, i haven't seen this before. can you make sure all the deps are up to date?

This is somewhat related to metalsmith/metalsmith#52. {{contents}} is actual HTML from page.html template for me.

Also, it's possible that item one has template in it's contents, but second item in the same collection has contents without template.

Yes, the same happens without excerpts plugin. Problem must be in collection plugin or core.

I encountered this bug as well. My workaround is to render the pages in two passes. The first pass uses an exclude pattern to render everything except the collection and the second pass only renders the collection.

For example:

metalsmith(__dirname)
    .use(collections({
        posts: {
            pattern: 'blog/*.html',
            sortBy: 'date',
            reverse: true
        }
    }))
    .use(templates({
        pattern: '!blog/*.html',
        engine: 'nunjucks'
    }))
    .use(templates({
        pattern: 'blog/*.html',
        engine: 'nunjucks'
    }))
    .build();

Actually turned out to be a bug with metalsmith-templates, fixed with 0.5.1

This still seems to be a problem with the latest versions of metalsmith/metalsmith-collections. I'm not using metalsmith-templates.

The value of {{{ contents }}} seem to change during different runs, possibly due to a thread/timing issue.