|
1 | 1 | <template> |
2 | 2 | <div> |
3 | | - <div class="md:block lg:block mx-auto text-gray-600 hidden"> |
| 3 | + <div class="md:block lg:block mx-auto text-gray-600 hidden"> |
| 4 | + <input |
| 5 | + class="border-2 border-gray-300 bg-white h-10 px-5 pr-16 rounded-lg text-sm focus:outline-none" |
| 6 | + autocomplete="off" |
| 7 | + type="search" |
| 8 | + name="search" |
| 9 | + v-model="searchQuery" |
| 10 | + placeholder="Search blog" |
| 11 | + /> |
4 | 12 |
|
5 | | - <input class="border-2 border-gray-300 bg-white h-10 px-5 pr-16 rounded-lg text-sm focus:outline-none" |
6 | | - |
7 | | - autocomplete="off" type="search" name="search" v-model="searchQuery" placeholder="Search blog"> |
8 | | - |
9 | | - <button type="submit" class="absolute right-10 mt-3 mr-4"> |
10 | | -<svg v-show="searchQuery" class="text-gray-600 h-4 w-4 fill-current text-1xl" @click="searchQuery = ''" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor"> <path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd" /> </svg> |
11 | | - <svg v-show="!searchQuery" class="text-gray-600 h-4 w-4 fill-current" xmlns="http://www.w3.org/2000/svg" |
12 | | - |
13 | | - xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Capa_1" x="0px" y="0px" |
14 | | - |
15 | | - viewBox="0 0 56.966 56.966" style="enable-background:new 0 0 56.966 56.966;" xml:space="preserve" |
16 | | - |
17 | | - width="512px" height="512px"> |
18 | | - |
19 | | - <path |
20 | | - |
21 | | - d="M55.146,51.887L41.588,37.786c3.486-4.144,5.396-9.358,5.396-14.786c0-12.682-10.318-23-23-23s-23,10.318-23,23 s10.318,23,23,23c4.761,0,9.298-1.436,13.177-4.162l13.661,14.208c0.571,0.593,1.339,0.92,2.162,0.92 c0.779,0,1.518-0.297,2.079-0.837C56.255,54.982,56.293,53.08,55.146,51.887z M23.984,6c9.374,0,17,7.626,17,17s-7.626,17-17,17 s-17-7.626-17-17S14.61,6,23.984,6z" /> |
22 | | - |
23 | | - </svg> |
24 | | - |
25 | | - </button> |
26 | | - |
27 | | - </div> |
| 13 | + <button type="submit" class="absolute right-10 mt-3 mr-4"> |
| 14 | + <svg |
| 15 | + v-show="searchQuery" |
| 16 | + class="text-gray-600 h-4 w-4 fill-current text-1xl" |
| 17 | + @click="searchQuery = ''" |
| 18 | + xmlns="http://www.w3.org/2000/svg" |
| 19 | + viewBox="0 0 20 20" |
| 20 | + fill="currentColor" |
| 21 | + > |
| 22 | + <path |
| 23 | + fill-rule="evenodd" |
| 24 | + d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" |
| 25 | + clip-rule="evenodd" |
| 26 | + /> |
| 27 | + </svg> |
| 28 | + <svg |
| 29 | + v-show="!searchQuery" |
| 30 | + class="text-gray-600 h-4 w-4 fill-current" |
| 31 | + xmlns="http://www.w3.org/2000/svg" |
| 32 | + xmlns:xlink="http://www.w3.org/1999/xlink" |
| 33 | + version="1.1" |
| 34 | + id="Capa_1" |
| 35 | + x="0px" |
| 36 | + y="0px" |
| 37 | + viewBox="0 0 56.966 56.966" |
| 38 | + style="enable-background: new 0 0 56.966 56.966" |
| 39 | + xml:space="preserve" |
| 40 | + width="512px" |
| 41 | + height="512px" |
| 42 | + > |
| 43 | + <path |
| 44 | + d="M55.146,51.887L41.588,37.786c3.486-4.144,5.396-9.358,5.396-14.786c0-12.682-10.318-23-23-23s-23,10.318-23,23 s10.318,23,23,23c4.761,0,9.298-1.436,13.177-4.162l13.661,14.208c0.571,0.593,1.339,0.92,2.162,0.92 c0.779,0,1.518-0.297,2.079-0.837C56.255,54.982,56.293,53.08,55.146,51.887z M23.984,6c9.374,0,17,7.626,17,17s-7.626,17-17,17 s-17-7.626-17-17S14.61,6,23.984,6z" |
| 45 | + /> |
| 46 | + </svg> |
| 47 | + </button> |
| 48 | + </div> |
28 | 49 |
|
29 | 50 | <ul |
30 | 51 | v-if="articles.length" |
|
45 | 66 | export default { |
46 | 67 | data() { |
47 | 68 | return { |
48 | | - searchQuery: '', |
49 | | - articles: [] |
50 | | - } |
| 69 | + searchQuery: "", |
| 70 | + articles: [], |
| 71 | + }; |
51 | 72 | }, |
52 | 73 | watch: { |
53 | 74 | async searchQuery(searchQuery) { |
54 | 75 | if (!searchQuery) { |
55 | | - this.articles = [] |
56 | | - return |
| 76 | + this.articles = []; |
| 77 | + return; |
57 | 78 | } |
58 | | - this.articles = await this.$content('articles') |
| 79 | + this.articles = await this.$content("articles") |
59 | 80 | .limit(6) |
60 | 81 | .search(searchQuery) |
61 | | - .fetch() |
62 | | - } |
63 | | - } |
64 | | -} |
| 82 | + .fetch(); |
| 83 | + }, |
| 84 | + }, |
| 85 | +}; |
65 | 86 | </script> |
66 | 87 | <style> |
67 | | -input[type=search]::-ms-clear { display: none; width : 0; height: 0; } |
68 | | -input[type=search]::-ms-reveal { display: none; width : 0; height: 0; } |
| 88 | +input[type="search"]::-ms-clear { |
| 89 | + display: none; |
| 90 | + width: 0; |
| 91 | + height: 0; |
| 92 | +} |
| 93 | +input[type="search"]::-ms-reveal { |
| 94 | + display: none; |
| 95 | + width: 0; |
| 96 | + height: 0; |
| 97 | +} |
69 | 98 | /* clears the ‘X’ from Chrome */ |
70 | 99 | input[type="search"]::-webkit-search-decoration, |
71 | 100 | input[type="search"]::-webkit-search-cancel-button, |
72 | 101 | input[type="search"]::-webkit-search-results-button, |
73 | | -input[type="search"]::-webkit-search-results-decoration { display: none; } |
| 102 | +input[type="search"]::-webkit-search-results-decoration { |
| 103 | + display: none; |
| 104 | +} |
74 | 105 | </style> |
0 commit comments