Skip to content

Commit

Permalink
Fix TypeScript errors on nav components (#12)
Browse files Browse the repository at this point in the history
- Remove unused `icons` object.
- Force `route.pages.length` to a boolean.
  • Loading branch information
fwextensions authored Feb 26, 2024
1 parent 2cedfee commit 6c47038
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 16 deletions.
11 changes: 1 addition & 10 deletions packages/astro/src/components/FooterNav.astro
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
---
import { Icon } from "astro-icon/components";
const icons = {
twitter: "twitter",
facebook: "facebook",
linkedin: "linkedin",
github: "github",
slack: "slack",
meetup: "meetup",
};
const routes = [
[
"Resources",
Expand Down Expand Up @@ -44,7 +35,7 @@ const routes = [
["https://www.meetup.com/sfcivictech/", "meetup", true],
],
],
];
] as const;
// because of annoying differences between dev and build modes, due to this
// behavior (https://github.com/withastro/astro/issues/5630), always remove
// any trailing slash so currentPage can match the pages above
Expand Down
12 changes: 6 additions & 6 deletions packages/astro/src/components/HeaderNav.astro
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ const currentPage = fullPath.slice(fullPath.lastIndexOf("/") + 1);
</ul>
<ul>
{routes.map(route => (
<li class={`nav-item ${route.pages?.length > 0 ? "dropdown" : ""}`}>
<li class={`nav-item ${!!route.pages?.length ? "dropdown" : ""}`}>
<a href={route.page} aria-current={currentPage === route.page ? "page" : false}>{route.label}</a>
{route.pages?.length > 0 &&
{!!route.pages?.length &&
<div class="dropdown-content">
{route.pages.map(page => (
<a href={page.page} aria-current={currentPage === page.page ? "page" : false}>{page.label}</a>
Expand All @@ -54,7 +54,7 @@ const currentPage = fullPath.slice(fullPath.lastIndexOf("/") + 1);
position: relative;
display: inline-block;
}

.dropdown-content {
display: none;
position: absolute;
Expand All @@ -63,16 +63,16 @@ const currentPage = fullPath.slice(fullPath.lastIndexOf("/") + 1);
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}

.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}

.dropdown:hover .dropdown-content {
display: block;
}

</style>

0 comments on commit 6c47038

Please sign in to comment.