one
Version:
One is a new React Framework that makes Vite serve both native and web.
95 lines (94 loc) • 2.42 kB
JavaScript
import * as React from "react";
import { usePathname, useRouter } from "../hooks.mjs";
import { Link } from "../link/Link.mjs";
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
function NoSSR({
children
}) {
const [render, setRender] = React.useState(false);
React.useEffect(() => {
setRender(true);
}, []);
return render ? /* @__PURE__ */jsx(Fragment, {
children
}) : null;
}
function CurrentURL() {
return /* @__PURE__ */jsx(Fragment, {
children: window.location.href
});
}
function Unmatched() {
const router = useRouter();
const pathname = usePathname();
return /* @__PURE__ */jsxs("main", {
style: {
minHeight: "100vh",
boxSizing: "border-box",
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
backgroundColor: "black",
color: "white",
padding: 24,
textAlign: "center"
},
children: [/* @__PURE__ */jsx("h1", {
style: {
fontSize: 36,
paddingBottom: 12,
margin: "0 0 12px",
borderBottom: "1px solid #323232"
},
children: "Unmatched Route"
}), /* @__PURE__ */jsxs("p", {
style: {
fontSize: 18,
margin: "0 0 12px"
},
children: ["Page could not be found.", " ", /* @__PURE__ */jsx("button", {
type: "button",
onClick: () => {
if (router.canGoBack()) {
router.back();
} else {
router.replace("/");
}
},
style: {
appearance: "none",
border: 0,
padding: 0,
background: "transparent",
color: "rgba(255,255,255,0.6)",
cursor: "pointer",
font: "inherit",
textDecoration: "underline"
},
children: "Go back."
})]
}), /* @__PURE__ */jsx(NoSSR, {
children: /* @__PURE__ */jsx(Link, {
href: pathname,
replace: true,
style: {
color: "rgba(255,255,255,0.4)",
textAlign: "center"
},
children: /* @__PURE__ */jsx(CurrentURL, {})
})
}), /* @__PURE__ */jsx(Link, {
href: "/_sitemap",
replace: true,
style: {
color: "rgba(255,255,255,0.4)",
marginTop: 8,
textAlign: "center"
},
children: "Sitemap"
})]
});
}
export { Unmatched };
//# sourceMappingURL=Unmatched.mjs.map