Skip to content

Commit 4822c2d

Browse files
authored
Merge pull request #245 from w3bdesign/development
Development
2 parents c9a247c + e91ae0a commit 4822c2d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

components/AlgoliaSearch/SearchResults.component.jsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@ import Link from 'next/link';
22

33
/**
44
* Displays search results from Algolia
5-
* @param {Object} props
5+
* @param {Object} hit {
6+
* @param {String} product_image Product image from WooCommerce
7+
* @param {String} product_name Name of product
8+
* @param {Float} regular_price Price without discount
9+
* @param {Float} sale_price Price when on sale
10+
* @param {Boolean} on_sale Is the product on sale? True or false
11+
* @param {String} short_description Short description of product
12+
* @param {Integer} objectID ID of product
13+
}
614
*/
715
const SearchResults = ({
816
hit: {
@@ -15,11 +23,14 @@ const SearchResults = ({
1523
objectID,
1624
},
1725
}) => {
26+
// Replace empty spaces with dash (-)
27+
const trimmedProductName = product_name.replace(/ /g, '-');
28+
1829
return (
1930
<article className="cursor-pointer hit">
2031
<Link
2132
href="/produkt/[post]"
22-
as={`/produkt/${product_name}?productId=${objectID}`}
33+
as={`/produkt/${trimmedProductName}?productId=${objectID}`}
2334
>
2435
<div className="flex p-6 bg-white">
2536
<header className="hit-image-container">
@@ -31,7 +42,7 @@ const SearchResults = ({
3142
</header>
3243
<div className="pl-4 text-left">
3344
{product_name && (
34-
<span class="text-lg font-bold">{product_name}</span>
45+
<span className="text-lg font-bold">{product_name}</span>
3546
)}
3647
<br />
3748
{on_sale && (

0 commit comments

Comments
 (0)