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:
Bkk1234 committed 2026-11-10 02:31:10 +07:00
1 parent 1e84023a44
commit 319c271d23
72 files changed
+4731 -765

No files matched your search

+11
View File
@@ -0,0 +1,11 @@
# ai.txt — AlterFlixHub
#
# ประกาศเจตนา: เนื้อหา ข้อความ รูปภาพ และข้อมูลโรงหนังบนเว็บไซต์นี้
# ไม่อนุญาตให้นำไปใช้ฝึก (train) ทำ fine-tune หรือสร้างโมเดลปัญญาประดิษฐ์
# รวมถึงการนำไปใช้เป็นคลังข้อมูลสำหรับคำตอบของระบบ AI โดยไม่ได้รับอนุญาตเป็นลายลักษณ์อักษร
#
# เว็บนี้ยังเปิดให้ search engine ปกติจัดทำดัชนีตามปกติ (ดู /robots.txt)
# สอบถามเรื่องการใช้เนื้อหา: ช่องทางติดต่อในส่วนท้ายของเว็บไซต์
User-Agent: *
Disallow: /
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

+21 -5
View File
@@ -2,19 +2,35 @@
"name": "AlterFlixHub",
"short_name": "AlterFlixHub",
"description": "ค้นหาโรงภาพยนตร์อิสระ ทางเลือกในการดูหนัง",
"start_url": "./",
"id": "/",
"lang": "th",
"dir": "ltr",
"start_url": "/",
"scope": "/",
"display": "standalone",
"display_override": ["standalone", "minimal-ui"],
"orientation": "any",
"background_color": "#0D0D0D",
"theme_color": "#0D0D0D",
"categories": ["entertainment", "travel"],
"icons": [
{
"src": "icon-192.svg",
"src": "/icon-192.png",
"sizes": "192x192",
"type": "image/svg+xml"
"type": "image/png",
"purpose": "any"
},
{
"src": "icon-512.svg",
"src": "/icon-512.png",
"sizes": "512x512",
"type": "image/svg+xml"
"type": "image/png",
"purpose": "any"
},
{
"src": "/icon-maskable-512.png",
"sizes": "512x512",
"type": "image/png",
"purpose": "maskable"
}
]
}
+80
View File
@@ -0,0 +1,80 @@
<!doctype html>
<html lang="th">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>ออฟไลน์อยู่ — AlterFlixHub</title>
<meta name="theme-color" content="#0D0D0D" />
<style>
:root {
color-scheme: dark;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
min-height: 100dvh;
display: grid;
place-items: center;
padding: 24px;
background:
radial-gradient(
380px 380px at 50% 0%,
rgba(143, 8, 8, 0.55),
transparent 70%
),
#0d0d0d;
color: #fff;
font-family:
"Inter Variable", Inter, "Noto Sans Thai", system-ui, sans-serif;
}
main {
max-width: 460px;
text-align: center;
}
.logo {
display: inline-block;
color: #8f0808;
font-size: 30px;
letter-spacing: -0.01em;
}
h1 {
margin: 20px 0 8px;
font-size: 22px;
line-height: 1.4;
}
p {
margin: 0 0 24px;
color: #b3b3b3;
font-size: 15px;
line-height: 1.7;
}
a {
display: inline-block;
padding: 12px 22px;
border-radius: 10px;
border: 1px solid #8f0808;
background: #8f0808;
color: #fff;
font-size: 15px;
text-decoration: none;
touch-action: manipulation;
}
a:focus-visible {
outline: 2px solid #d47272;
outline-offset: 3px;
}
</style>
</head>
<body>
<main>
<span class="logo">AlterFlixHub</span>
<h1>ตอนนี้ออฟไลน์อยู่</h1>
<p>
หน้าเว็บที่เคยเปิดไว้ยังดูได้ แต่ต้องต่ออินเทอร์เน็ตก่อนเพื่อโหลดข้อมูลโรงหนังชุดล่าสุด
</p>
<a href="/">ลองอีกครั้ง</a>
</main>
</body>
</html>
Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

