Files
klz-cables.com/.pnpm-store/v10/files/c0/97b23d905dc54adf2fe889925adef270955604aad564b9bc87dafc1d2507d0babfecd7d114e4da9a49608418877264c816c7aabfdc45d4892249c2ba06961b
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

35 lines
1.2 KiB
Plaintext

export const createBlocksMap = (data)=>{
const blocksMap = {};
Object.entries(data).forEach(([key, rows])=>{
if (key.startsWith('_blocks_') && Array.isArray(rows)) {
let blockType = key.replace('_blocks_', '');
const parsed = blockType.split('_');
if (parsed.length === 2 && Number.isInteger(Number(parsed[1]))) {
blockType = parsed[0];
}
rows.forEach((row)=>{
if ('_path' in row) {
if (!(row._path in blocksMap)) {
blocksMap[row._path] = [];
}
row.blockType = blockType;
blocksMap[row._path].push(row);
delete row._path;
}
});
delete data[key];
}
});
Object.entries(blocksMap).reduce((sortedBlocksMap, [path, blocks])=>{
sortedBlocksMap[path] = blocks.sort((a, b)=>{
if (typeof a._order === 'number' && typeof b._order === 'number') {
return a._order - b._order;
}
return 0;
});
return sortedBlocksMap;
}, {});
return blocksMap;
};
//# sourceMappingURL=createBlocksMap.js.map