fix menu system
This commit is contained in:
parent
62cd503704
commit
7e8297bb8b
22
app.js
22
app.js
@ -34,22 +34,20 @@ function loadMenuItems() {
|
|||||||
const content = fs.readFileSync(menuFile, 'utf-8');
|
const content = fs.readFileSync(menuFile, 'utf-8');
|
||||||
|
|
||||||
const menuItems = [];
|
const menuItems = [];
|
||||||
const titleRegex = /<!--\s*title:\s*(.*?)\s*-->/g;
|
const itemRegex = /<!--\s*title:\s*(.*?)\s*-->\s*(<!--\s*openNewPage\s*-->\s*)?<!--\s*url:\s*(.*?)\s*-->/g;
|
||||||
const urlRegex = /<!--\s*url:\s*(.*?)\s*-->/g;
|
|
||||||
const openNewPageRegex = /<!--\s*openNewPage\s*-->/g;
|
|
||||||
|
|
||||||
let titleMatch;
|
let match;
|
||||||
let urlMatch;
|
|
||||||
let openNewPageMatch;
|
|
||||||
|
|
||||||
// Use a loop to find and process each menu item
|
// Loop to find all menu items
|
||||||
while ((titleMatch = titleRegex.exec(content)) && (urlMatch = urlRegex.exec(content))) {
|
while ((match = itemRegex.exec(content)) !== null) {
|
||||||
openNewPageMatch = openNewPageRegex.exec(content);
|
const title = match[1];
|
||||||
|
const url = match[3];
|
||||||
|
const openNewPage = !!match[2]; // Check if openNewPage is present in the match
|
||||||
|
|
||||||
menuItems.push({
|
menuItems.push({
|
||||||
title: titleMatch[1],
|
title,
|
||||||
url: urlMatch[1],
|
url,
|
||||||
openNewPage: openNewPageMatch !== null // If openNewPage exists, set it to true
|
openNewPage
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
|
||||||
<!-- Main Content -->
|
<!-- Main Content -->
|
||||||
<header class="py-5">
|
<header class="py-5">
|
||||||
|
Loading…
Reference in New Issue
Block a user