Paths of the generated pages with assemble

前端 未结 2 1793
被撕碎了的回忆
被撕碎了的回忆 2020-12-31 16:02

I am struggling with the grunt-assemble grunt task configuration which looks like this:

assemble: {
  options: {
    f         


        
相关标签:
2条回答
  • 2020-12-31 16:36

    Did you try using the expanded files object for grunt targets with the cwd property?

    assemble: {
      options: {
        flatten: false,
        expand: true,
    
        assets: '',
    
        layout: 'default.hbs',
        layoutdir: 'templates/layouts',
    
        partials: ['templates/includes/*.hbs'],
        helpers: ['templates/helpers/*.js'],
        data: ['templates/data/*.{json,yml}']
      },
    
      dev: {
        files: [
          { cwd: 'templates/pages/', src: '**/*.hbs', dest: 'build/' }
        ]
      }
    }
    
    0 讨论(0)
  • 2020-12-31 16:47

    grunt-assemble

    (Note that this information refers specifically to grunt-assemble 0.4.x, which is the grunt plugin for assemble but has a completely different API)

    @doowb almost has it right, try adding expand: true and ext: '.html' to the files config:

    assemble: {
      options: {
        flatten: false,
        expand: true,
    
        assets: '',
    
        layout: 'default.hbs',
        layoutdir: 'templates/layouts',
    
        partials: ['templates/includes/*.hbs'],
        helpers: ['templates/helpers/*.js'],
        data: ['templates/data/*.{json,yml}']
      },
    
      dev: {
        files: [
          {expand: true, cwd: 'templates/pages/', src: '**/*.hbs', dest: 'build/', ext: '.html'}
        ]
      }
    }
    

    Also take a look at https://github.com/assemble/assemble-contrib-permalinks

    assemble 0.7.x

    Collections are first-class in assemble 0.7.0, as are plugins, so things like generating relative links, building pagination, and creating custom permalinks are much easier to do.

    If you're using assemble 0.7.x and up, assemble-permalinks is the plugin you'd want to use.

    0 讨论(0)
提交回复
热议问题