Not found
用于在 404 错误时显示自定义页面的中间件。
配置参数
- root string
- Default:
"/vercel/path0/_site"
- page404 string
- Default:
"/404.html"
- directoryIndex boolean
- Default:
false
Description
此中间件在 404 错误时显示未找到页面。 可选地,它可以为文件夹创建 directoryIndex。
Installation
此中间件必须与 Lume 的 HTTP 服务器 一起使用。 要在生产环境中使用它,你需要一个运行 Deno 服务器的主机,例如 Deno Deploy。
创建一个入口点文件 (例如, serve.ts
),内容如下:
import Server from "lume/core/server.ts";
import notFound from "lume/middlewares/not_found.ts";
const server = new Server();
server.use(notFound({
page404: "/404.html", // 默认值
}));
server.start();
Local development
在 --serve
模式下,Lume 默认使用此中间件,并使用 page404
选项的值。