Initial commit with Sveltekit + format files

This commit is contained in:
pheralb
2025-08-21 10:26:07 +01:00
parent ca4f397e0a
commit 459457a7e1
97 changed files with 3892 additions and 9893 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ interface AngularComponentParams {
export function getAngularCode(params: AngularComponentParams): string {
const updatedSvgContent = params.svgContent.replace(
/<svg([^>]*)>/,
`<svg$1 [attr.width]="size.width" [attr.height]="size.height">`
`<svg$1 [attr.width]="size.width" [attr.height]="size.height">`,
);
return `
+4 -4
View File
@@ -4,11 +4,11 @@ interface AstroComponentParams {
export function getAstroCode({ svgContent }: AstroComponentParams): string {
const cleanedSvg = 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) => {
const cleanedAttrs = attrs.replace(/\s*\{?\.\.\.Astro\.props\}?\s*/i, '');
const cleanedAttrs = attrs.replace(/\s*\{?\.\.\.Astro\.props\}?\s*/i, "");
return `<svg ${cleanedAttrs} {...Astro.props}>`;
});
+5 -5
View File
@@ -5,15 +5,15 @@ interface ReactComponentParams {
}
export const getReactCode = async (
params: ReactComponentParams
params: ReactComponentParams,
): Promise<{ data?: string; error?: string }> => {
try {
const getCode = await fetch('/api/svgs/svgr', {
method: 'POST',
const getCode = await fetch("/api/svgs/svgr", {
method: "POST",
headers: {
'Content-Type': 'application/json'
"Content-Type": "application/json",
},
body: JSON.stringify(params)
body: JSON.stringify(params),
});
const data = await getCode.json();
return data;
+1 -1
View File
@@ -3,7 +3,7 @@ interface SourceParams {
}
export const getSource = async (params: SourceParams) => {
const response = await fetch(params.url || '');
const response = await fetch(params.url || "");
const content = await response.text();
return content;
};
+6 -3
View File
@@ -1,4 +1,4 @@
import { parseSvgContent } from '@/utils/parseSvgContent';
import { parseSvgContent } from "@/utils/parseSvgContent";
interface SvelteComponentParams {
lang: string;
@@ -6,8 +6,11 @@ interface SvelteComponentParams {
}
export const getSvelteCode = (params: SvelteComponentParams) => {
const { templateContent, componentStyle } = parseSvgContent(params.content, 'Svelte');
return `<script${params.lang ? ` lang="${params.lang}"` : ''}></script>
const { templateContent, componentStyle } = parseSvgContent(
params.content,
"Svelte",
);
return `<script${params.lang ? ` lang="${params.lang}"` : ""}></script>
${templateContent}
${componentStyle}
+6 -3
View File
@@ -1,4 +1,4 @@
import { parseSvgContent } from '@/utils/parseSvgContent';
import { parseSvgContent } from "@/utils/parseSvgContent";
interface VueComponentParams {
lang: string;
@@ -6,8 +6,11 @@ interface VueComponentParams {
}
export const getVueCode = (params: VueComponentParams) => {
const { templateContent, componentStyle } = parseSvgContent(params.content, 'Vue');
return `<script setup${params.lang ? ` lang="${params.lang}"` : ''}></script>
const { templateContent, componentStyle } = parseSvgContent(
params.content,
"Vue",
);
return `<script setup${params.lang ? ` lang="${params.lang}"` : ""}></script>
<template>
${templateContent}
</template>