Skip to content

Commit 8037974

Browse files
committed
fix typing issues & add guards for potential undefined types
1 parent 7f8174d commit 8037974

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

app/components/AppHeader.vue

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ const mobileLinks = computed<NavigationConfigWithGroups>(() => [
5252
name: 'About',
5353
label: $t('footer.about'),
5454
to: { name: 'about' },
55-
keyshortcut: null,
5655
type: 'link',
5756
external: false,
5857
iconClass: 'i-carbon:information',
@@ -61,7 +60,6 @@ const mobileLinks = computed<NavigationConfigWithGroups>(() => [
6160
name: 'Privacy Policy',
6261
label: $t('privacy_policy.title'),
6362
to: { name: 'privacy' },
64-
keyshortcut: null,
6563
type: 'link',
6664
external: false,
6765
iconClass: 'i-carbon:security',
@@ -81,7 +79,6 @@ const mobileLinks = computed<NavigationConfigWithGroups>(() => [
8179
label: $t('footer.docs'),
8280
href: 'https://docs.npmx.dev',
8381
target: '_blank',
84-
keyshortcut: null,
8582
type: 'link',
8683
external: true,
8784
iconClass: 'i-carbon:document',
@@ -91,7 +88,6 @@ const mobileLinks = computed<NavigationConfigWithGroups>(() => [
9188
label: $t('footer.source'),
9289
href: 'https://repo.npmx.dev',
9390
target: '_blank',
94-
keyshortcut: null,
9591
type: 'link',
9692
external: true,
9793
iconClass: 'i-carbon:logo-github',
@@ -101,7 +97,6 @@ const mobileLinks = computed<NavigationConfigWithGroups>(() => [
10197
label: $t('footer.social'),
10298
href: 'https://social.npmx.dev',
10399
target: '_blank',
104-
keyshortcut: null,
105100
type: 'link',
106101
external: true,
107102
iconClass: 'i-simple-icons:bluesky',
@@ -111,7 +106,6 @@ const mobileLinks = computed<NavigationConfigWithGroups>(() => [
111106
label: $t('footer.chat'),
112107
href: 'https://chat.npmx.dev',
113108
target: '_blank',
114-
keyshortcut: null,
115109
type: 'link',
116110
external: true,
117111
iconClass: 'i-carbon:chat',
@@ -176,7 +170,7 @@ onKeyStroke(
176170
}
177171
178172
for (const link of desktopLinks.value) {
179-
if (isKeyWithoutModifiers(e, link.keyshortcut)) {
173+
if (link.to && link.keyshortcut && isKeyWithoutModifiers(e, link.keyshortcut)) {
180174
e.preventDefault()
181175
navigateTo(link.to.name)
182176
break

app/components/Header/MobileMenu.client.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<script setup lang="ts">
22
import { useFocusTrap } from '@vueuse/integrations/useFocusTrap'
33
import { useAtproto } from '~/composables/atproto/useAtproto'
4+
import type { NavigationConfigWithGroups } from '~/types'
45
56
const isOpen = defineModel<boolean>('open', { default: false })
67
const { links } = defineProps<{
@@ -178,8 +179,12 @@ onUnmounted(deactivate)
178179

179180
<!-- Navigation links -->
180181
<div class="flex-1 overflow-y-auto overscroll-contain py-2">
181-
<template v-for="group in links">
182-
<div v-if="group.type === 'separator'" class="mx-4 my-2 border-t border-border" />
182+
<template v-for="(group, index) in links">
183+
<div
184+
v-if="group.type === 'separator'"
185+
:key="`seperator-${index}`"
186+
class="mx-4 my-2 border-t border-border"
187+
/>
183188

184189
<div v-if="group.type === 'group'" :key="group.name" class="p-2">
185190
<span
@@ -192,7 +197,7 @@ onUnmounted(deactivate)
192197
<NuxtLink
193198
v-for="link in group.items"
194199
:key="link.name"
195-
:to="link.to"
200+
:to="link.to?.name"
196201
:href="link.href"
197202
:target="link.target"
198203
class="flex items-center gap-3 px-3 py-3 rounded-md font-mono text-sm text-fg hover:bg-bg-subtle transition-colors duration-200"

0 commit comments

Comments
 (0)