Skip to content

Commit 5580ef5

Browse files
committed
seprated navbar.html to /components
1 parent 3105a88 commit 5580ef5

File tree

2 files changed

+65
-63
lines changed

2 files changed

+65
-63
lines changed

templates/components/navbar.html

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<header class="header-area header-sticky">
2+
<div class="container">
3+
<div class="row">
4+
<div class="col-12">
5+
<nav class="main-nav">
6+
<!-- ***** Logo Start ***** -->
7+
<a href="{{ url_for('index.index') }}" class="logo">
8+
<img src="{{ url_for('static', filename='assets/images/logo.png') }}" alt="" />
9+
</a>
10+
<!-- ***** Logo End ***** -->
11+
<!-- ***** Search start ***** -->
12+
<div class="search-input">
13+
<form id="search" method="POST" action="{{ url_for('browse.browse_home') }}">
14+
<input type="text" placeholder="Search Courses" id="searchText" name="searchKeyword"
15+
value="{{ search_keyword }}" /> <!-- Display the search keyword if it was submitted -->
16+
<i type="submit" class="fa fa-search"></i>
17+
18+
</form>
19+
</div>
20+
<!-- ***** Search End ***** -->
21+
<!-- ***** Menu Start ***** -->
22+
<ul class="nav">
23+
<li>
24+
<a href="{{ url_for('index.index') }}" id="home">Home</a>
25+
</li>
26+
<li>
27+
<a href="{{ url_for('browse.browse_home') }}" id="browse">Browse</a>
28+
</li>
29+
<li>
30+
<a href="{{ url_for('login.login') }}" id="library">History</a>
31+
</li>
32+
<li onclick="window.open('https://github.com/sponsors/codeIntrovert', '_blank');">
33+
<img src="{{ url_for('static', filename='assets/images/SponsorButton.png') }}" alt="" />
34+
</li>
35+
36+
<!-- Add more items as required -->
37+
</ul>
38+
39+
<script>
40+
// Get the current page URL path
41+
var currentPath = window.location.pathname;
42+
43+
// Get the menu item with a matching URL and add the "active" class
44+
if (currentPath === "{{ url_for('index.index') }}") {
45+
document.getElementById("home").classList.add("active");
46+
} else if (
47+
currentPath === "{{ url_for('browse.browse_home') }}"
48+
) {
49+
document.getElementById("browse").classList.add("active");
50+
}
51+
else if (currentPath === "{{ url_for('login.login') }}") {
52+
document.getElementById("library").classList.add("active");
53+
}
54+
</script>
55+
56+
<a class="menu-trigger">
57+
<span>Menu</span>
58+
</a>
59+
<!-- ***** Menu End ***** -->
60+
</nav>
61+
</div>
62+
</div>
63+
</div>
64+
</header>

templates/layout.html

Lines changed: 1 addition & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -22,70 +22,8 @@
2222
<!-- ***** Preloader End ***** -->
2323

2424
<!-- ***** Header Area Start ***** -->
25-
<header class="header-area header-sticky">
26-
<div class="container">
27-
<div class="row">
28-
<div class="col-12">
29-
<nav class="main-nav">
30-
<!-- ***** Logo Start ***** -->
31-
<a href="{{ url_for('index.index') }}" class="logo">
32-
<img src="{{ url_for('static', filename='assets/images/logo.png') }}" alt="" />
33-
</a>
34-
<!-- ***** Logo End ***** -->
35-
<!-- ***** Search start ***** -->
36-
<div class="search-input">
37-
<form id="search" method="POST" action="{{ url_for('browse.browse_home') }}">
38-
<input type="text" placeholder="Search Courses" id="searchText" name="searchKeyword"
39-
value="{{ search_keyword }}" /> <!-- Display the search keyword if it was submitted -->
40-
<i type="submit" class="fa fa-search"></i>
41-
42-
</form>
43-
</div>
44-
<!-- ***** Search End ***** -->
45-
<!-- ***** Menu Start ***** -->
46-
<ul class="nav">
47-
<li>
48-
<a href="{{ url_for('index.index') }}" id="home">Home</a>
49-
</li>
50-
<li>
51-
<a href="{{ url_for('browse.browse_home') }}" id="browse">Browse</a>
52-
</li>
53-
<li>
54-
<a href="{{ url_for('login.login') }}" id="library">History</a>
55-
</li>
56-
<li onclick="window.open('https://github.com/sponsors/codeIntrovert', '_blank');">
57-
<img src="{{ url_for('static', filename='assets/images/SponsorButton.png') }}" alt="" />
58-
</li>
59-
60-
<!-- Add more items as required -->
61-
</ul>
62-
63-
<script>
64-
// Get the current page URL path
65-
var currentPath = window.location.pathname;
25+
{% include 'components/navbar.html' %}
6626

67-
// Get the menu item with a matching URL and add the "active" class
68-
if (currentPath === "{{ url_for('index.index') }}") {
69-
document.getElementById("home").classList.add("active");
70-
} else if (
71-
currentPath === "{{ url_for('browse.browse_home') }}"
72-
) {
73-
document.getElementById("browse").classList.add("active");
74-
}
75-
else if (currentPath === "{{ url_for('login.login') }}") {
76-
document.getElementById("library").classList.add("active");
77-
}
78-
</script>
79-
80-
<a class="menu-trigger">
81-
<span>Menu</span>
82-
</a>
83-
<!-- ***** Menu End ***** -->
84-
</nav>
85-
</div>
86-
</div>
87-
</div>
88-
</header>
8927
<!-- ***** Header Area End ***** -->
9028
<div class="container">
9129
<div class="row">

0 commit comments

Comments
 (0)