-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
28 lines (26 loc) · 1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
const genIcons = require('./favicon-gen');
const genHtml = require('./html-gen');
// plugin options
// (manifestData & generateManifest can be overridden per shortcode)
const defaultOptions = {
outputDir: './_site',
manifestData: {},
generateManifest: true,
skipCache: false,
};
module.exports = (eleventyConfig, options) => {
const {outputDir, manifestData, generateManifest, skipCache} = Object.assign({}, defaultOptions, options);
// favicons shortcode
// examples:
// {% favicons 'favicon.svg' %}
// {% favicons 'favicon.svg', appleIconBgColor='black' %}
// {% favicons 'favicon.svg', appleIconBgColor='black', manifestData={name:'My Website'} %}
eleventyConfig.addAsyncShortcode('favicons', async (sourceFile, opts) => {
const favOpts = Object.assign(
{manifestData: manifestData, generateManifest: generateManifest, skipCache: skipCache},
opts,
);
const generatedFiles = await genIcons(sourceFile, outputDir, favOpts);
return await genHtml(generatedFiles);
});
};