vike
Version:
The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.
22 lines (21 loc) • 1.32 kB
JavaScript
export { getPageConfigsRuntime };
export { getAllPageIds };
import { parseGlobResults } from './getPageFiles/parseGlobResults.js';
import { getPageConfigGlobalUserFriendly, getPageConfigUserFriendly } from './page-configs/getPageConfigUserFriendly.js';
import { unique } from './utils.js';
function getPageConfigsRuntime(virtualFileExports) {
const { pageFilesAll, pageConfigs, pageConfigGlobal } = parseGlobResults(virtualFileExports);
const allPageIds = getAllPageIds(pageFilesAll, pageConfigs);
// TODO/now: re-use this call, instead of calling it twice
const globalConfig = getPageConfigGlobalUserFriendly({ pageConfigGlobalValues: pageConfigGlobal.configValues });
const pageConfigsUserFriendly = Object.fromEntries(pageConfigs.map((pageConfig) => {
return getPageConfigUserFriendly(pageConfigGlobal.configValues, pageConfig, pageConfig.configValues);
}));
return { pageFilesAll, allPageIds, pageConfigs, pageConfigGlobal, globalConfig, pageConfigsUserFriendly };
}
function getAllPageIds(pageFilesAll, pageConfigs) {
const fileIds = pageFilesAll.filter(({ isDefaultPageFile }) => !isDefaultPageFile).map(({ pageId }) => pageId);
const allPageIds = unique(fileIds);
const allPageIds2 = pageConfigs.map((p) => p.pageId);
return [...allPageIds, ...allPageIds2];
}