gulp-assemble icon indicating copy to clipboard operation
gulp-assemble copied to clipboard

Child Pages

Open eikeco opened this issue 11 years ago • 15 comments

Original ticket on the assemble.io repo. https://github.com/assemble/assemble/issues/537#issuecomment-47785369

Is there a way to set up child pages with gulp-assemble? For example example.com/parent/child.html.

Looks like you can use "flatten" (https://github.com/assemble/assemble#flatten) in Grunt. Any idea if it's possible with gulp?

eikeco avatar Jul 02 '14 15:07 eikeco

Looks like you can use "flatten"

I don't think so. But like I mentioned https://github.com/jonschlinkert/gulp-rte might be a good solution here. I know it's one more plugin, but that's the gulp way (just adding mention of this here in case others read here)

jonschlinkert avatar Jul 02 '14 15:07 jonschlinkert

Thanks @jonschlinkert. I will give it a go and post any results here.

Thanks again :)

eikeco avatar Jul 02 '14 15:07 eikeco

@jonschlinkert @eikeco any progress on this issue. I've been working a lot on our company website in grunt-assemble and playing around with switching over to Gulp. Seems like multiple gulp.dest is an issue for many plugins. I tried to hack it in the task but resulted in some double compilation and it's not ideal. I'm willing to help on this issue if it's still something you guys are working on.

var glob = require('glob');

  glob('src/pages/**/*.hbs', function(err, files) {

    files.forEach(function(filePath) {
      replacedPath = filePath.replace('src/pages/', '');

      if ( /\//.test(replacedPath) ) {
        buildPath = replacedPath.substr(0, replacedPath.lastIndexOf('/')) - 1;
      } else {
        buildPath = '';
      }

      gulp.src(filePath)
        .pipe(assemble(options))
        .pipe(gulp.dest('build/' + buildPath));
    });
  });

The result of the above will be a duplication of the index file inside of the nested directory and it's content is the HTML templated twice.

screen shot 2014-08-11 at 1 47 26 am

dtothefp avatar Aug 11 '14 05:08 dtothefp

@jonschlinkert @eikeco anybody out there...Bueller??

dtothefp avatar Aug 17 '14 19:08 dtothefp

@dtothefp thanks for the ping! I read this initially on my iphone and forgot to respond when I got to my computer.

I'm willing to help on this issue if it's still something you guys are working on.

yeah, I'd love to hear your thoughts on what the solution might look like. one idea I've considered is creating a plugin that can be used as an alternative to gulp.dest().

just to make sure I'm clear on what you need, you just want to build to multiple destinations using the same src files and task configuration. is that all or are there other things you need to accomplish?

jonschlinkert avatar Aug 18 '14 02:08 jonschlinkert

... and sorry it took so long to reply!

jonschlinkert avatar Aug 18 '14 02:08 jonschlinkert

@jonschlinkert yes, all I'm looking to do is build multiple destinations using the same src files, without having to build multiple tasks. Also the directory structure of the build tree should match that of the source files. This is so easy in Grunt, but due to the streaming nature of Gulp it seems to be a ubiquitous problem.

Something along the lines of this might be appropriate

https://github.com/gulpjs/gulp/issues/372#issuecomment-38615041

Creating an object of all paths, passing them through gulp.src and manipulating their paths with gulp-tap

PS I'm working with @kylerush at Optimizely implementing Assemble for our new marketing website. We are using the Grunt version heavily now but I wanted to play around with what you guys have in Gulp so far

dtothefp avatar Aug 19 '14 15:08 dtothefp

PS I'm working with @kylerush at Optimizely implementing Assemble for our new marketing website. We are using the Grunt version heavily now but I wanted to play around with what you guys have in Gulp so far

Awesome! let us know how we can help. fwiw, if you want to play around with the gulp version, I highly recommend taking a look at assemble v0.6.0 instead - it depends on some of the awesome libs from the fractal team. it's nowhere near production ready, but it's orders of magnitude more powerful (and IMHO, easier to use) than Assemble 0.4.x. Not to mention, although the built-in plugins we're using currently take about 1 second to spin up, after that it's screaming fast. also fwiw, we will be externalizing those plugins, engines, parsers etc. into their own repos - and promoting use of gulp plugins whenever possible. @doowb did some benchmarking with thousands of files that we'll share when we launch.

btw, just out of curiosity where is optimizely located?

jonschlinkert avatar Aug 19 '14 22:08 jonschlinkert

@dtothefp did you manage to get any further with this? I have a number of times but can't get my head around it...

eikeco avatar Oct 09 '14 09:10 eikeco

@eikeco sorry I forgot to get back to you. I actually did have time to continue with Gulp Assemble but I did actually just start looking at their v0.6.0 API and CLI. Looks like this would do a lot of what we desire for the multiple destinations, and you could probably just fire up the CLi with Gulp if you wanted. I just sent a message to @jonschlinkert for some example repos as I'd like to start playing around with this.

Alternatively, if you still want to try the gulp-assemble route a friend of mine suggested this structure for mulitple dest in gulp http://jsfiddle.net/d4q5h66x/. It's a browserify example but may be pertinent.

dtothefp avatar Nov 08 '14 19:11 dtothefp

Hey @jonschlinkert, any news on this...?

kluplau avatar Sep 14 '15 10:09 kluplau

@Blueblau if you want to use gulp, just use assemble v0.6 directly inside of your gulp task. Have a look at my assemble docs if you're not familiar with v0.6 https://github.com/dtothefp/assemble-docs

dtothefp avatar Sep 14 '15 13:09 dtothefp

@dtothefp that's awesome! can I use some snippets from those docs?! of course I'll give you attribution in our docs

jonschlinkert avatar Sep 14 '15 13:09 jonschlinkert

@Blueblau this is something that can be done with a plugin. hmm... I have an idea. let me talk to @doowb

jonschlinkert avatar Sep 14 '15 13:09 jonschlinkert

Great. Thanks guys! :-)

kluplau avatar Sep 14 '15 16:09 kluplau