Skip to content

Commit 6c47038

Browse files
authored
Fix TypeScript errors on nav components (#12)
- Remove unused `icons` object. - Force `route.pages.length` to a boolean.
1 parent 2cedfee commit 6c47038

2 files changed

Lines changed: 7 additions & 16 deletions

File tree

packages/astro/src/components/FooterNav.astro

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
---
22
import { Icon } from "astro-icon/components";
33
4-
const icons = {
5-
twitter: "twitter",
6-
facebook: "facebook",
7-
linkedin: "linkedin",
8-
github: "github",
9-
slack: "slack",
10-
meetup: "meetup",
11-
};
12-
134
const routes = [
145
[
156
"Resources",
@@ -44,7 +35,7 @@ const routes = [
4435
["https://www.meetup.com/sfcivictech/", "meetup", true],
4536
],
4637
],
47-
];
38+
] as const;
4839
// because of annoying differences between dev and build modes, due to this
4940
// behavior (https://github.com/withastro/astro/issues/5630), always remove
5041
// any trailing slash so currentPage can match the pages above

packages/astro/src/components/HeaderNav.astro

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ const currentPage = fullPath.slice(fullPath.lastIndexOf("/") + 1);
2929
</ul>
3030
<ul>
3131
{routes.map(route => (
32-
<li class={`nav-item ${route.pages?.length > 0 ? "dropdown" : ""}`}>
32+
<li class={`nav-item ${!!route.pages?.length ? "dropdown" : ""}`}>
3333
<a href={route.page} aria-current={currentPage === route.page ? "page" : false}>{route.label}</a>
34-
{route.pages?.length > 0 &&
34+
{!!route.pages?.length &&
3535
<div class="dropdown-content">
3636
{route.pages.map(page => (
3737
<a href={page.page} aria-current={currentPage === page.page ? "page" : false}>{page.label}</a>
@@ -54,7 +54,7 @@ const currentPage = fullPath.slice(fullPath.lastIndexOf("/") + 1);
5454
position: relative;
5555
display: inline-block;
5656
}
57-
57+
5858
.dropdown-content {
5959
display: none;
6060
position: absolute;
@@ -63,16 +63,16 @@ const currentPage = fullPath.slice(fullPath.lastIndexOf("/") + 1);
6363
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
6464
z-index: 1;
6565
}
66-
66+
6767
.dropdown-content a {
6868
color: black;
6969
padding: 12px 16px;
7070
text-decoration: none;
7171
display: block;
7272
}
73-
73+
7474
.dropdown:hover .dropdown-content {
7575
display: block;
7676
}
77-
77+
7878
</style>

0 commit comments

Comments
 (0)