Spaces:
Sleeping
Sleeping
Update src/components/deploy-button/deploy-button.tsx
Browse files
src/components/deploy-button/deploy-button.tsx
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
import { useState } from "react";
|
3 |
import classNames from "classnames";
|
4 |
import { toast } from "react-toastify";
|
5 |
-
|
6 |
|
7 |
|
8 |
import SpaceIcon from "@/assets/space.svg";
|
@@ -75,28 +75,14 @@ function DeployButton({
|
|
75 |
}
|
76 |
};
|
77 |
|
78 |
-
const
|
79 |
-
const
|
80 |
-
|
81 |
-
// Assume HTML is always present
|
82 |
-
zip.file("index.html", html);
|
83 |
-
|
84 |
-
// Optional: Add more files if available from your generator logic
|
85 |
-
// You may modify this depending on how your app stores code
|
86 |
-
if (state?.reactCode) zip.file("index.tsx", state.reactCode);
|
87 |
-
if (state?.cssCode) zip.file("style.css", state.cssCode);
|
88 |
-
if (state?.jsCode) zip.file("script.js", state.jsCode);
|
89 |
-
|
90 |
-
const blob = await zip.generateAsync({ type: "blob" });
|
91 |
const url = URL.createObjectURL(blob);
|
92 |
const a = document.createElement("a");
|
93 |
a.href = url;
|
94 |
-
a.download =
|
95 |
-
? `${config.title.trim()}.zip`
|
96 |
-
: "website.zip";
|
97 |
-
document.body.appendChild(a);
|
98 |
a.click();
|
99 |
-
|
100 |
};
|
101 |
|
102 |
return (
|
@@ -126,13 +112,13 @@ const downloadZipFile = async () => {
|
|
126 |
{path ? "Update Space" : "Deploy to Space"}
|
127 |
</button>
|
128 |
<div className="pt-2 text-right">
|
|
|
129 |
<button
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
</div>
|
136 |
|
137 |
<div
|
138 |
className={classNames(
|
|
|
2 |
import { useState } from "react";
|
3 |
import classNames from "classnames";
|
4 |
import { toast } from "react-toastify";
|
5 |
+
|
6 |
|
7 |
|
8 |
import SpaceIcon from "@/assets/space.svg";
|
|
|
75 |
}
|
76 |
};
|
77 |
|
78 |
+
const downloadFile = (filename: string, content: string) => {
|
79 |
+
const blob = new Blob([content], { type: "text/html" });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
const url = URL.createObjectURL(blob);
|
81 |
const a = document.createElement("a");
|
82 |
a.href = url;
|
83 |
+
a.download = filename;
|
|
|
|
|
|
|
84 |
a.click();
|
85 |
+
URL.revokeObjectURL(url);
|
86 |
};
|
87 |
|
88 |
return (
|
|
|
112 |
{path ? "Update Space" : "Deploy to Space"}
|
113 |
</button>
|
114 |
<div className="pt-2 text-right">
|
115 |
+
|
116 |
<button
|
117 |
+
className="mt-2 rounded-full bg-gray-800 px-5 py-2 text-white font-semibold text-xs hover:bg-gray-700 transition-all duration-100"
|
118 |
+
onClick={() => downloadFile("index.html", html)}
|
119 |
+
>
|
120 |
+
Download index.html
|
121 |
+
</button>
|
|
|
122 |
|
123 |
<div
|
124 |
className={classNames(
|