Files
web-alterflixhub/app/components/site/ArticlePage.tsx
T
Bkk1234 319c271d23 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 ไฟล์)
2026-11-10 02:31:10 +07:00

140 lines
5.0 KiB
TypeScript

import { IconArrowBackUp } from "@tabler/icons-react";
import { Link } from "react-router";
import { footerIcon } from "@/components/site/footer-icons";
import { Reveal } from "@/components/site/Reveal";
import { SiteShell } from "@/components/site/SiteShell";
import { useContent } from "@/lib/content-context";
import type { ArticleBlock, ArticleContent } from "@/lib/content-types";
/** บล็อกบทความหนึ่งชิ้น — ย่อหน้าหรือรูป (รูปมีคำบรรยายได้) */
function ArticleBlockView({
block,
index,
}: {
block: ArticleBlock;
index: number;
}) {
// ไล่จังหวะแบบสั้น ๆ แต่ไม่เกิน 3 บล็อกแรก (บล็อกท้าย ๆ จะได้ไม่รอนาน)
const delay = 100 + Math.min(index, 3) * 60;
if (block.type === "image") {
return (
<Reveal delay={delay}>
<figure className="flex flex-col gap-2">
<img
src={block.src}
alt={block.alt}
loading="lazy"
className="w-full rounded-xl bg-[#242424] object-cover"
/>
{block.caption ? (
<figcaption className="font-content text-[14px] leading-[1.7] text-[#999]">
{block.caption}
</figcaption>
) : null}
</figure>
</Reveal>
);
}
return (
<Reveal delay={delay}>
<p className="font-content max-w-[860px] text-[18px] leading-[1.95] text-[#C7C7C7] md:text-[20px]">
{block.text}
</p>
</Reveal>
);
}
/**
* โครงหน้าบทความที่ใช้ร่วมกัน (สำหรับคนทำโรงหนัง / สำหรับคนรักหนัง)
* ภาษาภาพเดียวกับหน้า "เกี่ยวกับเรา": กรอบ 1440 + px-[108px], ฟอนต์เนื้อหา IBM Plex Sans Thai Looped,
* การ์ดติดต่อไล่แดงขอบ rgba(169,38,38,0.45) และไอคอนโซเชียลชุดเดียวกับ footer
*/
export function ArticlePage({
content,
backLabel,
}: {
content: ArticleContent;
backLabel: string;
}) {
const { site } = useContent();
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">
<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} />
{backLabel}
</Link>
</Reveal>
<Reveal delay={40} className="flex flex-col gap-4">
<h1 className="text-[32px] font-bold leading-[1.3] md:text-[40px]">
{content.title}
</h1>
<p className="font-content max-w-[860px] text-[19px] leading-[1.8] text-[#C4C4C4] md:text-[21px]">
{content.lead}
</p>
</Reveal>
<article className="flex flex-col gap-7">
{content.blocks.map((block, index) => (
<ArticleBlockView
key={`${block.type}-${index}`}
block={block}
index={index}
/>
))}
</article>
<Reveal kind="fade">
<section
className="flex flex-col gap-6 rounded-xl p-6 backdrop-blur-sm lg:flex-row lg:items-center lg:justify-between"
style={{
border: "1px solid rgba(169,38,38,0.45)",
background:
"linear-gradient(180deg, rgba(143,8,8,0.18) 0%, rgba(27,27,27,0.85) 65%, rgba(13,13,13,0.7) 100%)",
}}
>
<div className="flex flex-col gap-3">
<h2 className="text-2xl font-semibold leading-[1.3]">
{content.contactHeading}
</h2>
<p className="font-content max-w-[720px] text-[16px] leading-[1.9] text-[#C4C4C4] md:text-[17px]">
{content.contactNote}
</p>
</div>
{site.footer.length > 0 ? (
<div className="flex flex-wrap items-center gap-2">
{site.footer.map((item) => {
const Icon = footerIcon(item.icon_name);
return (
<a
key={item.id}
href={item.href}
aria-label={item.label}
title={item.label}
target="_blank"
rel="noreferrer"
className="flex size-11 items-center justify-center rounded-full bg-white/90 text-[#0D0D0D] transition hover:bg-white"
>
<Icon size={20} />
</a>
);
})}
</div>
) : null}
</section>
</Reveal>
</main>
</SiteShell>
);
}