Add banner text to main.min.js (#880)
- 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 #874, Fixes #722
This commit is contained in:
parent
dbdf5c2f25
commit
b9d86f3989
6 changed files with 43 additions and 3 deletions
9
assets/js/main.min.js
vendored
9
assets/js/main.min.js
vendored
File diff suppressed because one or more lines are too long
21
banner.js
Normal file
21
banner.js
Normal file
|
@ -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);
|
||||||
|
}
|
|
@ -195,7 +195,7 @@ defaults:
|
||||||
related: true
|
related: true
|
||||||
# _pages
|
# _pages
|
||||||
- scope:
|
- scope:
|
||||||
path: ""
|
path: "_pages"
|
||||||
type: pages
|
type: pages
|
||||||
values:
|
values:
|
||||||
layout: single
|
layout: single
|
||||||
|
|
9
docs/assets/js/main.min.js
vendored
9
docs/assets/js/main.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -27,7 +27,8 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"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",
|
"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",
|
"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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -258,7 +258,7 @@ defaults:
|
||||||
related: true
|
related: true
|
||||||
# _pages
|
# _pages
|
||||||
- scope:
|
- scope:
|
||||||
path: ""
|
path: "_pages"
|
||||||
type: pages
|
type: pages
|
||||||
values:
|
values:
|
||||||
layout: single
|
layout: single
|
||||||
|
|
Loading…
Reference in a new issue