File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11<script setup lang="ts">
2+ import { debounce } from ' perfect-debounce'
3+
24withDefaults (
35 defineProps <{
46 showLogo? : boolean
@@ -22,13 +24,17 @@ const showSearchBar = computed(() => {
2224 return route .name !== ' search' && route .name !== ' index'
2325})
2426
25- async function handleSearchInput() {
27+ const debouncedNavigate = debounce ( async () => {
2628 const query = searchQuery .value .trim ()
2729 await router .push ({
2830 name: ' search' ,
2931 query: query ? { q: query } : undefined ,
3032 })
3133 searchQuery .value = ' '
34+ }, 100 )
35+
36+ async function handleSearchInput() {
37+ debouncedNavigate ()
3238}
3339
3440onKeyStroke (' ,' , e => {
Original file line number Diff line number Diff line change 11<script setup lang="ts">
2+ import { debounce } from ' perfect-debounce'
3+
24const router = useRouter ()
35const searchQuery = ref (' ' )
46const searchInputRef = useTemplateRef (' searchInputRef' )
57const { focused : isSearchFocused } = useFocus (searchInputRef )
68
7- function handleSearch() {
9+ const debouncedNavigate = debounce (() => {
810 router .push ({
911 path: ' /search' ,
1012 query: searchQuery .value .trim () ? { q: searchQuery .value .trim () } : undefined ,
1113 })
14+ }, 250 )
15+
16+ function handleSearch() {
17+ debouncedNavigate ()
1218}
1319
1420useSeoMeta ({
You can’t perform that action at this time.
0 commit comments