feat: บทความ 2 หน้า + แชร์/ลิงก์ย่อ + PWA + แอนิเมชัน + SEO/AI + เอกสาร
- บทความจากหลังบ้าน: /for-film-lovers, /for-cinemas (ArticlePage + ArticleEditor แบบบล็อกย่อหน้า/รูป) - แชร์: ปุ่มบนการ์ดและท้ายหน้ารายละเอียด · ลิงก์ย่อ /c/<slug> (302) · ธีมแก้วตาม DESIGN.md - PWA: manifest/sw/offline + ถอดการล็อกซูม (WCAG 1.4.4) + touch target ≥44px - แอนิเมชัน reveal: IntersectionObserver + gate ด้วย html.fx-motion · เคารพ prefers-reduced-motion - ค้นหา: normalize/ตัดวรรณยุกต์ + AND หลายคำ + จัดอันดับ · รองรับ /?q= จาก SearchAction - SEO: pageMeta (canonical/OG/Twitter) + JSON-LD (WebSite/Organization/BreadcrumbList/MovieTheater/Article) - ไม่ฝังโดเมนในโค้ด: origin มาจาก request (x-forwarded-host/proto) ทั้ง canonical, sitemap, robots, ลิงก์แชร์ - กัน AI: robots.txt (Nitro route, บล็อก AI 21 ตัว) + ai.txt + OG image 1200x630 - เอกสาร: README สรุปโปรเจกต์, DESIGN.md (motion/PWA/SEO/ข้อมูล), architecture.html, admin-guide - tests: 135 ผ่าน (16 ไฟล์)
This commit is contained in:
1 parent
1e84023a44
commit
319c271d23
72 files changed
+4731
-765
No files matched your search
+146
-29
@@ -1,5 +1,5 @@
|
||||
import { useEffect } from "react";
|
||||
import { IconArrowBackUp } from "@tabler/icons-react";
|
||||
import { useEffect } from "react";
|
||||
import { Link, useParams } from "react-router";
|
||||
|
||||
import { CinemaNotFound } from "@/components/cinema/CinemaNotFound";
|
||||
@@ -9,35 +9,119 @@ import { FacilitiesSection } from "@/components/cinema/FacilitiesSection";
|
||||
import { Gallery } from "@/components/cinema/Gallery";
|
||||
import { TransportList } from "@/components/cinema/TransportList";
|
||||
import { CinemaGrid } from "@/components/site/CinemaGrid";
|
||||
import { Reveal } from "@/components/site/Reveal";
|
||||
import { ShareButton } from "@/components/site/ShareButton";
|
||||
import { SiteShell } from "@/components/site/SiteShell";
|
||||
import { useNearMe } from "@/hooks/use-near-me";
|
||||
import { APP_TITLE } from "@/lib/app-config";
|
||||
import { findCinemaBySlug, listOtherCinemas } from "@/lib/cinemas";
|
||||
import { readContent } from "@/lib/content.server";
|
||||
import { useContent } from "@/lib/content-context";
|
||||
import { trackEvent } from "@/lib/analytics-client";
|
||||
import { APP_TITLE } from "@/lib/app-config";
|
||||
import { findCinemaBySlug, cinemaName, listOtherCinemas } from "@/lib/cinemas";
|
||||
import { useContent } from "@/lib/content-context";
|
||||
import { readContent } from "@/lib/content.server";
|
||||
import { sortByDistance } from "@/lib/geo";
|
||||
import { useI18n } from "@/lib/i18n";
|
||||
import { DEFAULT_LOCALE, MESSAGES } from "@/lib/i18n/messages";
|
||||
import { resolvePageOrigin } from "@/lib/page-origin";
|
||||
import {
|
||||
breadcrumbJsonLd,
|
||||
cinemaJsonLd,
|
||||
originFromMatches,
|
||||
pageMeta,
|
||||
} from "@/lib/seo";
|
||||
|
||||
/** head (title) ไม่เปลี่ยนตามภาษา — meta() ไม่มี access ต่อ cookie */
|
||||
const HEAD_MESSAGES = MESSAGES[DEFAULT_LOCALE];
|
||||
|
||||
/** อ่านชื่อโรงหนังฝั่งเซิร์ฟเวอร์ เพื่อให้ <title> ถูกตั้งแต่ HTML แรก */
|
||||
export async function loader({ params }: { params: { slug?: string } }) {
|
||||
/** ฟิลด์ที่ต้องใช้ทำ SEO ของหน้าโรงหนัง (ส่งจาก loader เพื่อให้ crawler เห็นครบใน HTML แรก) */
|
||||
type CinemaSeo = {
|
||||
/** origin ของคำขอ (ไม่ฝังโดเมน) */
|
||||
origin: string;
|
||||
name: string | null;
|
||||
description: string | null;
|
||||
locationLabel: string | null;
|
||||
coordinates: { latitude: number; longitude: number } | null;
|
||||
mapUrl: string | null;
|
||||
photo: string | null;
|
||||
};
|
||||
|
||||
export async function loader({
|
||||
params,
|
||||
request,
|
||||
}: {
|
||||
params: { slug?: string };
|
||||
request: Request;
|
||||
}): Promise<CinemaSeo> {
|
||||
const content = await readContent();
|
||||
const cinema = findCinemaBySlug(content.cinemas, params.slug);
|
||||
return { name: cinema ? cinema.name : null };
|
||||
if (!cinema) {
|
||||
return {
|
||||
origin: resolvePageOrigin(request),
|
||||
name: null,
|
||||
description: null,
|
||||
locationLabel: null,
|
||||
coordinates: null,
|
||||
mapUrl: null,
|
||||
photo: null,
|
||||
};
|
||||
}
|
||||
return {
|
||||
origin: resolvePageOrigin(request),
|
||||
name: cinema.name,
|
||||
description: cinema.description.trim() === "" ? null : cinema.description,
|
||||
locationLabel: cinema.location_label || null,
|
||||
coordinates: cinema.coordinates,
|
||||
mapUrl: cinema.map_url,
|
||||
photo: cinema.photos.find((photo) => photo.trim() !== "") ?? null,
|
||||
};
|
||||
}
|
||||
|
||||
export function meta({ loaderData }: { loaderData?: { name?: string | null } }) {
|
||||
export function meta({
|
||||
loaderData,
|
||||
params,
|
||||
matches,
|
||||
}: {
|
||||
loaderData?: CinemaSeo;
|
||||
params?: { slug?: string };
|
||||
matches?: Array<{ id?: string; data?: unknown }>;
|
||||
}) {
|
||||
const origin = loaderData?.origin ?? originFromMatches(matches);
|
||||
const name = loaderData?.name ?? null;
|
||||
|
||||
if (!name) {
|
||||
return pageMeta({
|
||||
origin,
|
||||
title: `${HEAD_MESSAGES.meta.cinemaNotFoundTitle} — ${APP_TITLE}`,
|
||||
description: HEAD_MESSAGES.meta.cinemaNotFoundTitle,
|
||||
path: "/",
|
||||
noIndex: true,
|
||||
});
|
||||
}
|
||||
|
||||
const path = `/cinema/${params?.slug ?? ""}`;
|
||||
const location = loaderData?.locationLabel ?? "";
|
||||
const description =
|
||||
loaderData?.description ??
|
||||
`${name}${location ? ` — ${location}` : ""} · ที่ตั้ง วิธีเดินทาง สิ่งอำนวยความสะดวก และช่องทางจองตั๋ว`;
|
||||
const title = location
|
||||
? `${name} — ${location} | AlterFlixHub`
|
||||
: `${name} — AlterFlixHub`;
|
||||
|
||||
return [
|
||||
{
|
||||
title: name
|
||||
? `${name} — ${APP_TITLE}`
|
||||
: `${HEAD_MESSAGES.meta.cinemaNotFoundTitle} — ${APP_TITLE}`,
|
||||
},
|
||||
...pageMeta({ origin, title, description, path }),
|
||||
...breadcrumbJsonLd(origin, [
|
||||
{ name: "หน้าแรก", path: "/" },
|
||||
{ name, path },
|
||||
]),
|
||||
...cinemaJsonLd({
|
||||
origin,
|
||||
name,
|
||||
description,
|
||||
path,
|
||||
image: loaderData?.photo ?? null,
|
||||
coordinates: loaderData?.coordinates ?? null,
|
||||
locationLabel: location,
|
||||
mapUrl: loaderData?.mapUrl ?? null,
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
@@ -65,32 +149,65 @@ export default function CinemaDetailRoute() {
|
||||
return (
|
||||
<SiteShell variant="detail">
|
||||
<main className="relative z-10 mx-auto flex w-full max-w-[1440px] flex-col gap-10 px-5 pb-16 pt-4 md:px-[108px] md:pt-6">
|
||||
<Link
|
||||
to="/"
|
||||
className="inline-flex w-fit items-center gap-2 text-xl font-medium"
|
||||
>
|
||||
<IconArrowBackUp size={24} />
|
||||
{messages.detail.back}
|
||||
</Link>
|
||||
<Reveal kind="fade">
|
||||
<Link
|
||||
to="/"
|
||||
className="inline-flex w-fit items-center gap-2 text-xl font-medium transition hover:text-[#D47272]"
|
||||
>
|
||||
<IconArrowBackUp size={24} />
|
||||
{messages.detail.back}
|
||||
</Link>
|
||||
</Reveal>
|
||||
|
||||
<Gallery photos={cinema.photos} cinemaName={cinema.name} />
|
||||
<Reveal kind="zoom">
|
||||
<Gallery photos={cinema.photos} cinemaName={cinema.name} />
|
||||
</Reveal>
|
||||
|
||||
<section className="grid gap-10 lg:grid-cols-[minmax(0,749px)_minmax(0,384px)] lg:justify-between">
|
||||
<div className="flex flex-col gap-12">
|
||||
<CinemaSummary cinema={cinema} />
|
||||
<TransportList transport={cinema.transport} />
|
||||
<Reveal delay={60}>
|
||||
<CinemaSummary cinema={cinema} />
|
||||
</Reveal>
|
||||
<Reveal delay={120}>
|
||||
<TransportList transport={cinema.transport} />
|
||||
</Reveal>
|
||||
</div>
|
||||
<ContactPanel cinema={cinema} />
|
||||
<Reveal delay={160}>
|
||||
<ContactPanel cinema={cinema} />
|
||||
</Reveal>
|
||||
</section>
|
||||
|
||||
<FacilitiesSection cinema={cinema} />
|
||||
<Reveal>
|
||||
<FacilitiesSection cinema={cinema} />
|
||||
</Reveal>
|
||||
|
||||
<section className="flex flex-col gap-8">
|
||||
<h2 className="text-2xl font-semibold leading-[1.3]">
|
||||
{messages.detail.otherCinemas}
|
||||
</h2>
|
||||
<Reveal className="w-full">
|
||||
<h2 className="text-2xl font-semibold leading-[1.3]">
|
||||
{messages.detail.otherCinemas}
|
||||
</h2>
|
||||
</Reveal>
|
||||
<CinemaGrid cinemas={orderedOthers} source="other_cinemas" />
|
||||
</section>
|
||||
|
||||
{/* แชร์หน้ารายละเอียดโรงนี้ (ท้ายหน้า) */}
|
||||
<Reveal kind="fade">
|
||||
<section className="flex flex-wrap items-center justify-between gap-4 rounded-xl border border-[#332B2B] bg-[#1B1B1B]/70 p-5 backdrop-blur-sm">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2 className="text-lg font-semibold leading-[1.3]">
|
||||
{messages.share.pageLabel}
|
||||
</h2>
|
||||
<p className="text-sm text-[#B3B3B3]">
|
||||
{cinemaName(cinema, locale)}
|
||||
</p>
|
||||
</div>
|
||||
<ShareButton
|
||||
variant="wide"
|
||||
slug={cinema.slug}
|
||||
title={cinemaName(cinema, locale)}
|
||||
/>
|
||||
</section>
|
||||
</Reveal>
|
||||
</main>
|
||||
</SiteShell>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user