mirror of
https://github.com/codex-team/codex.docs.git
synced 2025-08-08 06:55:26 +02:00
move const
This commit is contained in:
parent
9a78c10f06
commit
a43c1fe930
1 changed files with 8 additions and 3 deletions
|
@ -2,8 +2,6 @@ const Pages = require('../../controllers/pages');
|
|||
const PagesOrder = require('../../controllers/pagesOrder');
|
||||
const asyncMiddleware = require('../../utils/asyncMiddleware');
|
||||
|
||||
const RootPage = '0';
|
||||
|
||||
/**
|
||||
* Process one-level pages list to parent-children list
|
||||
* @param {string[]} pages - list of all available pages
|
||||
|
@ -53,8 +51,15 @@ async function createMenuTree(pages, level = 1, currentLevel = 1) {
|
|||
* @param next
|
||||
*/
|
||||
module.exports = asyncMiddleware(async function (req, res, next) {
|
||||
/**
|
||||
* Pages without parent
|
||||
* @type {string}
|
||||
*/
|
||||
const parentIdOfRootPages = '0';
|
||||
|
||||
try {
|
||||
const rootPages = await PagesOrder.get(RootPage);
|
||||
const rootPages = await PagesOrder.get(parentIdOfRootPages);
|
||||
|
||||
res.locals.menu = await createMenuTree(rootPages.order, 2);
|
||||
} catch (error) {
|
||||
console.log('Can not load menu:', error);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue