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,66 +0,0 @@
|
||||
/**
|
||||
* ตัวสร้าง sitemap.xml (ฟังก์ชันบริสุทธิ์ — ทดสอบได้โดยไม่ต้องมีเซิร์ฟเวอร์)
|
||||
*
|
||||
* หน้า static มาจาก `SITE.staticPages` · หน้าโรงหนังมาจากข้อมูลจริง
|
||||
* (ไม่รวมโรงที่ตั้ง `hidden: true` เพราะไม่ควรอยู่ในผลค้นหา)
|
||||
*/
|
||||
import type { Cinema } from "@/lib/cinemas";
|
||||
import { SITE } from "@/lib/site";
|
||||
|
||||
function escapeXml(value: string): string {
|
||||
return value
|
||||
.replace(/&/g, "&")
|
||||
.replace(/</g, "<")
|
||||
.replace(/>/g, ">")
|
||||
.replace(/"/g, """)
|
||||
.replace(/'/g, "'");
|
||||
}
|
||||
|
||||
/** ต่อพาธกับโดเมน — หน้าแรกต้องมี `/` ปิดท้าย */
|
||||
export function sitemapLocation(origin: string, path: string): string {
|
||||
const base = origin.replace(/\/+$/, "");
|
||||
if (path === "/" || path === "") return `${base}/`;
|
||||
return `${base}${path.startsWith("/") ? path : `/${path}`}`;
|
||||
}
|
||||
|
||||
function urlEntry(
|
||||
origin: string,
|
||||
path: string,
|
||||
options: { priority: string; changeFrequency: string },
|
||||
): string {
|
||||
return [
|
||||
" <url>",
|
||||
` <loc>${escapeXml(sitemapLocation(origin, path))}</loc>`,
|
||||
` <changefreq>${options.changeFrequency}</changefreq>`,
|
||||
` <priority>${options.priority}</priority>`,
|
||||
" </url>",
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
/** จำนวน URL สูงสุดต่อไฟล์ (ข้อกำหนด sitemap = 50,000) */
|
||||
export function buildSitemapXml(origin: string, cinemas: Cinema[]): string {
|
||||
const entries = SITE.staticPages.map((page) =>
|
||||
urlEntry(origin, page.path, {
|
||||
priority: page.priority,
|
||||
changeFrequency: page.changeFrequency,
|
||||
}),
|
||||
);
|
||||
|
||||
for (const cinema of cinemas) {
|
||||
if (cinema.hidden) continue;
|
||||
entries.push(
|
||||
urlEntry(origin, `/cinema/${cinema.slug}`, {
|
||||
priority: "0.8",
|
||||
changeFrequency: "weekly",
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
return [
|
||||
'<?xml version="1.0" encoding="UTF-8"?>',
|
||||
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">',
|
||||
...entries,
|
||||
"</urlset>",
|
||||
"",
|
||||
].join("\n");
|
||||
}
|
||||
Reference in new issue
Block a user