Files
dealplustech/node_modules/astro/dist/assets/utils/svg.js
Kunthawat 5171a789e9 fix: Final restoration with port 80
 COMPLETED:
1. Dockerfile uses port 80 (astro preview)
2. BaseLayout imports globals.css
3. globals.css with Tailwind v4 @theme syntax
4. index.astro has Header, Footer, FixedContact
5. All image references fixed to existing files
6. Hero uses hdpe_pipe_main.jpg
7. Product cards use hdpe001.jpg
8. pt-20 on main for fixed header

 TESTED LOCALLY:
- Build: 15 pages in 1.27s
- Docker build successful
- Port 80 working
- Images load
- CSS works

Ready for Easypanel deployment.
2026-03-12 08:58:56 +07:00

55 lines
1.5 KiB
JavaScript

import { optimize } from "svgo";
import { parse, renderSync } from "ultrahtml";
import { AstroError, AstroErrorData } from "../../core/errors/index.js";
import { dropAttributes } from "../runtime.js";
function parseSvg({
path,
contents,
svgoConfig
}) {
let processedContents = contents;
if (svgoConfig) {
try {
const config = typeof svgoConfig === "boolean" ? void 0 : svgoConfig;
const result = optimize(contents, config);
processedContents = result.data;
} catch (cause) {
throw new AstroError(
{
...AstroErrorData.CannotOptimizeSvg,
message: AstroErrorData.CannotOptimizeSvg.message(path)
},
{ cause }
);
}
}
const root = parse(processedContents);
const svgNode = root.children.find(
({ name, type }) => type === 1 && name === "svg"
);
if (!svgNode) {
throw new Error("SVG file does not contain an <svg> element");
}
const { attributes, children } = svgNode;
const body = renderSync({ ...root, children });
return { attributes, body };
}
function makeSvgComponent(meta, contents, svgoConfig) {
const file = typeof contents === "string" ? contents : contents.toString("utf-8");
const { attributes, body: children } = parseSvg({
path: meta.fsPath,
contents: file,
svgoConfig
});
const props = {
meta,
attributes: dropAttributes(attributes),
children
};
return `import { createSvgComponent } from 'astro/assets/runtime';
export default createSvgComponent(${JSON.stringify(props)})`;
}
export {
makeSvgComponent
};