Spaces:
Running
Running
File size: 2,541 Bytes
fb33344 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
// 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);
}
}
}
});
|