Files
ukaiautomation/includes/nav.php
root edd491d680 Fix navbar across all pages: add nav include, fonts, active state, spacing, stats, error pages
- Add nav.php include to 5 missing pages (cost-calculator, thank-you, 403, 404, 500)
- Add ErrorDocument directives to .htaccess for custom 403/404/500 pages
- Fix bogus accuracy stats (homepage, web-scraping, location pages)
- Fix invisible CTA buttons on property and financial service pages
- Add Google Fonts (Roboto Slab + Lato) to all pages missing it (tools, blog articles, error pages)
- Add active nav link highlighting (teal underline for current page)
- Improve footer contrast to WCAG AA, equal-height cards, mobile text scaling
- Consistent navbar-to-content spacing across all pages
- Bump cache version to v1.1.3
2026-02-11 07:15:11 +00:00

43 lines
2.1 KiB
PHP

<?php
$current_path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$current_path = rtrim($current_path, '/');
if ($current_path === '') $current_path = '/';
function nav_active($href, $current) {
// Exact match
if ($href === $current) return ' active';
// Section match (e.g. /tools/ matches /tools/cost-calculator)
$href_trimmed = rtrim($href, '/');
if ($href_trimmed !== '' && $href_trimmed !== '/' && strpos($current, $href_trimmed) === 0) return ' active';
return '';
}
?>
<!-- Navigation -->
<nav class="navbar" id="navbar">
<div class="nav-container">
<div class="nav-logo">
<a href="/">
<picture>
<source srcset="/assets/images/ukds-main-logo.webp" type="image/webp">
<img src="/assets/images/ukds-main-logo.png" alt="UK Data Services" class="logo">
</picture>
</a>
</div>
<div class="nav-menu" id="nav-menu">
<a href="/" class="nav-link<?php echo $current_path === '/' ? ' active' : ''; ?>">Home</a>
<a href="/#services" class="nav-link<?php echo (strpos($current_path, '/services') === 0) ? ' active' : ''; ?>">Services</a>
<a href="/project-types" class="nav-link<?php echo nav_active('/project-types', $current_path); ?>">Project Types</a>
<a href="/about" class="nav-link<?php echo nav_active('/about', $current_path); ?>">About</a>
<a href="/tools/" class="nav-link<?php echo nav_active('/tools', $current_path); ?>">Free Tools</a>
<a href="/blog/" class="nav-link<?php echo nav_active('/blog', $current_path); ?>">Blog</a>
<a href="/#contact" class="nav-link">Contact</a>
<a href="/quote" class="nav-link cta-button<?php echo nav_active('/quote', $current_path); ?>">Request Consultation</a>
</div>
<button class="nav-toggle" id="nav-toggle" aria-expanded="false" aria-controls="nav-menu" aria-label="Toggle navigation menu">
<span class="bar"></span>
<span class="bar"></span>
<span class="bar"></span>
</button>
</div>
</nav>