assemble / grunt-assemble-permalinks

Permalinks middleware for Assemble, the static site generator for Grunt.js and Yeoman. This plugin enables powerful and configurable URI replacement patterns, presets, uses Moment.js for parsing dates, and much more.
MIT License
43 stars 11 forks source link

Permalink not showing in tags collection. #28

Closed Hypercubed closed 10 years ago

Hypercubed commented 10 years ago

I have a page (say test.html) with the permalinks plugin and preset: 'pretty'. The file is then written to test/index.html but {{dest}} in the tags collection is still test.html.

I think it may be that the dest is not updating in the tags collection. The new dest shows up here:

  {{#each pages}}
    <li>{{dest}}</li>
  {{/each}}

but not here:

{{#each tags}}
  <h1>{{tag}}</h1>
  <ul>
    {{#each pages}}
      <li>{{dest}}</li>
    {{/each}}
  </ul>
{{/each}}
jonschlinkert commented 10 years ago

I think it may be that the dest is not updating in the tags collection

yeah, good call. I think that's right. we'll look into this, thanks for submitting the ticket

jonschlinkert commented 10 years ago

@Hypercubed take a look at this HTML and let me know if you see anything amiss: https://github.com/assemble/permalinks/pull/30

I added targets to the Gruntfile for testing how paths calculate with collections, and everything seems to be calculating okay to me, but this wouldn't be the first time I missed something when looking at the compiled HTML. I'm just trying to pin down the issue to something specific so we can track this down.

thanks!

Hypercubed commented 10 years ago

This is the file (a repo) that is failing for me.

https://github.com/Hypercubed/assemble-bootstrap-template/blob/dev/src/test.hbs

The pages section shows out/test/index.html while tags section shows out/test.html.

jonschlinkert commented 10 years ago

Your best bet is to look over what I pushed up and see if you can get a hint about what's going on.

Hypercubed commented 10 years ago

If I understand the tests (it's possible I don't) shouldn't articles/bar/index.html, articles/baz/index.html, and foo/index.html be generating the same thing? Instead I see that bar shows the pre-permalink path for all three pages, baz is only correct for bar, and foo is correct for bar and baz but not for itself.

Looks to me that the dest is updated as each page is rendered. Maybe not a coincidence that this appears to be the order they are in the file structure.

Hypercubed commented 10 years ago

Yeah, if you run grunt assemble:preset -v you will see that the plugin is run only as it renders each file. Meaning, as far as I can tell, the {{dest}} is not changed for files it hasn't reached yet.

AndersDJohnson commented 10 years ago

@Hypercubed That's why I am proposing #360 (https://github.com/assemble/assemble/pull/360). @jonschlinkert Using the "before" stage for this plugin seems like it could address the issue.

jonschlinkert commented 10 years ago

I'm pretty sure this is fixed. please see ./test/actual, there are a number of tests using collections.