Skip to content

Commit 0c47885

Browse files
committed
Display products in search and link to product page
1 parent ffcb656 commit 0c47885

File tree

1 file changed

+24
-8
lines changed

1 file changed

+24
-8
lines changed

pages/search.vue

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,44 @@
55
<ais-refinement-list attribute="brand" />
66
<ais-hits>
77
<template slot="item" slot-scope="{ item }">
8-
<p>
9-
<ais-highlight attribute="product_name" :hit="item" />
10-
</p>
11-
<p>
12-
<ais-highlight attribute="short_description" :hit="item" />
8+
<NuxtLink
9+
class="text-black cursor-pointer hover:underline"
10+
:to="{
11+
path: '/product/' + item.product_name,
12+
query: { id: item.objectID },
13+
}"
14+
>
15+
<p class="p-2 text-2xl font-bold text-center">
16+
{{ item.product_name }}
17+
</p>
18+
</NuxtLink>
19+
20+
<p class="p-2 text-xl text-center">
21+
{{ item.short_description }}
1322
</p>
14-
<p>
23+
<p class="p-2">
1524
<img :src="item.product_image" alt="item.product_name" />
1625
</p>
26+
<p class="p-2 text-xl text-center">
27+
{{ item.sale_price ? item.sale_price : item.regular_price }} kr
28+
</p>
1729
</template>
1830
</ais-hits>
1931
<ais-pagination />
2032
</ais-instant-search-ssr>
2133
</template>
2234

2335
<script>
36+
// TODO
37+
/*
38+
Replace empty spaces with dash (-)
39+
40+
const trimmedProductName = product_name.replace(/ /g, '-');
41+
*/
2442
import {
2543
AisInstantSearchSsr,
2644
AisRefinementList,
2745
AisHits,
28-
AisHighlight,
2946
AisSearchBox,
3047
AisStats,
3148
AisPagination,
@@ -44,7 +61,6 @@ export default {
4461
AisInstantSearchSsr,
4562
AisRefinementList,
4663
AisHits,
47-
AisHighlight,
4864
AisSearchBox,
4965
AisStats,
5066
AisPagination,

0 commit comments

Comments
 (0)