chore(publish): replace source tree with static export at repo root
Publish the prerendered static export (index.html, 404.html, cinema/,
c/, about/, for-cinemas/, for-film-lovers/, assets/, images/, og/,
sitemap.xml, robots.txt) as the site root and remove the React Router
+ Nitro source tree from this branch. Source remains available in
history at 0548772.
Note: public/sw.js here reports VERSION v2.0.5 while the removed source
tree (v2.1.0) was newer, and .gitignore was not carried over.
This commit is contained in:
1 parent
05487728a7
commit
e6c4ebff48
394 files changed
+3977
-37891
No files matched your search
@@ -1,39 +0,0 @@
|
||||
/**
|
||||
* /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