repos
/ orchard main

orchard

mirror

Every site I host, in one repo, along with the Cloudflare Tunnel and Caddy that front them. It's all Go, Vite, and SQLite, and it runs on a desktop at home with nothing listening on an inbound port.

blogbuncaddycloudflare-tunneldockergogolanghomelabhtml-templatemonorepoself-hostedseosqlitestatic-sitetypstuptime-monitoringviteweb-analytics

1.9 KB · 63 lines · JavaScript Raw History
 1// Entry point. Vite bundles this into one hashed .js and one hashed .css, and
 2// the Go server resolves both names out of dist/.vite/manifest.json. Every page
 3// is a real document, so all this does is dispatch on <body data-page>.
 4
 5import "./css/globals.css";
 6import "./css/components/page.css";
 7import "./css/components/grid.css";
 8import "./css/components/loader.css";
 9import "./css/components/cursor.css";
10import "./css/components/menu.css";
11import "./css/components/sidebar.css";
12import "./css/components/canvas.css";
13import "./css/pages/index.css";
14import "./css/pages/about.css";
15import "./css/pages/code.css";
16import "./css/pages/art.css";
17import "./css/pages/contact.css";
18
19import { initCursor } from "./js/cursor.js";
20import { initLoader } from "./js/loader.js";
21import { initMenu } from "./js/menu.js";
22
23import { initHome } from "./js/pages/index.js";
24import { initAbout } from "./js/pages/about.js";
25import { initArt } from "./js/pages/art.js";
26import { initContact } from "./js/pages/contact.js";
27
28const PAGES = {
29  index: initHome,
30  about: initAbout,
31  art: initArt,
32  contact: initContact,
33};
34
35// Each init is isolated. initLoader is what lifts the opening curtain, so a
36// throw anywhere else would leave the page under an opaque full-screen sheet.
37const run = (name, fn) => {
38  try {
39    fn();
40  } catch (err) {
41    console.error(name + " failed", err);
42  }
43};
44
45const start = () => {
46  // Loader first, since it is the one whose failure shows as a blank page.
47  run("loader", initLoader);
48  run("cursor", initCursor);
49  run("menu", initMenu);
50
51  const page = document.body.dataset.page;
52  if (PAGES[page]) run(page, PAGES[page]);
53};
54
55// The bundle is a module, so it is deferred and the DOM is already parsed by
56// the time it runs. The readyState check is only for the dev-server case where
57// it can be injected earlier.
58if (document.readyState === "loading") {
59  document.addEventListener("DOMContentLoaded", start);
60} else {
61  start();
62}