fix menu system

This commit is contained in:
Raven Scott 2024-09-26 18:47:09 -04:00
parent 62cd503704
commit 7e8297bb8b
2 changed files with 11 additions and 12 deletions

22
app.js
View File

@ -34,22 +34,20 @@ function loadMenuItems() {
const content = fs.readFileSync(menuFile, 'utf-8');
const menuItems = [];
const titleRegex = /<!--\s*title:\s*(.*?)\s*-->/g;
const urlRegex = /<!--\s*url:\s*(.*?)\s*-->/g;
const openNewPageRegex = /<!--\s*openNewPage\s*-->/g;
const itemRegex = /<!--\s*title:\s*(.*?)\s*-->\s*(<!--\s*openNewPage\s*-->\s*)?<!--\s*url:\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
});
}

View File

@ -28,6 +28,7 @@
</div>
</nav>
<!-- Main Content -->
<header class="py-5">
<div class="container text-center">