Răsfoiți Sursa

Bug fix: fix bugs in css rendering for components.

Lee Morgan 5 zile în urmă
părinte
comite
e16023d8e6
1 a modificat fișierele cu 2 adăugiri și 3 ștergeri
  1. 2 3
      parseComponent.js

+ 2 - 3
parseComponent.js

@@ -104,15 +104,14 @@ const createBundle = async (data)=>{
 
 
 const mergeFiles = (comps)=>{
 const mergeFiles = (comps)=>{
     let cssIndex = comps.html.indexOf("</head>");
     let cssIndex = comps.html.indexOf("</head>");
-    cssIndex = cssIndex < 0 ? comps.html.length - 1 : cssIndex;
+    cssIndex = cssIndex < 0 ? 0 : cssIndex;
     comps.css = comps.css ? `<style>${comps.css}</style>` : "";
     comps.css = comps.css ? `<style>${comps.css}</style>` : "";
     const html = `${comps.html.slice(0, cssIndex)}${comps.css}${comps.html.slice(cssIndex)}`;
     const html = `${comps.html.slice(0, cssIndex)}${comps.css}${comps.html.slice(cssIndex)}`;
 
 
     let jsIndex = html.indexOf("</body>");
     let jsIndex = html.indexOf("</body>");
     jsIndex = jsIndex < 0 ? html.length : jsIndex;
     jsIndex = jsIndex < 0 ? html.length : jsIndex;
     comps.js = comps.js ? `<script>${comps.js}</script>` : "";
     comps.js = comps.js ? `<script>${comps.js}</script>` : "";
-    let thing = `${html.slice(0, jsIndex)}${comps.js}${html.slice(jsIndex)}`;
-    return thing;
+    return `${html.slice(0, jsIndex)}${comps.js}${html.slice(jsIndex)}`;
 }
 }
 
 
 const addComponents = async (html, dir)=>{
 const addComponents = async (html, dir)=>{