formacao
This commit is contained in:
+20
-10
@@ -4,22 +4,30 @@ import { createPool } from "../../utils/concurrent.js";
|
||||
import { getExtension } from "../../utils/mime.js";
|
||||
import { SSG_CONTEXT, X_HONO_DISABLE_SSG_HEADER_KEY } from "./middleware.js";
|
||||
import { defaultPlugin } from "./plugins.js";
|
||||
import { dirname, filterStaticGenerateRoutes, isDynamicRoute, joinPaths } from "./utils.js";
|
||||
import {
|
||||
dirname,
|
||||
ensureWithinOutDir,
|
||||
filterStaticGenerateRoutes,
|
||||
isDynamicRoute,
|
||||
joinPaths
|
||||
} from "./utils.js";
|
||||
var DEFAULT_CONCURRENCY = 2;
|
||||
var DEFAULT_CONTENT_TYPE = "text/plain";
|
||||
var DEFAULT_OUTPUT_DIR = "./static";
|
||||
var generateFilePath = (routePath, outDir, mimeType, extensionMap) => {
|
||||
const extension = determineExtension(mimeType, extensionMap);
|
||||
let filePath;
|
||||
if (routePath.endsWith(`.${extension}`)) {
|
||||
return joinPaths(outDir, routePath);
|
||||
filePath = joinPaths(outDir, routePath);
|
||||
} else if (routePath === "/") {
|
||||
filePath = joinPaths(outDir, `index.${extension}`);
|
||||
} else if (routePath.endsWith("/")) {
|
||||
filePath = joinPaths(outDir, routePath, `index.${extension}`);
|
||||
} else {
|
||||
filePath = joinPaths(outDir, `${routePath}.${extension}`);
|
||||
}
|
||||
if (routePath === "/") {
|
||||
return joinPaths(outDir, `index.${extension}`);
|
||||
}
|
||||
if (routePath.endsWith("/")) {
|
||||
return joinPaths(outDir, routePath, `index.${extension}`);
|
||||
}
|
||||
return joinPaths(outDir, `${routePath}.${extension}`);
|
||||
ensureWithinOutDir(outDir, filePath);
|
||||
return filePath;
|
||||
};
|
||||
var parseResponseContent = async (response) => {
|
||||
const contentType = response.headers.get("Content-Type");
|
||||
@@ -39,6 +47,8 @@ var defaultExtensionMap = {
|
||||
"text/html": "html",
|
||||
"text/xml": "xml",
|
||||
"application/xml": "xml",
|
||||
"application/atom+xml": "xml",
|
||||
"application/rss+xml": "xml",
|
||||
"application/yaml": "yaml"
|
||||
};
|
||||
var determineExtension = (mimeType, userExtensionMap) => {
|
||||
@@ -110,7 +120,7 @@ var fetchRoutesContent = function* (app, beforeRequestHook, afterResponseHook, c
|
||||
}
|
||||
forGetInfoURLRequest = maybeRequest;
|
||||
}
|
||||
await pool.run(() => app.fetch(forGetInfoURLRequest));
|
||||
await pool.run(() => app.fetch(forGetInfoURLRequest, { [SSG_CONTEXT]: true }));
|
||||
if (!forGetInfoURLRequest.ssgParams) {
|
||||
if (isDynamicRoute(route.path)) {
|
||||
resolveGetInfo(void 0);
|
||||
|
||||
Reference in New Issue
Block a user