Skip to content

Commit

Permalink
Underline the current section in the nav bar
Browse files Browse the repository at this point in the history
  • Loading branch information
dabreegster committed Aug 7, 2024
1 parent 23d6860 commit 51ed347
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/lib/nav/NavHeader.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

{#if navList}
<ol>
{#each navList as navItem}
{#each navList as [path, title, currentlyHere]}
<li>
<a href="{base}{navItem[0]}">{navItem[1]}</a>
<a href="{base}{path}" class:govuk-link--no-underline={!currentlyHere}>
{title}
</a>
</li>
{/each}
</ol>
Expand Down
11 changes: 7 additions & 4 deletions src/lib/nav/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,23 @@ export function getNextPage(
return result;
}

// Returns [path, title, currently here]
export function getNavList(
rawPath: string,
routeCheckType: "street" | "path" | "",
): [string, string][] | null {
): [string, string, boolean][] | null {
let path = getSectionPath(rawPath);
if (!path) {
return null;
}

let sections = filterMainPageSections(routeCheckType);
const toolName = path != "/" ? path.split("/")[1] : "";
return sections.filter((section) => {
return section[0] != "/" && section[0].split("/")[1] == toolName;
});
return sections
.filter((section) => {
return section[0] != "/" && section[0].split("/")[1] == toolName;
})
.map(([p, title]) => [p, title, p == path]);
}

export function canonicalizePath(path: string): string {
Expand Down

0 comments on commit 51ed347

Please sign in to comment.