🔧 Refactor getAstroCode function to use destructured parameters for improved readability

This commit is contained in:
pheralb
2025-08-25 19:04:23 +01:00
parent d563478871
commit 110657a028
+3 -3
View File
@@ -2,12 +2,12 @@ interface AstroComponentParams {
svgContent: string;
}
export function getAstroCode({ svgContent }: AstroComponentParams): string {
const cleanedSvg = svgContent
export function getAstroCode(params: AstroComponentParams): string {
const cleanedSvg = params.svgContent
.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, "");
return `<svg ${cleanedAttrs} {...Astro.props}>`;
});