Skip to content

Commit

Permalink
Fix highlight on current active page
Browse files Browse the repository at this point in the history
  • Loading branch information
Deflaktor committed Jun 24, 2024
1 parent 3210b2d commit 115b1cf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/components/navbar.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
const currentPagePath = Astro.url.pathname;
import { getPathnameWithoutExtension } from "~/lib/utils";
const currentPagePath = getPathnameWithoutExtension(Astro.url);
---

<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="/">
Expand Down
3 changes: 2 additions & 1 deletion src/layouts/boardsLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ interface Props {
title: string;
}
const { title } = Astro.props;
import { getPathnameWithoutExtension } from '~/lib/utils';
import Layout from './layout.astro';
import './layout.css';
import boards from "~/lib/getboards";
const currentPagePath = Astro.url.pathname;
const currentPagePath = getPathnameWithoutExtension(Astro.url);
---
<Layout title={title}>
<section class="jumbotron text-center">
Expand Down
6 changes: 6 additions & 0 deletions src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import path from "path";

export function getPathnameWithoutExtension(url: URL) {
const parsedPath = path.parse(url.pathname);
return path.join(parsedPath.dir, parsedPath.name);
}

0 comments on commit 115b1cf

Please sign in to comment.