Streaming live at 10am (PST)

Collection List Javascript


I am using Magic (How to Add Member Authentication on Webflow with Magic | Magic) to protect pages. I need to protect Collection Pages, there is some Javascript that looks at the current page and matches it to an array. But I do not have the skill to make the array a path and include all the pages in the Collection.

The array

let privatePages = [
‘/incidents/’, // This is the slug path to my collection…it works if I use the absolute URL /incidents/incident-1… but I need to know if I can use something like . to accept any collection page.

if (privatePages.includes(currentPath)) {

The current path is formed by

const currentPath = window.location.pathname;

I have tried many forms to get my array to match the window.location.pathname. Without success. I could easily do this in C, but I seem unable in Javascript (still a novice).

Anyone have any ideas.


Solved… contact me if you need to do the same thing.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.