Skip to content

Commit d098b24

Browse files
committed
style: Update styling for app navigation links based on active path
1 parent f226a78 commit d098b24

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/handler.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export async function getAppPageHandler(req: Request, res: Response) {
6363
return res.render('apps-id.html', {
6464
app,
6565
layout: '../layouts/app.html',
66+
path: `/apps/${app.id}`,
6667
});
6768
}
6869

@@ -75,6 +76,7 @@ export async function getAppChannelsPageHandler(req: Request, res: Response) {
7576
return res.render('apps-id-channels.html', {
7677
app,
7778
layout: '../layouts/app.html',
79+
path: `/apps/${app.id}/channels`,
7880
});
7981
}
8082

@@ -87,6 +89,7 @@ export async function getAppNotificationsPageHandler(req: Request, res: Response
8789
return res.render('apps-id-notifications.html', {
8890
app,
8991
layout: '../layouts/app.html',
92+
path: `/apps/${app.id}/notifications`,
9093
});
9194
}
9295

src/views/layouts/app.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ <h2 class="font-medium text-2xl">Apps / <%= app.id %></h2>
1717

1818
<aside>
1919
<ul class="menu bg-base-100 rounded-lg p-5">
20-
<li><a href="/apps/<%= app.id %>">App</a></li>
21-
<li><a href="/apps/<%= app.id %>/channels">Channels</a></li>
22-
<li><a href="/apps/<%= app.id %>/notifications">Notifications</a></li>
20+
<li><a class="<%= path === `/apps/${app.id}` ? 'active' : '' %>" href="/apps/<%= app.id %>">App</a></li>
21+
<li><a class="<%= /\/apps\/.*\/channels/.test(path) ? 'active' : '' %>" href="/apps/<%= app.id %>/channels">Channels</a></li>
22+
<li><a class="<%= /\/apps\/.*\/notifications/.test(path) ? 'active' : '' %>" href="/apps/<%= app.id %>/notifications">Notifications</a></li>
2323
</ul>
2424
</aside>
2525

0 commit comments

Comments
 (0)