Skip to content

Commit

Permalink
feat: add symbolNameDelimiter option. (#181)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Sep 10, 2022
1 parent 0accee6 commit e36ab29
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ export type SvgToFontOptions = {
* @default fontName
*/
classNamePrefix?: SvgToFontOptions['fontName'];
/**
* Symbol Name Delimiter, @default `-`
*/
symbolNameDelimiter?: string;
/**
* Directory of custom templates.
*/
Expand Down Expand Up @@ -180,6 +184,7 @@ export default async (options: SvgToFontOptions = {}) => {
options.fontName = options.fontName || 'iconfont';
options.svgicons2svgfont = options.svgicons2svgfont || {};
options.svgicons2svgfont.fontName = options.fontName;
options.symbolNameDelimiter = options.symbolNameDelimiter || '-';
options.classNamePrefix = options.classNamePrefix || options.fontName;
const fontSize = options.css && typeof options.css !== 'boolean' && options.css.fontSize ? options.css.fontSize : '16px';
// If you generate a font you need to generate a style.
Expand All @@ -202,7 +207,7 @@ export default async (options: SvgToFontOptions = {}) => {

Object.keys(unicodeObject).forEach(name => {
const _code = unicodeObject[name];
let symbolName = options.classNamePrefix + '-' + name
let symbolName = options.classNamePrefix + options.symbolNameDelimiter + name
let iconPart = symbolName + '">';
let encodedCodes: string | number = _code.charCodeAt(0);

Expand Down

0 comments on commit e36ab29

Please sign in to comment.