update
This commit is contained in:
13
README.md
Normal file
13
README.md
Normal file
@@ -0,0 +1,13 @@
|
||||
This repo is for content hosted at djledda.net
|
||||
|
||||
The basic idea is that the `/app` folder contains shared files (in the root)
|
||||
and separate Vue apps (each folder) whose code doesn't need to be built and can
|
||||
be run in SSR mode or sent to the client directly, transpiled on the fly using
|
||||
Deno's built in transpilation API.
|
||||
|
||||
# Structure
|
||||
- `/app/` contains shared files and individual vue apps ('sites')
|
||||
- `/app/<site>/client.ts` is the javascript entry point for the client
|
||||
- `/app/<site>/server.ts` is the javascript entry point for the server
|
||||
- `/public/` contains static files publicly available using the same folder structure over HTTP
|
||||
- `/public/home` and `/app/home` will be remapped to root requests: a request to `/img/*` is retrieved from `/public/home/img/*`
|
||||
@@ -1,8 +1,8 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="icon" href="/home/icon.webp" />
|
||||
<link rel="icon" href="/home/img/dj.gif" />
|
||||
<link rel="icon" type="image/png" href="/favicon.png" sizes="256x256">
|
||||
<link rel="icon" type="image/png" href="/favicon-small.png" sizes="32x32">
|
||||
<link rel="stylesheet" href="/static/theme.css" />
|
||||
|
||||
<meta charset="utf-8">
|
||||
10
main.ts
10
main.ts
@@ -42,17 +42,19 @@ async function* siteEntries(path: string): AsyncGenerator<string> {
|
||||
for await (const dirEnt of Deno.readDir(path)) {
|
||||
if (dirEnt.isDirectory) {
|
||||
yield* siteEntries(join(path, dirEnt.name));
|
||||
} else if (dirEnt.name === "index_template.html") {
|
||||
} else if (dirEnt.name === "index.html") {
|
||||
yield path.split("/")[1] ?? "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const sites: string[] = [];
|
||||
for await (const entry of siteEntries("public")) {
|
||||
for await (const entry of siteEntries("app")) {
|
||||
sites.push(entry);
|
||||
}
|
||||
|
||||
console.log(sites);
|
||||
|
||||
async function getAPIResponse(apiReq: Request): Promise<Response> {
|
||||
let jsonResponse: DjAPIResult | { error: string } | null = null;
|
||||
let status = 200;
|
||||
@@ -109,7 +111,7 @@ async function getAPIResponse(apiReq: Request): Promise<Response> {
|
||||
}
|
||||
const result: DjAPIResultMap['/blog-entries'] = [];
|
||||
for (const filePath of paths) {
|
||||
const [ stat, content ] = await Promise.all([Deno.stat(filePath), Deno.readTextFile(filePath)]);
|
||||
const content = await Deno.readTextFile(filePath);
|
||||
const dom = parser.parseFromString(content, 'text/html');
|
||||
const metadata = {
|
||||
slug: '',
|
||||
@@ -225,7 +227,7 @@ Deno.serve({
|
||||
let baseDirectoryName = pathname.split("/")[1] ?? "";
|
||||
baseDirectoryName = baseDirectoryName === "" ? "home" : baseDirectoryName;
|
||||
if (sites.includes(baseDirectoryName)) {
|
||||
const siteTemplate = join("public", baseDirectoryName, "index_template.html");
|
||||
const siteTemplate = join("app", baseDirectoryName, "index.html");
|
||||
const siteEntry = join("app", baseDirectoryName, "server.ts");
|
||||
const clientEntry = join("@", baseDirectoryName, "client.ts");
|
||||
const { app, router } = (await import("./" + siteEntry)).default() as {
|
||||
|
||||
BIN
public/favicon-small.png
Normal file
BIN
public/favicon-small.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 80 KiB |
BIN
public/favicon.png
Normal file
BIN
public/favicon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 88 KiB |
0
public/manifest.json
Normal file
0
public/manifest.json
Normal file
Reference in New Issue
Block a user