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

Pretty permalinks not working #59

Closed andyra closed 9 years ago

andyra commented 9 years ago

I'm trying out this plugin to get pretty permalinks (example.com/about instead of example.com/about.html).

When I run grunt assemble, I expect docs/pages/about.hbs to compile to docs/build/about/index.html, but instead it's compiling to docs/build/about.html. I've followed the example in the docs and my Gruntfile.coffee looks like so:

assemble:
  options:
    flatten: true
    plugins: ['assemble-middleware-permalinks']
    layoutdir: 'docs/layouts'
    assets: 'dist/assets'
    partials: 'docs/partials/*.hbs'
    helpers: 'docs/helpers/*.js'
    data: ['docs/data/*.{json,yml}']
  docs:
    options:
      permalinks:
        preset: 'pretty'
    files: [
      expand: true
      cwd: 'docs/pages'
      src: ['**/*.hbs']
      dest: 'docs/build/'
    ]

The plugin doesn't seem to be doing anything at all. Is there something I'm missing here?

doowb commented 9 years ago

Try using assemble-contrib-permalinks for assemble 0.4.x

andyra commented 9 years ago

Ah, good catch. OK, now my package.json dependencies look like so:

"assemble": "^0.4.42",
"assemble-contrib-permalinks": "^0.3.6",
"grunt": "^0.4.5",

I changed my Grunfile to:

assemble:
  options:
    flatten: true
    plugins: ['assemble-contrib-permalinks']
    ...

Now when I run grunt:assemble, I get the following error:

Warning: Arguments to path.resolve must be strings Use --force to continue.

andyra commented 9 years ago

Note: I'm getting this same error when I clone the assemble-middleware-permalinks repo, install npm dependencies, and run grunt:assemble.

doowb commented 9 years ago

Check your node_modules and make sure assemble-contrib-permalinks is version 0.3.6. I have that setup on:

Mac OSX 10.9.5
node 0.10.29
npm 1.4.26

Maybe something else is conflicting.

andyra commented 9 years ago

Yep, the package.json file for assemble-contrib-permalinks is telling the the version number is 0.3.6. I'm set up with:

Mac OSX 10.9.5
node 0.10.36
npm 1.4.28

The only other npm modules I have in the project are grunt, assemble, and load-grunt-tasks, so I don't think there should be any conflicts.

doowb commented 9 years ago

I updated and it's working fine. How are you using load-grunt-tasks? Can you post the entire gruntfile?

andyra commented 9 years ago

I'm using load-grunt-tasks so I don't have to manually include new plugins in the gruntfile.

module.exports = (grunt) ->
  grunt.initConfig
    pkg: grunt.file.readJSON('package.json')

    assemble:
      options:
        flatten: true
        plugins: ['assemble-contrib-permalinks']
        layoutdir: 'docs/layouts'
        assets: 'dist/assets'
        partials: 'docs/partials/*.hbs'
        helpers: 'docs/helpers/*.js'
        data: ['docs/data/*.{json,yml}']
      site:
        options:
          permalinks:
            preset: 'pretty'
        files: [
          expand: true
          cwd: 'docs/pages'
          src: ['**/*.hbs']
          dest: 'docs/build/'
        ]

  # Load plugins
  require('load-grunt-tasks') grunt,
    pattern: ['grunt-*', 'assemble']

  grunt.registerTask 'default', ['assemble']

Keep in mind that I'm getting the same error when running grunt assemble on the examples included in the repo, so I don't think it's specific to this project.

akileez commented 9 years ago

try this:

# Load plugins
  require('load-grunt-tasks') grunt,
    pattern: ['grunt-*', 'assemble*']

  grunt.registerTask 'default', ['assemble']

basically, wildcard the assemble string to pick up the plugin.

andyra commented 9 years ago

Ah, that did the trick. Thanks! I'm not sure why I was having the same issue on the assemble-middleware-permalinks repo, but fixing it here works for my project.