// PageNavigation.js - Reusable page navigation component // Creates the "On this page" / breadcrumb navigation card /** * Renders a page navigation card * @param {string} label - Label for the navigation (e.g., "On this page:", "Area Name:") * @param {Array} items - Array of navigation items: { text, href, active } * @returns {string} HTML string for the navigation card */ export function renderPageNavigation(label, items) { if (!items || items.length === 0) { return ''; } return `
${label} ${items.map((item, index) => { const activeClasses = item.active ? 'text-blue-600 font-semibold underline decoration-2 underline-offset-2' : 'text-gray-700 hover:text-blue-600'; return ` ${index > 0 ? '' : ''} ${item.text} `; }).join('')}
`; } /** * Convenience function for home page navigation */ export function renderHomeNavigation() { return renderPageNavigation('On this page:', [ { text: 'About', href: '/#about' }, { text: 'Recent Works', href: '/#recent-works' }, { text: 'Research Areas', href: '/#research-areas' }, { text: 'Team Members', href: '/#team' } ]); } /** * Convenience function for area page navigation * @param {string} areaId - Area identifier * @param {string} areaTitle - Area display title * @param {Array} topics - Array of topics: { id, navName } * @param {string} currentTopicId - Current topic ID (if any) */ export function renderAreaNavigation(areaId, areaTitle, topics, currentTopicId = null) { const items = [ { text: 'Overview', href: `/${areaId}`, active: currentTopicId === null }, ...topics.map(topic => ({ text: topic.navName, href: `/${areaId}/${topic.id}`, active: topic.id === currentTopicId })) ]; return renderPageNavigation(`${areaTitle}:`, items); }