From 19882782f72184cecea8d9007ea1a68a88362071 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 14 Jun 2025 14:13:15 +0900 Subject: feat(blog/nuldoc): do not rebuild site for resource request --- vhosts/blog/nuldoc-src/commands/serve.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'vhosts/blog/nuldoc-src') diff --git a/vhosts/blog/nuldoc-src/commands/serve.ts b/vhosts/blog/nuldoc-src/commands/serve.ts index 67966760..e944aaf0 100644 --- a/vhosts/blog/nuldoc-src/commands/serve.ts +++ b/vhosts/blog/nuldoc-src/commands/serve.ts @@ -3,11 +3,25 @@ import { join } from "@std/path"; import { Config } from "../config.ts"; import { runBuildCommand } from "./build.ts"; +function isResourcePath(pathname: string): boolean { + const EXTENSIONS = [ + ".css", + ".gif", + ".ico", + ".jpeg", + ".jpg", + ".js", + ".png", + ".svg", + ]; + return EXTENSIONS.some((ext) => pathname.endsWith(ext)); +} + export function runServeCommand(config: Config) { const rootDir = join(Deno.cwd(), config.locations.destDir); Deno.serve({ hostname: "127.0.0.1" }, async (req) => { const pathname = new URL(req.url).pathname; - if (!pathname.endsWith("css") && !pathname.endsWith("svg")) { + if (!isResourcePath(pathname)) { await runBuildCommand(config); console.log("rebuild"); } -- cgit v1.2.3-70-g09d2