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
@@ -35,6 +35,8 @@ export default defineEventHandler(async (event) => {
|
||||
cinemas: Array.from(bySlug.values()),
|
||||
site: current.site,
|
||||
about: current.about,
|
||||
forCinemas: current.forCinemas,
|
||||
forFilmLovers: current.forFilmLovers,
|
||||
};
|
||||
await writeContent(next);
|
||||
return { imported: incoming.length, store: next };
|
||||
|
||||
@@ -5,17 +5,21 @@ import {
|
||||
readContent,
|
||||
sanitizeAbout,
|
||||
sanitizeCinemas,
|
||||
sanitizeForCinemas,
|
||||
sanitizeForFilmLovers,
|
||||
sanitizeSite,
|
||||
writeContent,
|
||||
} from "@/lib/content.server";
|
||||
|
||||
/** บันทึกทั้งชุด: ส่งมาเฉพาะส่วนที่แก้ได้ (cinemas, site และ/หรือ about) */
|
||||
/** บันทึกทั้งชุด: ส่งมาเฉพาะส่วนที่แก้ได้ (cinemas, site, about และ/หรือ forCinemas) */
|
||||
export default defineEventHandler(async (event) => {
|
||||
requireAdmin(event);
|
||||
const body = (await readBody(event)) as {
|
||||
cinemas?: unknown;
|
||||
site?: unknown;
|
||||
about?: unknown;
|
||||
forCinemas?: unknown;
|
||||
forFilmLovers?: unknown;
|
||||
};
|
||||
const current = await readContent();
|
||||
|
||||
@@ -28,6 +32,14 @@ export default defineEventHandler(async (event) => {
|
||||
site: body?.site === undefined ? current.site : sanitizeSite(body.site),
|
||||
about:
|
||||
body?.about === undefined ? current.about : sanitizeAbout(body.about),
|
||||
forCinemas:
|
||||
body?.forCinemas === undefined
|
||||
? current.forCinemas
|
||||
: sanitizeForCinemas(body.forCinemas),
|
||||
forFilmLovers:
|
||||
body?.forFilmLovers === undefined
|
||||
? current.forFilmLovers
|
||||
: sanitizeForFilmLovers(body.forFilmLovers),
|
||||
};
|
||||
await writeContent(next);
|
||||
return next;
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/**
|
||||
* /robots.txt — สร้างสด ๆ ที่ชั้น Nitro เพื่อให้บรรทัด `Sitemap:` ชี้โดเมนจริงของ request
|
||||
* (ไฟล์ static ใน public/ ต้องฮาร์ดโค้ดโดเมน จึงย้ายมาเป็น route)
|
||||
*/
|
||||
import {
|
||||
defineEventHandler,
|
||||
getRequestHeaders,
|
||||
getRequestProtocol,
|
||||
setResponseHeader,
|
||||
} from "h3";
|
||||
|
||||
import { originFromHeaders } from "../../app/lib/request-origin";
|
||||
import { configuredOrigin } from "../../app/lib/site";
|
||||
|
||||
/** search engine ที่อนุญาตชัดเจน */
|
||||
const ALLOWED_ENGINES = [
|
||||
"Googlebot",
|
||||
"Bingbot",
|
||||
"DuckDuckBot",
|
||||
"Bravebot",
|
||||
"Applebot",
|
||||
];
|
||||
|
||||
/** AI crawler ที่ไม่อนุญาต (ฝึกโมเดล/สรุปเนื้อหา) */
|
||||
const AI_CRAWLERS = [
|
||||
"GPTBot",
|
||||
"OAI-SearchBot",
|
||||
"ChatGPT-User",
|
||||
"ClaudeBot",
|
||||
"Claude-Web",
|
||||
"anthropic-ai",
|
||||
"Google-Extended",
|
||||
"Applebot-Extended",
|
||||
"PerplexityBot",
|
||||
"Perplexity-User",
|
||||
"CCBot",
|
||||
"Bytespider",
|
||||
"Amazonbot",
|
||||
"meta-externalagent",
|
||||
"cohere-ai",
|
||||
"Diffbot",
|
||||
"ImagesiftBot",
|
||||
"Omgilibot",
|
||||
"Timpibot",
|
||||
"VelenPublicWebCrawler",
|
||||
"YouBot",
|
||||
];
|
||||
|
||||
/** ประกอบไฟล์ robots.txt จาก origin ของ request */
|
||||
export function buildRobotsTxt(origin: string): string {
|
||||
const lines: string[] = [
|
||||
"# robots.txt — AlterFlixHub",
|
||||
"# ค้นหาโรงหนังอิสระ/อาร์ตเฮาส์ในประเทศไทย",
|
||||
"",
|
||||
"# ── search engines (อนุญาตชัดเจน) ────────────────────────────────",
|
||||
];
|
||||
|
||||
for (const engine of ALLOWED_ENGINES) {
|
||||
lines.push(`User-agent: ${engine}`, "Allow: /", "");
|
||||
}
|
||||
|
||||
lines.push(
|
||||
"# ── ค่าเริ่มต้น: เปิดให้ index แต่ปิดส่วนที่ไม่ควรอยู่ในผลค้นหา ──",
|
||||
"User-agent: *",
|
||||
"Allow: /",
|
||||
"Disallow: /api/",
|
||||
"Disallow: /admin",
|
||||
"Disallow: /admin/login",
|
||||
"Disallow: /_agent-native/",
|
||||
"Disallow: /c/ # ลิงก์ย่อสำหรับแชร์ (302 ไปหน้าโรงหนังจริง)",
|
||||
"",
|
||||
"# ── AI crawlers: ไม่อนุญาตให้นำเนื้อหาไปใช้ ─────────────────────",
|
||||
"# (รวมถึงการฝึกโมเดล/สรุปเนื้อหาของผู้ให้บริการ AI)",
|
||||
);
|
||||
|
||||
for (const crawler of AI_CRAWLERS) {
|
||||
lines.push(`User-agent: ${crawler}`, "Disallow: /", "");
|
||||
}
|
||||
|
||||
lines.push(`Sitemap: ${origin.replace(/\/+$/, "")}/sitemap.xml`, "");
|
||||
return lines.join("\n");
|
||||
}
|
||||
|
||||
export default defineEventHandler((event) => {
|
||||
const origin =
|
||||
configuredOrigin() ||
|
||||
originFromHeaders(getRequestHeaders(event), getRequestProtocol(event));
|
||||
setResponseHeader(event, "Content-Type", "text/plain; charset=utf-8");
|
||||
setResponseHeader(event, "Cache-Control", "public, max-age=3600");
|
||||
return buildRobotsTxt(origin);
|
||||
});
|
||||
@@ -0,0 +1,39 @@
|
||||
/**
|
||||
* /sitemap.xml — จัดการที่ชั้น Nitro (ไม่ผ่านตัวเรนเดอร์ React)
|
||||
*
|
||||
* ทำไมไม่ใช้ React Router resource route: ตัว SSR handler ของ framework
|
||||
* ตอบ 404 ให้พาธที่ลงท้ายด้วยนามสกุลไฟล์ (.xml) แม้ route จะถูกประกาศไว้แล้ว
|
||||
* จึงประกาศที่ Nitro ตรง ๆ ให้ crawler ได้ XML เสมอโดยไม่ขึ้นกับ Accept header
|
||||
*/
|
||||
import {
|
||||
defineEventHandler,
|
||||
getRequestHeaders,
|
||||
getRequestProtocol,
|
||||
setResponseHeader,
|
||||
} from "h3";
|
||||
|
||||
import { readContent } from "../../app/lib/content.server";
|
||||
import { originFromHeaders } from "../../app/lib/request-origin";
|
||||
import { configuredOrigin } from "../../app/lib/site";
|
||||
import { buildSitemapXml } from "../../app/lib/sitemap";
|
||||
|
||||
export default defineEventHandler(async (event) => {
|
||||
// โดเมนมาจาก request จริง (ไม่ฝังในโค้ด) — ตั้ง SITE_URL เฉพาะกรณีต้องบังคับ
|
||||
const origin =
|
||||
configuredOrigin() ||
|
||||
originFromHeaders(getRequestHeaders(event), getRequestProtocol(event));
|
||||
|
||||
let xml: string;
|
||||
|
||||
try {
|
||||
const content = await readContent();
|
||||
xml = buildSitemapXml(origin, content.cinemas);
|
||||
} catch {
|
||||
// ข้อมูลอ่านไม่ได้ → ยังคืน sitemap ที่มีหน้า static (ดีกว่า 500)
|
||||
xml = buildSitemapXml(origin, []);
|
||||
}
|
||||
|
||||
setResponseHeader(event, "Content-Type", "application/xml; charset=utf-8");
|
||||
setResponseHeader(event, "Cache-Control", "public, max-age=3600");
|
||||
return xml;
|
||||
});
|
||||
Reference in new issue
Block a user