This commit is contained in:
Rizky 2024-04-01 13:42:09 +07:00
parent afc77eec1e
commit 55d1d7376b
1 changed files with 8 additions and 1 deletions

View File

@ -4,6 +4,9 @@ import { gzipAsync } from "utils/gzip";
import { getContent } from "../server/prep-api-ts"; import { getContent } from "../server/prep-api-ts";
import mime from "mime"; import mime from "mime";
const cache = {
route: null as any,
};
export const _ = { export const _ = {
url: "/_prasi/**", url: "/_prasi/**",
async api() { async api() {
@ -32,13 +35,15 @@ export const _ = {
}, },
route: async () => { route: async () => {
if (gz) { if (gz) {
if (cache.route) return cache.route;
let layout = null as null | SinglePage; let layout = null as null | SinglePage;
for (const l of gz.layouts) { for (const l of gz.layouts) {
if (!layout) layout = l; if (!layout) layout = l;
if (l.is_default_layout) layout = l; if (l.is_default_layout) layout = l;
} }
return await responseCompressed( cache.route = await responseCompressed(
req, req,
JSON.stringify({ JSON.stringify({
site: { ...gz.site, api_url: (gz.site as any)?.config?.api_url }, site: { ...gz.site, api_url: (gz.site as any)?.config?.api_url },
@ -51,6 +56,8 @@ export const _ = {
}, },
}) })
); );
return cache.route;
} }
}, },
page: async () => { page: async () => {