shannonmoeller / gulp-hb

A sane Gulp plugin to compile Handlebars templates. Useful as a static site generator.

Home Page:http://npm.im/gulp-hb

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

QUESTION: Using helper-markdown with gulp-hb

caraya opened this issue · comments

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/'));
});

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

.helpers({ markdown: require('helper-markdown') })

@caraya Did you get it working?

Yes, I did