UNPKG

vike

Version:

The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.

24 lines (23 loc) 1.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getPageConfigsRuntime = getPageConfigsRuntime; exports.getAllPageIds = getAllPageIds; const parseGlobResults_js_1 = require("./getPageFiles/parseGlobResults.js"); const getPageConfigUserFriendly_js_1 = require("./page-configs/getPageConfigUserFriendly.js"); const utils_js_1 = require("./utils.js"); function getPageConfigsRuntime(virtualFileExports) { const { pageFilesAll, pageConfigs, pageConfigGlobal } = (0, parseGlobResults_js_1.parseGlobResults)(virtualFileExports); const allPageIds = getAllPageIds(pageFilesAll, pageConfigs); // TODO/now: re-use this call, instead of calling it twice const globalConfig = (0, getPageConfigUserFriendly_js_1.getPageConfigGlobalUserFriendly)({ pageConfigGlobalValues: pageConfigGlobal.configValues }); const pageConfigsUserFriendly = Object.fromEntries(pageConfigs.map((pageConfig) => { return (0, getPageConfigUserFriendly_js_1.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 = (0, utils_js_1.unique)(fileIds); const allPageIds2 = pageConfigs.map((p) => p.pageId); return [...allPageIds, ...allPageIds2]; }