update
This commit is contained in:
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 {
|
||||
|
||||
Reference in New Issue
Block a user