shannonmoeller / gulp-hb

A sane Gulp plugin to compile Handlebars templates. Useful as a static site generator.
http://npm.im/gulp-hb
MIT License
148 stars 14 forks source link

QUESTION: Using helper-markdown with gulp-hb #68

Closed caraya closed 5 years ago

caraya commented 5 years ago

I am having a problem trying to use front-matter and layouts when building content using gulp-hb (version 8). The goal is to use a different layout based on whether the content is html versus Markdown.

I have the following question:

How can I convert Markdown to HTML in the process? I've tried using helper-markdown but it's not recognized as a helper and doesn't appear when I use debug

I'm using the following task

gulp.task('prepHB', () => {
  return gulp.src('src/pages/**/*.{md,html}')
      .pipe(frontMatter({
        property: 'frontMatter',
        remove: true,
      }))
      .pipe(hb({debug: true})
          .partials('src/partials/components/**/*.hbs')
          .helpers(require('helper-markdown'))
          .helpers(require('handlebars-layouts'))
      )
      .pipe(extReplace('.html'))
      .pipe(gulp.dest('docs/'));
});
shannonmoeller commented 5 years ago

Not all handlebars plugins are compatible with the .helpers() function out of the box. Try this:

.helpers({ markdown: require('helper-markdown') })
shannonmoeller commented 5 years ago

@caraya Did you get it working?

caraya commented 5 years ago

Yes, I did