diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-06-14 14:13:15 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-06-14 14:13:15 +0900 |
| commit | 19882782f72184cecea8d9007ea1a68a88362071 (patch) | |
| tree | fc5a2b0ea06388239f54ec97f99dc0afbfa925e8 /vhosts/blog/nuldoc-src | |
| parent | d99ad2c63916cc24f927974e30dcd9daa189978f (diff) | |
| download | nsfisis.dev-19882782f72184cecea8d9007ea1a68a88362071.tar.gz nsfisis.dev-19882782f72184cecea8d9007ea1a68a88362071.tar.zst nsfisis.dev-19882782f72184cecea8d9007ea1a68a88362071.zip | |
feat(blog/nuldoc): do not rebuild site for resource request
Diffstat (limited to 'vhosts/blog/nuldoc-src')
| -rw-r--r-- | vhosts/blog/nuldoc-src/commands/serve.ts | 16 |
1 files changed, 15 insertions, 1 deletions
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"); } |
