diff --git a/app.js b/app.js index 69936d8..e993f61 100644 --- a/app.js +++ b/app.js @@ -34,22 +34,20 @@ function loadMenuItems() { const content = fs.readFileSync(menuFile, 'utf-8'); const menuItems = []; - const titleRegex = //g; - const urlRegex = //g; - const openNewPageRegex = //g; + const itemRegex = /\s*(\s*)?/g; - let titleMatch; - let urlMatch; - let openNewPageMatch; + let match; - // Use a loop to find and process each menu item - while ((titleMatch = titleRegex.exec(content)) && (urlMatch = urlRegex.exec(content))) { - openNewPageMatch = openNewPageRegex.exec(content); + // Loop to find all menu items + while ((match = itemRegex.exec(content)) !== null) { + const title = match[1]; + const url = match[3]; + const openNewPage = !!match[2]; // Check if openNewPage is present in the match menuItems.push({ - title: titleMatch[1], - url: urlMatch[1], - openNewPage: openNewPageMatch !== null // If openNewPage exists, set it to true + title, + url, + openNewPage }); } diff --git a/views/index.ejs b/views/index.ejs index e6a74a9..64a34ab 100644 --- a/views/index.ejs +++ b/views/index.ejs @@ -27,6 +27,7 @@ +