mirror of
https://github.com/Mibew/simple-icons.git
synced 2025-02-20 16:05:47 +03:00
Reuse svg
getter package template parts (#7457)
* Reuse svg getter package template parts
This commit is contained in:
parent
986589c34c
commit
e0a4e765ad
@ -106,18 +106,24 @@ const build = async () => {
|
||||
}),
|
||||
);
|
||||
|
||||
// constants used in templates to reduce package size
|
||||
const constantsString = `const a='<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>',b='</title><path d="',c='"/></svg>';`;
|
||||
|
||||
// write our generic index.js
|
||||
const rawIndexJs = util.format(
|
||||
indexTemplate,
|
||||
constantsString,
|
||||
buildIcons.map(iconToKeyValue).join(','),
|
||||
);
|
||||
await writeJs(indexFile, rawIndexJs);
|
||||
|
||||
// write our file containing the exports of all icons in CommonJS ...
|
||||
const rawIconsJs = `module.exports={${iconsBarrelJs.join('')}};`;
|
||||
const rawIconsJs = `${constantsString}module.exports={${iconsBarrelJs.join(
|
||||
'',
|
||||
)}};`;
|
||||
await writeJs(iconsJsFile, rawIconsJs);
|
||||
// and ESM
|
||||
const rawIconsMjs = iconsBarrelMjs.join('');
|
||||
const rawIconsMjs = constantsString + iconsBarrelMjs.join('');
|
||||
await writeJs(iconsMjsFile, rawIconsMjs);
|
||||
// and create a type declaration file
|
||||
const rawIconsDts = `import {SimpleIcon} from ".";type I = SimpleIcon;${iconsBarrelDts.join(
|
||||
|
@ -2,7 +2,7 @@
|
||||
title: '%s',
|
||||
slug: '%s',
|
||||
get svg() {
|
||||
return '<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><title>%s</title><path d="' + this.path + '"/></svg>';
|
||||
return a + '%s' + b + this.path + c;
|
||||
},
|
||||
path: '%s',
|
||||
source: '%s',
|
||||
|
@ -1,5 +1,7 @@
|
||||
console.warn('Deprecation warning: The `simple-icons` entrypoint will be removed in the next major. Please switch to using `import * as icons from "simple-icons/icons"` if you need an object with all the icons.')
|
||||
|
||||
%s
|
||||
|
||||
var icons = {%s};
|
||||
|
||||
Object.defineProperty(icons, "Get", {
|
||||
|
Loading…
Reference in New Issue
Block a user