From 4b267c6a59a5c70d164ef4a6440e6e124f1fae1c Mon Sep 17 00:00:00 2001 From: wearrrrr Date: Tue, 9 Jan 2024 14:28:36 -0600 Subject: [PATCH] Fix bug where UV would stop working after new page --- index.js | 4 +++ package.json | 3 ++- src/components/UVRegistrar.astro | 46 +++++++++++++++----------------- src/layouts/Layout.astro | 8 ++++++ src/pages/404.astro | 21 +++++++++++++++ src/pages/index.astro | 13 +++------ 6 files changed, 59 insertions(+), 36 deletions(-) create mode 100644 src/pages/404.astro diff --git a/index.js b/index.js index 3705bfc..1301d25 100644 --- a/index.js +++ b/index.js @@ -25,6 +25,10 @@ app.use(express.urlencoded({ app.use("/", express.static('dist/client/')); app.use(ssrHandler); +app.get('*', function(req, res){ + res.status(200).sendFile("404.html", {root: path.resolve("dist/client")}); +}); + server.on("request", (req, res) => { if (bareServer.shouldRoute(req)) { bareServer.routeRequest(req, res); diff --git a/package.json b/package.json index 10f406f..e307e5b 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,8 @@ "type": "module", "version": "0.0.1", "scripts": { - "start": "node ." + "start": "node .", + "build": "astro build" }, "dependencies": { "@astrojs/check": "^0.4.0", diff --git a/src/components/UVRegistrar.astro b/src/components/UVRegistrar.astro index d364e4c..3ddb556 100644 --- a/src/components/UVRegistrar.astro +++ b/src/components/UVRegistrar.astro @@ -1,31 +1,27 @@ - - - + + \ No newline at end of file + console.log("here") + + window.location.href = window.__uv$config.prefix + window.__uv$config.encodeUrl(url); + }); + + function isUrl(val = ''){ + if (/^http(s?):\/\//.test(val) || val.includes('.') && val.substr(0, 1) !== ' ') return true; + return false; + }; + \ No newline at end of file diff --git a/src/layouts/Layout.astro b/src/layouts/Layout.astro index 9e69dee..be2fc9b 100644 --- a/src/layouts/Layout.astro +++ b/src/layouts/Layout.astro @@ -52,4 +52,12 @@ body { ::-webkit-scrollbar { display: none; } +.main-content { + display: flex; + justify-content: center; + align-items: center; + flex-direction: column; + width: 100%; + height: 60vh; +} diff --git a/src/pages/404.astro b/src/pages/404.astro new file mode 100644 index 0000000..7387851 --- /dev/null +++ b/src/pages/404.astro @@ -0,0 +1,21 @@ +--- +import Footer from "../components/Footer.astro"; +import Header from "../components/Header.astro"; +import Layout from "../layouts/Layout.astro"; + +--- + + +
+
+

404!

+

The content you have requested could not be found!

+
+
+
+ + \ No newline at end of file diff --git a/src/pages/index.astro b/src/pages/index.astro index e66cd49..5fdb3a8 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -7,26 +7,19 @@ import UVRegistrar from '../components/UVRegistrar.astro';
-
+

Welcome to Alu

Loading Content...

- + +