From 163773bdf237ba80a34a4a5366df826933f2cd8a Mon Sep 17 00:00:00 2001 From: unwox Date: Tue, 14 Oct 2025 13:07:48 +0600 Subject: improve products search --- pages/shop/index.fnl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'pages/shop') diff --git a/pages/shop/index.fnl b/pages/shop/index.fnl index 6b0f79b..58ff288 100644 --- a/pages/shop/index.fnl +++ b/pages/shop/index.fnl @@ -3,6 +3,7 @@ (local shop (require :shop)) (local dicts (require :dicts)) (local templates (require :templates)) +(local synonyms (require :synonyms)) (fn all-products [db filters authenticated?] (local where-stmts []) @@ -18,7 +19,10 @@ (when filters.search (table.insert where-stmts "products_search MATCH ?") - (table.insert where-args filters.search) + (var query (synonyms.replace filters.search)) + (when (not (lib.ends-with? query "*")) + (set query (.. query "*"))) + (table.insert where-args query) (set has-search-query? true)) (local where @@ -109,7 +113,7 @@ [:a {:style "white-space: nowrap; margin-left: 1rem;" :href (.. "/shop/order/list")} "☰ Список заказов"]]) "") - [:form {:class "d-flex gap-0-5 mb-1"} + [:form {:class "d-flex-desktop gap-0-5 mb-1"} [:input {:name "search" :type "search" :placeholder "Поиск" :value (or filters.search "")}] [:select {:name "type"} -- cgit v1.2.3