110 lines
3.6 KiB
JavaScript
110 lines
3.6 KiB
JavaScript
const navItems = [
|
|
{ href: "/index.html", label: "Home", match: ["/index.html", "/"] },
|
|
{
|
|
href: "/about.html",
|
|
label: "About Us",
|
|
match: ["/about.html", "/the-founders.html", "/about-us-organizations.html"],
|
|
children: [
|
|
{ href: "/the-founders.html", label: "The Founders" },
|
|
{ href: "/about-us-organizations.html", label: "Organizations" },
|
|
],
|
|
},
|
|
{ href: "/videos.html", label: "Videos", match: ["/videos.html"] },
|
|
{
|
|
href: "/events.html",
|
|
label: "Events",
|
|
match: ["/events.html", "/services.html"],
|
|
children: [{ href: "/services.html", label: "Sunday Services" }],
|
|
},
|
|
{ href: "/speeches/", label: "Speeches", match: ["/speeches/"] },
|
|
{ href: "/contact.html", label: "Contact", match: ["/contact.html"] },
|
|
];
|
|
|
|
const sidebarItems = [
|
|
{ href: "/the-founders.html", label: "The Founders" },
|
|
{ href: "/services.html", label: "Sunday Services" },
|
|
{ href: "/contact.html", label: "Contact" },
|
|
{ href: "/speeches/", label: "Speeches" },
|
|
];
|
|
|
|
function isCurrent(pathname, item) {
|
|
return item.match.some((match) => {
|
|
if (match.endsWith("/")) {
|
|
if (match === "/") {
|
|
return pathname === "/";
|
|
}
|
|
return pathname.startsWith(match);
|
|
}
|
|
return pathname === match;
|
|
});
|
|
}
|
|
|
|
function renderNavItem(item, index, pathname) {
|
|
const current = isCurrent(pathname, item);
|
|
const classes = [
|
|
"menu-item",
|
|
item.children ? "menu-item-has-children" : "",
|
|
current ? "current-menu-item current_page_item" : "",
|
|
`menu-item-${index + 1}`,
|
|
]
|
|
.filter(Boolean)
|
|
.join(" ");
|
|
const aria = current ? ' aria-current="page"' : "";
|
|
const children = item.children
|
|
? `
|
|
<ul class="sub-menu">
|
|
${item.children
|
|
.map(
|
|
(child, childIndex) =>
|
|
`\t<li class="menu-item menu-item-${index + 1}-${childIndex + 1}"><a href="${child.href}"><span>${child.label}</span></a></li>`
|
|
)
|
|
.join("\n")}
|
|
</ul>`
|
|
: "";
|
|
|
|
return `<li class="${classes}"><a href="${item.href}"${aria}><span>${item.label}</span></a>${children}</li>`;
|
|
}
|
|
|
|
export function renderPrimaryNav(pathname) {
|
|
return `<nav id="access" class="jssafe" role="navigation">
|
|
|
|
\t\t\t\t\t<div class="skip-link screen-reader-text"><a href="#content" title="Skip to content">Skip to content</a></div>
|
|
\t<div class="menu"><ul id="prime_nav" class="menu">${navItems
|
|
.map((item, index) => renderNavItem(item, index, pathname))
|
|
.join("\n")}</ul></div>
|
|
\t\t\t</nav><!-- #access -->`;
|
|
}
|
|
|
|
export function renderSidebar() {
|
|
return `<div id="secondary" class="widget-area sidey" role="complementary">
|
|
\t\t
|
|
\t\t\t<ul class="xoxo">
|
|
\t\t\t\t\t\t\t\t<li id="nav_menu-2" class="widget-container widget_nav_menu"><div class="menu-menu-3-side-bar-menu-container"><ul id="menu-menu-3-side-bar-menu" class="menu">${sidebarItems
|
|
.map((item, index) => `<li class="menu-item menu-item-${index + 1}"><a href="${item.href}">${item.label}</a></li>`)
|
|
.join("\n")}
|
|
</ul></div></li>\t\t\t</ul>
|
|
|
|
\t\t\t
|
|
\t\t</div>`;
|
|
}
|
|
|
|
export function renderFooter() {
|
|
return `<footer id="footer" role="contentinfo">
|
|
\t\t<div id="colophon">
|
|
\t\t
|
|
\t\t\t
|
|
\t\t\t
|
|
\t\t</div><!-- #colophon -->
|
|
|
|
\t\t<div id="footer2">
|
|
\t\t\t<div id="footer2-inner">
|
|
\t\t\t\t<div id="site-copyright"><b>Family Federation for World Peace and Unification (FFWPU) Ireland</b>
|
|
<br>Charity no. CHY 6071 All Rights Reserved 2013</b> <br>
|
|
<a href="/speeches/" target="_blank">Speeches</a></div>\t<div style="text-align:center;padding:5px 0 2px;text-transform:uppercase;font-size:12px;margin:1em auto 0;">
|
|
\tFamily Federation for World Peace and Unification Ireland
|
|
\t</div><!-- #site-info -->
|
|
\t\t\t\t</div>
|
|
\t\t</div><!-- #footer2 -->
|
|
|
|
\t</footer><!-- #footer -->`;
|
|
}
|