feat(home): ชั้นกรองที่ 1 — ประเภทโรงหนัง (ท้องถิ่น / อินดี้ / กลุ่มคนฉายหนัง)
- แถบกรองสองชั้นในแถวเดียว: ทั้งหมด → 3 ประเภท │ ยอดนิยม → หมวดภาพยนตร์เดิม
- เก็บประเภทที่ฟิลด์เดี่ยว cinema.venue_type (ค่าเดียว) + hasVenue()/filterCinemas({ venue })
- ย้าย "กลุ่มคนฉายหนัง" จาก categories ขึ้นชั้น 1 (ไม่ให้ปุ่มซ้ำ) · tag ยังอยู่และยังค้นหาเจอ
- เลือกได้ทีละชั้น: กดประเภทล้างหมวด / กดหมวดล้างประเภท / ทั้งหมดล้างทั้งคู่
- ปิด popularity path เมื่อกรองด้วยประเภท (กันจัดอันดับข้ามประเภท)
- หลังบ้าน: ช่อง "ประเภทโรงหนัง" ในหมวดข้อมูลหลัก + sanitize เฉพาะค่าใน VENUE_TYPES
- i18n: messages.venues (TH/EN) · override ได้ผ่าน site.terms
- scripts/set-venue-types.mjs จัดประเภท 29 โรง (15 ท้องถิ่น / 11 อินดี้ / 3 กลุ่มคนฉายหนัง) พร้อมสำรอง content.json
- tests: hasVenue + filterCinemas (165 ผ่าน) · sw v2.0.5 · DESIGN/AGENTS/README/admin-guide/api อัปเดต
This commit is contained in:
1 parent
2e794cd365
commit
1932098a1d
15 files changed
+362
-26
No files matched your search
+13
-2
@@ -11,7 +11,13 @@
|
||||
* 4) matchLevel + FIELD_WEIGHTS — ให้คะแนนความตรง
|
||||
* 5) scoreCinema / filterCinemas — รวมผลและเรียงจากตรงที่สุด
|
||||
*/
|
||||
import { hasCategory, type Cinema, type CinemaCategory } from "@/lib/cinemas";
|
||||
import {
|
||||
hasCategory,
|
||||
hasVenue,
|
||||
type Cinema,
|
||||
type CinemaCategory,
|
||||
type VenueType,
|
||||
} from "@/lib/cinemas";
|
||||
|
||||
/** อักขระล่องหนที่ติดมากับการคัดลอกข้อความ (zero-width, BOM) */
|
||||
const ZERO_WIDTH = /[\u200B-\u200D\u2060\uFEFF]/g;
|
||||
@@ -187,15 +193,20 @@ export function filterCinemas(
|
||||
{
|
||||
category,
|
||||
query,
|
||||
venue = null,
|
||||
tagLabels = {},
|
||||
}: {
|
||||
category: CinemaCategory;
|
||||
query: string;
|
||||
/** ชั้นกรองที่ 1 — ประเภทโรงหนัง (null = ทุกประเภท) */
|
||||
venue?: VenueType | null;
|
||||
/** ป้ายหมวดตามภาษาที่แสดงบนการ์ด (messages.tags) */
|
||||
tagLabels?: Record<string, string>;
|
||||
},
|
||||
): Cinema[] {
|
||||
const inCategory = cinemas.filter((cinema) => hasCategory(cinema, category));
|
||||
const inCategory = cinemas
|
||||
.filter((cinema) => hasVenue(cinema, venue))
|
||||
.filter((cinema) => hasCategory(cinema, category));
|
||||
const tokens = searchTokens(query);
|
||||
if (tokens.length === 0) return inCategory;
|
||||
|
||||
|
||||
Reference in new issue
Block a user