Use shortcuts

This commit is contained in:
2024-06-30 01:00:15 +02:00
parent 9edf8f733a
commit fe9d154915

View File

@@ -10,23 +10,27 @@ const navs = [
{ {
label: 'home', label: 'home',
to: '/', to: '/',
icon: 'i-ph-house-line-duotone' icon: 'i-ph-house-line-duotone',
shortcut: 'h'
}, },
{ {
label: 'uses', label: 'uses',
to: '/uses', to: '/uses',
icon: 'i-ph-briefcase-duotone' icon: 'i-ph-briefcase-duotone',
shortcut: 'u'
}, },
{ {
label: 'writings', label: 'writings',
to: '/writings', to: '/writings',
icon: 'i-ph-newspaper-clipping-duotone' icon: 'i-ph-newspaper-clipping-duotone',
shortcut: 'w'
}, },
{ {
label: 'resume', label: 'resume',
to: config.public.cloud.resume, to: config.public.cloud.resume,
target: '_blank', target: '_blank',
icon: 'i-ph-address-book-duotone' icon: 'i-ph-address-book-duotone',
shortcut: 'r'
} }
] ]
@@ -40,6 +44,14 @@ async function toggleTheme() {
await new Promise(resolve => setTimeout(resolve, 500)) await new Promise(resolve => setTimeout(resolve, 500))
document.body.style.animation = '' document.body.style.animation = ''
} }
const router = useRouter()
defineShortcuts({
h: () => router.push('/'),
u: () => router.push('/uses'),
w: () => router.push('/writings'),
r: () => window.open(config.public.cloud.resume, '_blank')
})
</script> </script>
<template> <template>
@@ -55,24 +67,25 @@ async function toggleTheme() {
v-for="nav in navs" v-for="nav in navs"
:key="nav.label" :key="nav.label"
:text="nav.label" :text="nav.label"
:shortcuts="[nav.shortcut]"
> >
<UButton <UButton
:icon="nav.icon" :icon="nav.icon"
:target="nav.target ? nav.target : '_self'" :target="nav.target ? nav.target : '_self'"
:to="nav.to" :to="nav.to"
color="gray" color="gray"
dynamic
size="sm" size="sm"
variant="link" label=""
variant="solid"
/> />
</UTooltip> </UTooltip>
<ClientOnly> <ClientOnly>
<UTooltip text="switch theme"> <UTooltip text="switch theme">
<UButton <UButton
:icon="isDark ? 'i-ph-moon-duotone' : 'i-ph-sun-duotone'" :icon="isDark ? 'i-ph-moon-duotone' : 'i-ph-sun-duotone'"
variant="link" color="black"
color="gray"
size="sm" size="sm"
variant="solid"
@click="toggleTheme()" @click="toggleTheme()"
/> />
</UTooltip> </UTooltip>