Enhance university-related components by adding logo support and improving search functionality. Introduced a new "logolar" script in package.json, updated KatalogArama to include rehber results, and integrated UniLogo component across various pages for better visual representation. Refactored UniversiteIcerik and TercihHaritasi to display logos conditionally, enhancing user experience. Additionally, made adjustments to styles and layout for improved responsiveness and clarity.
All checks were successful
Deploy / deploy (push) Successful in 16m24s
All checks were successful
Deploy / deploy (push) Successful in 16m24s
This commit is contained in:
30
src/lib/arama.ts
Normal file
30
src/lib/arama.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Katalog aramasının paylaşılan metin eşleştirme yardımcıları.
|
||||
* Hem /api/katalog-ara route'u hem de client'taki rehber araması kullanır —
|
||||
* iki taraf aynı normalize kurallarıyla eşleşmeli.
|
||||
*/
|
||||
|
||||
export function aramaNormalize(metin: string): string {
|
||||
return metin
|
||||
.toLocaleLowerCase("tr-TR")
|
||||
.replace(/ı/g, "i")
|
||||
.replace(/ş/g, "s")
|
||||
.replace(/ğ/g, "g")
|
||||
.replace(/ü/g, "u")
|
||||
.replace(/ö/g, "o")
|
||||
.replace(/ç/g, "c")
|
||||
.replace(/â/g, "a")
|
||||
.replace(/î/g, "i")
|
||||
.replace(/û/g, "u")
|
||||
.normalize("NFKD")
|
||||
.replace(/[̀-ͯ]/g, "");
|
||||
}
|
||||
|
||||
/** 0 = tam eşleşme, 1 = baş, 2 = kelime başı, 3 = geçiyor */
|
||||
export function eslesmePuani(ad: string, sorgu: string): number {
|
||||
const normalAd = aramaNormalize(ad);
|
||||
if (normalAd === sorgu) return 0;
|
||||
if (normalAd.startsWith(sorgu)) return 1;
|
||||
if (normalAd.split(/\s+/).some((kelime) => kelime.startsWith(sorgu))) return 2;
|
||||
return 3;
|
||||
}
|
||||
Reference in New Issue
Block a user