This commit is contained in:
eko 2025-11-27 21:30:39 +07:00
parent 0e85aa93a2
commit bcb8b5fa18
2 changed files with 30 additions and 1 deletions

View File

@ -17,6 +17,9 @@ export const _ = {
res.setHeader("Access-Control-Allow-Origin", "*"); res.setHeader("Access-Control-Allow-Origin", "*");
res.setHeader("Access-Control-Allow-Headers", "content-type"); res.setHeader("Access-Control-Allow-Headers", "content-type");
const gz = g.deploy.content; const gz = g.deploy.content;
const parts = req.params._.split("/"); const parts = req.params._.split("/");
const action = { const action = {
@ -57,6 +60,7 @@ export const _ = {
let layout = null as null | SinglePage; let layout = null as null | SinglePage;
for (const l of gz.layouts) { for (const l of gz.layouts) {
console.log(`[DEBUG] _prasi route layout: ${l.id}, content_tree: ${l.content_tree}`);
if (!layout) layout = l; if (!layout) layout = l;
if (l.is_default_layout) layout = l; if (l.is_default_layout) layout = l;
} }

View File

@ -311,7 +311,32 @@ export const deploy = {
console.error(`[ERROR] JSON content preview:`, metadataStr.substring(0, 200)); console.error(`[ERROR] JSON content preview:`, metadataStr.substring(0, 200));
throw new Error(`Invalid JSON in metadata.json: ${jsonError.message}`); throw new Error(`Invalid JSON in metadata.json: ${jsonError.message}`);
} }
} else if (entry.filename.startsWith('public/')) { }
else if (entry.filename === 'content/layout-content-trees.json') {
//inject content_tree to layouts
const layoutContentTrees = JSON.parse(new TextDecoder().decode(fileContent));
for (const layout of g.deploy.content.layouts) {
layout.content_tree = layoutContentTrees[layout.id];
}
console.log(`[DEBUG] ✓ Injected content_tree to ${g.deploy.content.layouts.length} layouts`);
}
else if(entry.filename === 'content/page-content-trees.json') {
//inject content_tree to pages
const pageContentTrees = JSON.parse(new TextDecoder().decode(fileContent));
for (const page of g.deploy.content.pages) {
page.content_tree = pageContentTrees[page.id];
}
console.log(`[DEBUG] ✓ Injected content_tree to ${g.deploy.content.pages.length} pages`);
}
else if(entry.filename === 'content/component-content-trees.json') {
//inject content_tree to components
const componentContentTrees = JSON.parse(new TextDecoder().decode(fileContent));
for (const comp of g.deploy.content.comps) {
comp.content_tree = componentContentTrees[comp.id];
}
console.log(`[DEBUG] ✓ Injected content_tree to ${g.deploy.content.comps.length} components`);
}
else if (entry.filename.startsWith('public/')) {
const relativePath = entry.filename.slice(7); // Remove 'public/' prefix const relativePath = entry.filename.slice(7); // Remove 'public/' prefix
const binaryExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.ico', '.svg', '.woff', '.woff2', '.ttf', '.eot', '.js', '.css', '.map']; const binaryExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.ico', '.svg', '.woff', '.woff2', '.ttf', '.eot', '.js', '.css', '.map'];
const isBinary = binaryExtensions.some(ext => relativePath.toLowerCase().endsWith(ext)); const isBinary = binaryExtensions.some(ext => relativePath.toLowerCase().endsWith(ext));