-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from gouz/renderWeb
Render web
- Loading branch information
Showing
12 changed files
with
9,671 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import html from "./render/index.html.txt"; | ||
import js from "./render/main.js.txt"; | ||
import css from "./render/main.css.txt"; | ||
import type { Options } from "./types"; | ||
|
||
export const render = (json: JSON, options?: Options) => { | ||
const server = Bun.serve({ | ||
port: 1337, | ||
async fetch(req) { | ||
const path = new URL(req.url).pathname; | ||
if (path === "/main.css") | ||
return new Response(css, { | ||
headers: { "content-type": "text/css" }, | ||
}); | ||
if (path === "/main.js") | ||
return new Response( | ||
` | ||
const exportJSON = ${JSON.stringify(json).replaceAll("\n", "<br>")} | ||
const options = ${JSON.stringify(options)}; | ||
${js} | ||
`.trim(), | ||
{ | ||
headers: { | ||
"Content-Type": "application/javascript", | ||
}, | ||
status: 200, | ||
} | ||
); | ||
return new Response(html, { | ||
headers: { | ||
"Content-Type": "text/html", | ||
}, | ||
status: 200, | ||
}); | ||
}, | ||
}); | ||
|
||
console.log("🍫 is listening on \x1b[1m\x1b[35;49m%s\x1b[0m", server.url); | ||
}; | ||
|
||
export default render; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="color-scheme" content="light dark" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css" | ||
/> | ||
<link rel="stylesheet" href="main.css" /> | ||
<title>CHoC</title> | ||
<script src="https://unpkg.com/showdown/dist/showdown.min.js"></script> | ||
</head> | ||
<body> | ||
<main class="container"> | ||
<h1></h1> | ||
<aside class="grid container"> | ||
<label> | ||
Categories: | ||
<select id="categories" onchange="window.filterTalks()"></select> | ||
</label> | ||
<label> | ||
Formats: | ||
<select id="formats" onchange="window.filterTalks()"></select> | ||
</label> | ||
<label> | ||
Speakers: | ||
<select id="speakers" onchange="window.filterTalks()"></select> | ||
</label> | ||
<label> | ||
Companies: | ||
<select id="companies" onchange="window.filterTalks()"></select> | ||
</label> | ||
</aside> | ||
<h2>Talks</h2> | ||
<section id="talks"></section> | ||
</main> | ||
<script src="main.js"></script> | ||
</body> | ||
</html> |
Oops, something went wrong.