11<script setup lang="ts">
2- import { debounce } from ' perfect-debounce'
32import { SHOWCASED_FRAMEWORKS } from ' ~/utils/frameworks'
43
54const searchQuery = shallowRef (' ' )
6- const searchInputRef = useTemplateRef (' searchInputRef' )
7- const { focused : isSearchFocused } = useFocus (searchInputRef )
85
96async function search() {
10- const query = searchQuery .value .trim ()
11- if (! query ) return
12- await navigateTo ({
13- path: ' /search' ,
14- query: query ? { q: query } : undefined ,
15- })
16- const newQuery = searchQuery .value .trim ()
17- if (newQuery !== query ) {
18- await search ()
7+ if (! searchQuery .value ) {
8+ return
199 }
20- }
2110
22- const handleInput = isTouchDevice ()
23- ? search
24- : debounce (search , 250 , { leading: true , trailing: true })
11+ navigateTo ({
12+ name: ' search' ,
13+ query: {
14+ q: searchQuery .value ,
15+ },
16+ })
17+ }
2518
2619useSeoMeta ({
2720 title : () => $t (' seo.home.title' ),
@@ -66,12 +59,12 @@ defineOgImageComponent('Default', {
6659 class =" w-full max-w-xl motion-safe:animate-slide-up motion-safe:animate-fill-both"
6760 style =" animation-delay : 0.2s "
6861 >
69- <form method =" GET" action =" /search" class =" relative" @submit.prevent.trim =" search" >
62+ <form method =" GET" action =" /search" class =" relative" @submit.prevent =" search" >
7063 <label for =" home-search" class =" sr-only" >
7164 {{ $t('search.label') }}
7265 </label >
7366
74- <div class =" relative group" :class = " { 'is-focused': isSearchFocused } " >
67+ <div class =" relative group" >
7568 <div
7669 class =" absolute -inset-px rounded-lg bg-gradient-to-r from-fg/0 via-fg/5 to-fg/0 opacity-0 transition-opacity duration-500 blur-sm group-[.is-focused]:opacity-100"
7770 />
@@ -85,15 +78,13 @@ defineOgImageComponent('Default', {
8578
8679 <input
8780 id =" home-search"
88- ref =" searchInputRef"
89- v-model =" searchQuery"
81+ v-model.trim =" searchQuery"
9082 type =" search"
9183 name =" q"
9284 autofocus
9385 :placeholder =" $t('search.placeholder')"
9486 v-bind =" noCorrect"
9587 class =" w-full bg-bg-subtle border border-border rounded-xl ps-8 pe-24 h-14 py-4 font-mono text-base text-fg placeholder:text-fg-subtle transition-[border-color,outline-color] duration-300 motion-reduce:transition-none hover:border-fg-subtle outline-2 outline-transparent focus:border-accent focus-visible:(outline-2 outline-accent/70)"
96- @input =" handleInput"
9788 />
9889
9990 <button
0 commit comments