Skip to content

Commit 41f0911

Browse files
committed
Add JSDoc and improve search url
1 parent a4577dc commit 41f0911

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

components/AlgoliaSearch/SearchResults.component.jsx

Lines changed: 13 additions & 2 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">

0 commit comments

Comments
 (0)