New to EJS. I want to make a conditional statement basically saying if I am on this directory path, then replace this link in my nav bar.
<%let url = window.document.URL;
if(!url.includes('prospects/index')) {%>
<li class="nav-item">
<a class="nav-link" href="/prospects">Targeted Prospects</a>
</li>
<% } else { %>
<li class="nav-item">
<a class="nav-link" href="/prospects/new">Add Prospects</a>
</li>
<% } %>
My res.render
module.exports.index = async (req, res) => {
const prospects = await Prospect.find({});
res.render('prospects/index', { prospects })
};
I was hoping to see when I'm on my route "prospects/index" I'll see "Add Prospects" and all other routes I'll see "Targeted Prospects." Is there a way to target that route in my if statement? Thanks!