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