This repository has been archived on 2026-05-03. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
novarix-networks-homepage/node_modules/next/dist/esm/build/file-classifier.js
T
Kismet Hasanaj 34dc9aec52 .
2026-05-02 20:07:02 +02:00

54 lines
1.7 KiB
JavaScript

import { normalizeAppPath } from '../shared/lib/router/utils/app-paths';
import { isParallelRouteSegment } from '../shared/lib/segment';
/**
* Extract slot info from a page path if it contains a parallel route
*/ export function extractSlotFromPath(pagePath) {
const segments = pagePath.split('/');
for(let i = segments.length - 1; i >= 0; i--){
const segment = segments[i];
if (isParallelRouteSegment(segment)) {
return {
name: segment.slice(1),
parent: normalizeAppPath(segments.slice(0, i).join('/'))
};
}
}
return undefined;
}
/**
* Add a slot to the slots array if it doesn't already exist
*/ export function addSlotIfNew(slots, pagePath) {
const slot = extractSlotFromPath(pagePath);
if (!slot) return false;
if (slots.some((s)=>s.name === slot.name && s.parent === slot.parent)) return false;
slots.push(slot);
return true;
}
/**
* Extract slots from a route mapping object
*/ export function extractSlotsFromRoutes(routes, skipRoutes) {
const slots = [];
for (const [route] of Object.entries(routes)){
if (skipRoutes == null ? void 0 : skipRoutes.has(route)) continue;
addSlotIfNew(slots, route);
}
return slots;
}
/**
* Combine and deduplicate slot arrays
*/ export function combineSlots(...slotArrays) {
const slotSet = new Set();
const result = [];
for (const slots of slotArrays){
for (const slot of slots){
const key = `${slot.name}:${slot.parent}`;
if (!slotSet.has(key)) {
slotSet.add(key);
result.push(slot);
}
}
}
return result;
}
//# sourceMappingURL=file-classifier.js.map