Browse Source

Fix header.asp: move nav active-state logic out of function into simple vars

VBScript errors on Function defs mixed with executable code in same block.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
pull/5/head
Nano 6 days ago
parent
commit
b26c56ac2d
1 changed files with 18 additions and 14 deletions
  1. +18
    -14
      app/views/shared/header.asp

+ 18
- 14
app/views/shared/header.asp View File

@@ -13,20 +13,24 @@ If IsObject(CurrentController) Then
End If
On Error GoTo 0
End If

If Len(pageTitle) = 0 Then pageTitle = "BrainOrdure"

Dim currentPath
currentPath = LCase(Request.ServerVariables("HTTP_X_ORIGINAL_URL"))
If InStr(currentPath, "?") > 0 Then currentPath = Left(currentPath, InStr(currentPath, "?") - 1)
Dim hdr_path
hdr_path = LCase(Request.ServerVariables("HTTP_X_ORIGINAL_URL"))
If InStr(hdr_path, "?") > 0 Then hdr_path = Left(hdr_path, InStr(hdr_path, "?") - 1)

Function NavClass(ByVal prefix)
If Left(currentPath, Len(prefix)) = prefix Then
NavClass = "nav-link active"
Else
NavClass = "nav-link"
End If
End Function
Dim hdr_navHome, hdr_navPosts, hdr_navCats
hdr_navHome = "nav-link"
hdr_navPosts = "nav-link"
hdr_navCats = "nav-link"

If hdr_path = "/" Or hdr_path = "" Or Left(hdr_path, 5) = "/home" Then
hdr_navHome = "nav-link active"
ElseIf Left(hdr_path, 6) = "/posts" Then
hdr_navPosts = "nav-link active"
ElseIf Left(hdr_path, 11) = "/categories" Then
hdr_navCats = "nav-link active"
End If
%>
<html lang="en">
<head>
@@ -52,13 +56,13 @@ End Function
<div class="collapse navbar-collapse" id="mainNav">
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="<%= NavClass("/") %>" href="/">Home</a>
<a class="<%= hdr_navHome %>" href="/">Home</a>
</li>
<li class="nav-item">
<a class="<%= NavClass("/posts") %>" href="/posts">Posts</a>
<a class="<%= hdr_navPosts %>" href="/posts">Posts</a>
</li>
<li class="nav-item">
<a class="<%= NavClass("/categories") %>" href="/categories">Categories</a>
<a class="<%= hdr_navCats %>" href="/categories">Categories</a>
</li>
</ul>
</div>


Loading…
Cancel
Save

Powered by TurnKey Linux.