diff --git a/README.md b/README.md new file mode 100644 index 0000000..d6d4d2f --- /dev/null +++ b/README.md @@ -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//client.ts` is the javascript entry point for the client +- `/app//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/*` diff --git a/public/blog/index_template.html b/app/blog/index.html similarity index 100% rename from public/blog/index_template.html rename to app/blog/index.html diff --git a/public/generative-energy/index_template.html b/app/generative-energy/index.html similarity index 100% rename from public/generative-energy/index_template.html rename to app/generative-energy/index.html diff --git a/public/home/index_template.html b/app/home/index.html similarity index 68% rename from public/home/index_template.html rename to app/home/index.html index eecae32..6c1b43e 100644 --- a/public/home/index_template.html +++ b/app/home/index.html @@ -1,8 +1,8 @@ - - + + diff --git a/main.ts b/main.ts index 914812d..37b9204 100644 --- a/main.ts +++ b/main.ts @@ -42,17 +42,19 @@ async function* siteEntries(path: string): AsyncGenerator { 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 { let jsonResponse: DjAPIResult | { error: string } | null = null; let status = 200; @@ -109,7 +111,7 @@ async function getAPIResponse(apiReq: Request): Promise { } 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 { diff --git a/public/favicon-small.png b/public/favicon-small.png new file mode 100644 index 0000000..afdfcb2 Binary files /dev/null and b/public/favicon-small.png differ diff --git a/public/favicon.png b/public/favicon.png new file mode 100644 index 0000000..a27788a Binary files /dev/null and b/public/favicon.png differ diff --git a/public/manifest.json b/public/manifest.json new file mode 100644 index 0000000..e69de29