Public
HTTP
Forked from willthereader/testWebsite
willthereader-personalwebsite.web.val.run
September 6, 2024
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/** @jsxImportSource https://esm.sh/hono@latest/jsx **/
import { Bringing_My_OCD_Online } from "https://esm.town/v/willthereader/Bringing_My_OCD_Online";
import { homepage } from "https://esm.town/v/willthereader/homepage";
import { projects } from "https://esm.town/v/willthereader/projects";
import { Time_Blindness_Loud_Calendar_via_iOS_shortcuts } from "https://esm.town/v/willthereader/Time_Blindness_Loud_Calendar_via_iOS_shortcuts";
import { Hono } from "npm:hono@3";
const app = new Hono();
// Add a middleware to include the viewport meta tag and additional CSS in all HTML responses
app.use("*", async (c, next) => {
await next();
if (c.res.headers.get("Content-Type")?.includes("text/html")) {
const html = await c.res.text();
const updatedHtml = html.replace(
"</head>",
`
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
@media screen and (max-width: 768px) and (orientation: portrait) {
body {
margin-left: 5%;
margin-right: 5%;
}
}
</style>
</head>`,
);
c.res = new Response(updatedHtml, c.res);
}
});
app.get("/", homepage);
app.get("/projects", projects);
app.get("/projects/Time_Blindness_Loud_Calendar_via_iOS_shortcuts", Time_Blindness_Loud_Calendar_via_iOS_shortcuts);
app.get("/projects/Bringing_My_OCD_Online", Bringing_My_OCD_Online);
export default app.fetch;
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
September 6, 2024