mirror of
https://github.com/pheralb/svgl.git
synced 2025-12-29 08:01:36 +08:00
🔧 Refactor getAstroCode function to use destructured parameters for improved readability
This commit is contained in:
@@ -2,12 +2,12 @@ interface AstroComponentParams {
|
|||||||
svgContent: string;
|
svgContent: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getAstroCode({ svgContent }: AstroComponentParams): string {
|
export function getAstroCode(params: AstroComponentParams): string {
|
||||||
const cleanedSvg = svgContent
|
const cleanedSvg = params.svgContent
|
||||||
.replace(/\s*(width|height)="[^"]*"/gi, "")
|
.replace(/\s*(width|height)="[^"]*"/gi, "")
|
||||||
.replace(/\s*(width|height)='[^']*'/gi, "")
|
.replace(/\s*(width|height)='[^']*'/gi, "")
|
||||||
.replace(/\s*(width|height)=\{[^}]*\}/gi, "")
|
.replace(/\s*(width|height)=\{[^}]*\}/gi, "")
|
||||||
.replace(/<svg([^>]*)>/i, (match, attrs) => {
|
.replace(/<svg([^>]*)>/i, (_, attrs) => {
|
||||||
const cleanedAttrs = attrs.replace(/\s*\{?\.\.\.Astro\.props\}?\s*/i, "");
|
const cleanedAttrs = attrs.replace(/\s*\{?\.\.\.Astro\.props\}?\s*/i, "");
|
||||||
return `<svg ${cleanedAttrs} {...Astro.props}>`;
|
return `<svg ${cleanedAttrs} {...Astro.props}>`;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user