Skip to content
This repository has been archived by the owner on May 20, 2024. It is now read-only.

Commit

Permalink
[grunt] add ability to exclude pages building by specifying _ in th…
Browse files Browse the repository at this point in the history
…e beginning of the directory
  • Loading branch information
ArmorDarks committed Aug 2, 2019
1 parent a05c8c3 commit b1ece95
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,23 @@

## [HEAD](https://github.com/LotusTM/Kotsu/compare/v1.14.1...HEAD)

### Added
- [grunt] Added ability to exclude pages building by simply specifying `_` in the beginning of the directory

Previously:

* `/templates/test/page.nj` — build
* `/templates/_test/page.nj` — build
* `/templates/test/_page.nj` — exclude
* `/templates/_test/_page.nj` — exclude

With update:

* `/templates/test/page.nj` — build
* `/templates/_test/page.nj` — exclude
* `/templates/test/_page.nj` — exclude
* `/templates/_test/_page.nj` — exclude

### Changed
- [scripts] Improved logging of the site info to the console:

Expand Down
9 changes: 6 additions & 3 deletions tasks/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const nunjucksTask = require('../modules/nunjucks-task')
const { merge } = require('lodash')
const { join } = require('path')

const ALL = '{,**/}*.{nj,html}'
const NON_PARTIALS = `{,!(_)*/!(_)*{,/}}!(_)*.{nj,html}`

module.exports = function ({ config, file: { readJSON } }) {
// Nunjucks to HTML
// https://github.com/vitkarpov/grunt-nunjucks-2-html
Expand Down Expand Up @@ -33,7 +36,7 @@ module.exports = function ({ config, file: { readJSON } }) {
files: [{
expand: true,
cwd: config('path.source.templates'),
src: ['{,**/}*.{nj,html}', '!{,**/}_*.{nj,html}', '!{,**/}*.{txt,json,xml}.nj'],
src: [NON_PARTIALS, '!{,**/}*.{txt,json,xml}.{nj,html}'],
dest: config('path.build.templates'),
ext: '.html'
}]
Expand Down Expand Up @@ -92,11 +95,11 @@ module.exports = function ({ config, file: { readJSON } }) {
this.config.merge({
watch: {
templates: {
files: ['<%= path.source.templates %>/{,**/}*.nj', '!<%= path.source.templates %>/{,**/}_*.nj'],
files: [`<%= path.source.templates %>/${NON_PARTIALS}`],
tasks: ['grayMatter', 'newer:nunjucks']
},
templatesPartials: {
files: ['<%= path.source.templates %>/{,**/}_*.nj'],
files: [`<%= path.source.templates %>/${ALL}`, `!<%= path.source.templates %>/${NON_PARTIALS}`],
tasks: ['grayMatter', 'nunjucks']
}
}
Expand Down

0 comments on commit b1ece95

Please sign in to comment.