mirror of
https://github.com/vale981/metalsmith-layouts
synced 2025-03-04 17:21:37 -05:00
Support layout: false to override a default layout
This commit is contained in:
parent
4f4577511f
commit
2f275dbf56
6 changed files with 22 additions and 5 deletions
|
@ -31,9 +31,5 @@ function check(files, file, pattern, def){
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only process files with a specified layout
|
// Only process files with a specified layout
|
||||||
if(!data.layout && !def) {
|
return 'layout' in data ? data.layout : def;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
1
test/fixtures/layout-false/build/layout-false.html
vendored
Normal file
1
test/fixtures/layout-false/build/layout-false.html
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
has no layout
|
1
test/fixtures/layout-false/expected/layout-false.html
vendored
Normal file
1
test/fixtures/layout-false/expected/layout-false.html
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
has no layout
|
2
test/fixtures/layout-false/layouts/default.html
vendored
Normal file
2
test/fixtures/layout-false/layouts/default.html
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
{{title}}
|
||||||
|
{{contents}}
|
5
test/fixtures/layout-false/src/layout-false.html
vendored
Normal file
5
test/fixtures/layout-false/src/layout-false.html
vendored
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Title
|
||||||
|
layout: false
|
||||||
|
---
|
||||||
|
has no layout
|
|
@ -149,6 +149,18 @@ describe('metalsmith-layouts', function(){
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should ignore files with layout: false', function(done){
|
||||||
|
Metalsmith('test/fixtures/layout-false')
|
||||||
|
.use(layouts({engine: 'handlebars', default: 'default.html'}))
|
||||||
|
.build(function(err){
|
||||||
|
if (err) {
|
||||||
|
return done(err);
|
||||||
|
}
|
||||||
|
equal('test/fixtures/layout-false/expected', 'test/fixtures/layout-false/build');
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should not change file extension by default', function(done) {
|
it('should not change file extension by default', function(done) {
|
||||||
Metalsmith('test/fixtures/rename-option-default')
|
Metalsmith('test/fixtures/rename-option-default')
|
||||||
.use(layouts({
|
.use(layouts({
|
||||||
|
|
Loading…
Add table
Reference in a new issue