micromata / Baumeister

Unmaintained – :construction_worker: The aim of this project is to help you to build your things. From Bootstrap themes over static websites to single page applications.
MIT License
171 stars 37 forks source link

Templating using markdown and handlebars not working #260

Closed virajsoni06 closed 2 years ago

virajsoni06 commented 5 years ago

Hi, I'm trying to using Markdown for content and Handlebars for templating. However, it does not seem to work.

The is the error thrown no files to process. See https://www.npmjs.com/package/metalsmith-in-place#no-files-to-process. However, there are .md files in the folder.

Here's my handlebar configuration


metalsmith(__dirname)
  // Source directory
  .source('../src/handlebars/pages')

  // Destination directory
  .destination(path.join(__dirname, '../', settings.destinations.handlebars))

  // Clean destination before
  .clean(true)

  // Register Handlebars helpers
  .use(registerHelpers({
    directory: path.join(__dirname, '../', settings.sources.handlebars, 'helpers')
  }))

  // Register Handlebars partials
  .use(registerPartials({
    directory: path.join(__dirname, '../', settings.sources.handlebars, 'partials'),
    pattern: /\.hbs$/
  }))

  .use(markdown({
    smartypants: true,
    smartLists: true,
    gfm: true,
    tables: true
  }))

  .use(permalinks())

  .use(layouts({
    directory: path.join(__dirname, '../', settings.sources.handlebars, 'layouts'),
    default: 'default.hbs',
    pattern: '**/*.hbs',
    engine: 'handlebars'
  }))

  .use(inPlace({
    pattern: '*.md',
    engineOptions: {
      partials: path.join(__dirname, '../', settings.sources.handlebars, 'partials'),
    }
  }))

  // Only build HTML files
  // .use(filter(['**/*.html', '!handlebars/**/*.html','handlebars']))
  .use(filter(['**/*.html']))

  // Finally build files
  .build(err => {

    // Handle build errors
    if (err) {
      console.log(stripIndents`
        ${logSymbols.error} Handlebars build failed:
        ${chalk.red.bold(err.message)}
      `);
      process.exit(1);

    // Handle successful build
    } else {
      /**
       * NOTE:
       * We need to backdate the generated files by ten seconds until
       * https://github.com/webpack/watchpack/issues/25 is fixed.
       * Otherwise we would have some uneeded rebuilds when starting webpack in
       * watch mode or starting the webpack dev server.
       */
      const f = path.resolve(__dirname, '../', settings.destinations.handlebars);
      const now = Date.now() / 1000;
      const then = now - 10;
        globby(f + '/**/*.html')
          .then(files => {
              console.log(files)
              files.forEach(file => {
                fs.utimes(file, then, then, (err) => {
                  if (err) {
                    console.error(err);
                  }
                  console.log(
                    logSymbols.success,
                    ` Finished ${chalk.blue.bold('Handlebars build')} after`,
                    chalk.yellow.bold(perfy.end('build').time >= 1 ? `${Math.round(perfy.end('build').time * 100) / 100} s` : `${Math.round(perfy.end('build').milliseconds)} ms`),
                    '\n'
                  );
                  process.exit(0);
                });
              });
          });
    }
  });
mischah commented 5 years ago

Hej @virajsoni06,

are you using metalsmith-markdown in addition?

Sorry, for the delayed answer πŸ™ˆ

Cheers, Michael

virajsoni06 commented 5 years ago

@mischah Yeah, I have metalsmith-markdown@1.0.1 installed

mischah commented 2 years ago

This project is unmaintained 😒 See Note in Readme.