+149
View File
@@ -0,0 +1,149 @@
/*
* Service worker ของ AlterFlixHub
*
* กลยุทธ์
* - หน้าเว็บ (navigate): network-first → ออฟไลน์ค่อยใช้แคชของหน้านั้น → สุดท้าย /offline.html
* - ไฟล์ static (/assets/*.js|css, รูป, ฟอนต์): cache-first แล้วอัปเดตแคชเบื้องหลัง
* - /api/* และของภายนอกโดเมน: ไม่แตะ (ข้อมูลต้องสด + เคารพความเป็นส่วนตัว)
* - activate: ลบแคชเวอร์ชันเก่าทั้งหมด (กันเคสค้างเวอร์ชัน — เคยมีแคช `alterflixhub-v1.2.0` ค้าง)
*
* เวลาปล่อยเวอร์ชันใหม่: เปลี่ยน VERSION — พอ SW ตัวใหม่ activate จะเก็บกวาดแคชเก่าให้เอง
*
* ตารางกลยุทธ์ (อ่านประกอบ fetch handler ด้านล่าง)
* | คำขอ | กลยุทธ์ |
* |-------------------------------------|------------------------------------------|
* | navigate (เปิดหน้า) | network-first → แคชของหน้านั้น → /offline.html |
* | /assets/* · รูป · ฟอนต์ (.png/.svg…) | cache-first + อัปเดตเบื้องหลัง |
* | /api/* · /__* · /sw.js | ไม่จัดการ (ปล่อยผ่านไปเครือข่าย) |
* | โดเมนอื่น (รูป hotlink) | ไม่จัดการ |
* | /app/* · /node_modules/* · /@* | ไม่จัดการ (โมดูลของ dev server) |
*/
const VERSION = "v2.0.1";
const PAGES_CACHE = `alterflixhub-pages-${VERSION}`;
const ASSETS_CACHE = `alterflixhub-assets-${VERSION}`;
/** ไฟล์ที่ต้องมีติดเครื่องไว้ตั้งแต่ก่อนออฟไลน์ครั้งแรก */
const PRECACHE = [
"/offline.html",
"/manifest.json",
"/icon-192.png",
"/icon-512.png",
"/favicon.svg",
];
self.addEventListener("install", (event) => {
event.waitUntil(
(async () => {
const cache = await caches.open(ASSETS_CACHE);
// ไฟล์ใดโหลดไม่ได้ (เช่นตอน dev ที่ยังไม่ build) ไม่ทำให้ install ล้มทั้งชุด
await Promise.all(
PRECACHE.map((url) => cache.add(url).catch(() => undefined)),
);
})(),
);
});
self.addEventListener("activate", (event) => {
event.waitUntil(
(async () => {
const keep = new Set([PAGES_CACHE, ASSETS_CACHE]);
const names = await caches.keys();
await Promise.all(
names
.filter((name) => !keep.has(name))
.map((name) => caches.delete(name)),
);
// เข้าคุมแท็บที่เปิดอยู่ทันที เพื่อไม่ให้ค้าง SW เวอร์ชันเก่า
await self.clients.claim();
})(),
);
});
self.addEventListener("message", (event) => {
if (event.data === "SKIP_WAITING") self.skipWaiting();
});
function isSameOrigin(url) {
return url.origin === self.location.origin;
}
function isStaticAsset(url) {
// ไม่แคชเส้นทางของ bundler/dev server (Vite เสิร์ฟโมดูลที่ /app, /node_modules, /@…)
if (
url.pathname.startsWith("/app/") ||
url.pathname.startsWith("/node_modules/") ||
url.pathname.startsWith("/@")
) {
return false;
}
if (url.pathname.startsWith("/assets/")) return true;
return /\.(?:js|mjs|css|woff2?|ttf|png|jpe?g|webp|avif|gif|svg|ico)$/i.test(
url.pathname,
);
}
self.addEventListener("fetch", (event) => {
const request = event.request;
if (request.method !== "GET") return;
let url;
try {
url = new URL(request.url);
} catch {
return;
}
if (!isSameOrigin(url)) return;
// ข้อมูลสด/ข้อมูลหลังบ้าน — ห้ามแคช
if (url.pathname.startsWith("/api/") || url.pathname.startsWith("/__"))
return;
if (url.pathname === "/sw.js") return;
if (request.mode === "navigate") {
event.respondWith(
(async () => {
try {
const fresh = await fetch(request);
if (fresh && fresh.ok) {
const cache = await caches.open(PAGES_CACHE);
cache.put(request, fresh.clone()).catch(() => undefined);
}
return fresh;
} catch {
const cached = await caches.match(request);
if (cached) return cached;
const offline = await caches.match("/offline.html");
return offline || Response.error();
}
})(),
);
return;
}
if (isStaticAsset(url)) {
event.respondWith(
(async () => {
const cache = await caches.open(ASSETS_CACHE);
const cached = await cache.match(request);
if (cached) {
// อัปเดตเบื้องหลัง (stale-while-revalidate) — ไม่หน่วงการแสดงผล
fetch(request)
.then((fresh) => {
if (fresh && fresh.ok)
cache.put(request, fresh).catch(() => undefined);
})
.catch(() => undefined);
return cached;
}
try {
const fresh = await fetch(request);
if (fresh && fresh.ok) {
cache.put(request, fresh.clone()).catch(() => undefined);
}
return fresh;
} catch {
return Response.error();
}
})(),
);
}
});