Spaces:
Running
Running
| // Script to help transform page content for dynamic loading | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Process all pages to remove duplicate headers and footers | |
| // This is useful for direct page access (non-dynamic loading) | |
| // Check if this is a standalone page (not loaded via dynamic content) | |
| const isStandalonePage = !window.location.href.includes('?page='); | |
| if (!isStandalonePage) return; // Only process for direct access | |
| // For standalone pages, we'll keep their headers and footers | |
| // but add a back link to the home page | |
| // Find any navigation links | |
| const navLinks = document.querySelectorAll('header a, nav a'); | |
| navLinks.forEach(link => { | |
| // If it's a home link or empty link | |
| if (link.textContent.toLowerCase().includes('home') || link.getAttribute('href') === '#') { | |
| // Update it to go back to the main site | |
| link.setAttribute('href', 'index.html'); | |
| link.classList.add('home-link'); | |
| } | |
| }); | |
| // Add specific page styles for standalone view | |
| const styleElement = document.createElement('style'); | |
| styleElement.textContent = ` | |
| body.standalone-page { | |
| max-width: 1200px; | |
| margin: 0 auto; | |
| padding: 0 20px; | |
| } | |
| .back-to-home { | |
| display: inline-block; | |
| margin: 1rem 0; | |
| padding: 0.5rem 1rem; | |
| color: #1a365d; | |
| text-decoration: none; | |
| font-weight: 500; | |
| } | |
| .back-to-home:hover { | |
| text-decoration: underline; | |
| } | |
| `; | |
| document.head.appendChild(styleElement); | |
| // Check if it's a standalone page (directly accessed, not through dynamic loading) | |
| if (isStandalonePage && !document.body.classList.contains('index-page')) { | |
| document.body.classList.add('standalone-page'); | |
| // Add a back to home link at the top if it doesn't exist | |
| if (!document.querySelector('.back-to-home')) { | |
| const mainContent = document.querySelector('main') || document.body.firstElementChild; | |
| if (mainContent) { | |
| const backLink = document.createElement('a'); | |
| backLink.href = 'index.html'; | |
| backLink.className = 'back-to-home'; | |
| backLink.innerHTML = '<i class="fas fa-arrow-left mr-2"></i> Back to Home'; | |
| mainContent.parentNode.insertBefore(backLink, mainContent); | |
| } | |
| } | |
| } | |
| }); | |