forked from snxraven/ravenscott-blog
Add open new page when configuring the menu
This commit is contained in:
parent
2d89dcddf6
commit
6e02e0219a
8
app.js
8
app.js
@ -36,14 +36,20 @@ function loadMenuItems() {
|
||||
const menuItems = [];
|
||||
const titleRegex = /<!--\s*title:\s*(.*?)\s*-->/g;
|
||||
const urlRegex = /<!--\s*url:\s*(.*?)\s*-->/g;
|
||||
const openNewPageRegex = /<!--\s*openNewPage\s*-->/g;
|
||||
|
||||
let titleMatch;
|
||||
let urlMatch;
|
||||
let openNewPageMatch;
|
||||
|
||||
// Use a loop to find and process each menu item
|
||||
while ((titleMatch = titleRegex.exec(content)) && (urlMatch = urlRegex.exec(content))) {
|
||||
openNewPageMatch = openNewPageRegex.exec(content);
|
||||
|
||||
menuItems.push({
|
||||
title: titleMatch[1],
|
||||
url: urlMatch[1]
|
||||
url: urlMatch[1],
|
||||
openNewPage: openNewPageMatch !== null // If openNewPage exists, set it to true
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<% menuItems.forEach(item => { %>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="<%= item.url %>"><%= item.title %></a>
|
||||
<a class="nav-link" href="<%= item.url %>" <%= item.openNewPage ? 'target="_blank"' : '' %>><%= item.title %></a>
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
|
@ -32,7 +32,7 @@
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<% menuItems.forEach(item => { %>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="<%= item.url %>"><%= item.title %></a>
|
||||
<a class="nav-link" href="<%= item.url %>" <%= item.openNewPage ? 'target="_blank"' : '' %>><%= item.title %></a>
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
|
@ -37,7 +37,7 @@
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<% menuItems.forEach(item => { %>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="<%= item.url %>"><%= item.title %></a>
|
||||
<a class="nav-link" href="<%= item.url %>" <%= item.openNewPage ? 'target="_blank"' : '' %>><%= item.title %></a>
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
|
@ -20,7 +20,7 @@
|
||||
<ul class="navbar-nav ms-auto">
|
||||
<% menuItems.forEach(item => { %>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="<%= item.url %>"><%= item.title %></a>
|
||||
<a class="nav-link" href="<%= item.url %>" <%= item.openNewPage ? 'target="_blank"' : '' %>><%= item.title %></a>
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
|
Loading…
Reference in New Issue
Block a user