forked from GDGToulouse/devfest-theme-hugo
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathicons.js
More file actions
21 lines (17 loc) · 695 Bytes
/
icons.js
File metadata and controls
21 lines (17 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
const {readFileSync, writeFileSync} = require('fs');
const {sync: glob} = require('glob');
const data = glob(`src/icons/*.svg`)
.map(file => {
const parts = file.split('/');
const id = parts[parts.length - 1].split('.')[0];
return readFileSync(file, 'utf8')
.replace(`<svg xmlns="http://www.w3.org/2000/svg"`, `\t<symbol id="${id}"`)
.replace(`</svg>`, `\t</symbol>`);
}
);
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="0" height="0" class="visually-hidden">
${data.join('\n')}
</svg>`;
const file = 'static/icons.svg';
console.info('Generate ', file);
writeFileSync(file, svg, {flag: 'w'});