Skip to content

Commit

Permalink
Add banner text to main.min.js (mmistakes#880)
Browse files Browse the repository at this point in the history
- Add `---` YAML Front Matter as a workaround to allow the theme gem's version to be overridden locally.
- Adjust page scope in Front Matter default to avoid adding a layout to `main.min.js`
- Fixes mmistakes#874, Fixes mmistakes#722
  • Loading branch information
mmistakes authored Feb 28, 2017
1 parent 5d6cf24 commit 9eb2c45
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
9 changes: 9 additions & 0 deletions assets/js/main.min.js

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions banner.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const fs = require('fs');
const pkg = require('./package.json');
const filename = 'assets/js/main.min.js';
const script = fs.readFileSync(filename);
const padStart = str => ('0' + str).slice(-2)
const dateObj = new Date;
const date = `${dateObj.getFullYear()}-${padStart(dateObj.getMonth() + 1)}-${padStart(dateObj.getDate())}`;
const banner = `---
layout:
---
/*!
* Minimal Mistakes Jekyll Theme ${pkg.version} by ${pkg.author}
* Copyright ${dateObj.getFullYear()} Michael Rose - mademistakes.com | @mmistakes
* Licensed under ${pkg.license}
*/
`;

if (script.slice(0, 3) != '/**') {
fs.writeFileSync(filename, banner + script);
}
2 changes: 1 addition & 1 deletion docs/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ defaults:
related: true
# _pages
- scope:
path: ""
path: "_pages"
type: pages
values:
layout: single
Expand Down
9 changes: 9 additions & 0 deletions docs/assets/js/main.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@
},
"scripts": {
"uglify": "uglifyjs assets/js/vendor/jquery/jquery-1.12.4.min.js assets/js/plugins/jquery.fitvids.js assets/js/plugins/jquery.greedy-navigation.js assets/js/plugins/jquery.magnific-popup.js assets/js/plugins/jquery.smooth-scroll.min.js assets/js/_main.js -c -m -o assets/js/main.min.js",
"add-banner": "node banner.js",
"watch:js": "onchange \"assets/js/**/*.js\" -e \"assets/js/main.min.js\" -- npm run build:js",
"build:js": "npm run uglify"
"build:js": "npm run uglify && npm run add-banner"
}
}
2 changes: 1 addition & 1 deletion test/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ defaults:
related: true
# _pages
- scope:
path: ""
path: "_pages"
type: pages
values:
layout: single
Expand Down

0 comments on commit 9eb2c45

Please sign in to comment.