Files
asphp/preview-server.mjs
2026-09-06 00:14:09 +03:30

255 lines
25 KiB
JavaScript

import { createReadStream } from "node:fs";
import { readFile } from "node:fs/promises";
import { createServer } from "node:http";
import { extname, join, normalize } from "node:path";
import { fileURLToPath } from "node:url";
import {
articles,
contact,
features,
heroSlides,
megaCategories,
products,
projectSteps,
services,
sourceBanners
} from "./app/data.js";
import { getStaticImageSlotMap, staticSlotImages } from "./app/meshkee.js";
const root = fileURLToPath(new URL(".", import.meta.url));
const hostname = process.env.HOSTNAME || "127.0.0.1";
const port = Number(process.env.PORT || 3000);
const css = await readFile(join(root, "app/globals.css"), "utf8");
const customerUrl = "https://customer.asphp.ir.com";
const staticSlots = await getStaticImageSlotMap("home");
const sliderImages = staticSlotImages(staticSlots, "slider", heroSlides);
const belowSliderBanners = staticSlotImages(staticSlots, "three-banner-below-slider", heroSlides.slice(1, 4)).slice(0, 3);
const specialSaleBanner = staticSlotImages(staticSlots, "special-sale-banner", ["/assets/banner-2.jpg"])[0];
const serverBanner = staticSlotImages(staticSlots, "server-banner", ["/assets/server-info-1.jpg"])[0];
const aboutusBanner = staticSlotImages(staticSlots, "aboutus-banner", ["/assets/server-info-1.jpg"])[0];
const threeBanners = staticSlotImages(staticSlots, "three-banner", sourceBanners).slice(0, 3);
const mime = {
".css": "text/css; charset=utf-8",
".jpg": "image/jpeg",
".jpeg": "image/jpeg",
".png": "image/png",
".ttf": "font/ttf"
};
function layout(title, body) {
return `<!doctype html>
<html lang="fa" dir="rtl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>${title}</title>
<meta name="description" content="خرید سرور HP، رم سرور، هارد سرور، CPU و تجهیزات شبکه از آریا شبکه پیشرو همراه با مشاوره تخصصی.">
<link rel="canonical" href="https://www.asphp.ir/">
<style>${css}</style>
</head>
<body>
${header()}
<main>${body}</main>
${footer()}
</body>
</html>`;
}
function header() {
const mega = `<div class="mega-title"><span>Categories</span><h3>خرید بر اساس دسته</h3></div><div class="mega-tabs">${megaCategories.map((group) => `<a href="#">${group.tab}</a>`).join("")}</div><div class="mega-columns">${megaCategories.map((group) => `<div><h4>${group.title}</h4>${group.items.map((item) => `<a href="#">${item}</a>`).join("")}</div>`).join("")}</div>`;
const phoneIcon = `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6.6 10.8c1.5 3 3.8 5.2 6.6 6.6l2.2-2.2c.3-.3.8-.4 1.2-.3 1.3.4 2.6.6 4 .6.7 0 1.2.5 1.2 1.2v3.5c0 .7-.5 1.2-1.2 1.2C10.3 22 2 13.7 2 3.4 2 2.7 2.5 2.2 3.2 2.2h3.5c.7 0 1.2.5 1.2 1.2 0 1.4.2 2.7.6 4 .1.4 0 .9-.3 1.2l-1.6 2.2Z" /></svg>`;
const instagramIcon = `<svg viewBox="0 0 24 24" aria-hidden="true"><rect x="4" y="4" width="16" height="16" rx="5" /><circle cx="12" cy="12" r="3.5" /><circle cx="17" cy="7" r="1" /></svg>`;
const searchIcon = `<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7" /><path d="m16.5 16.5 4 4" /></svg>`;
const cartIcon = `<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 4h2l2.2 11.2a2 2 0 0 0 2 1.6h7.6a2 2 0 0 0 2-1.5L21 7H6" /><circle cx="10" cy="20" r="1.3" /><circle cx="17" cy="20" r="1.3" /></svg>`;
const userIcon = `<svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="8" r="4" /><path d="M4 21c1.6-4.2 4.2-6.3 8-6.3s6.4 2.1 8 6.3" /></svg>`;
return `<header class="site-header">
<div class="container header-box">
<div class="topbar"><div class="topbar-inner">
<div class="header-tools"><a class="login user-login" href="${customerUrl}">${userIcon}ورود</a><details class="cart-menu"><summary aria-label="سبد خرید">${cartIcon}<span class="cart-badge">0</span></summary><div class="cart-popup"><h3>سبد خرید</h3><p>سبد خرید شما خالی است.</p></div></details></div>
<div class="topbar-links"><span class="top-icon" aria-label="تماس">${phoneIcon}</span><a href="tel:02177133934">02177133934</a><span>|</span><a href="tel:02177132293">02177132293</a><a class="top-icon" href="${contact.instagram}" aria-label="Instagram">${instagramIcon}</a></div>
</div></div>
<div class="nav-row">
<nav class="main-nav"><details class="category-menu"><summary><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 6h16M4 12h16M4 18h16" /></svg>دسته بندی ها</summary><div class="mega-menu">${mega}</div></details><a href="/store">فروشگاه</a><a href="/blog">مقالات</a><a href="/#special-sale">فروش ویژه</a><a href="/about-us">درباره ما</a><a href="/contact-us">تماس با ما</a></nav>
<details class="search-pop"><summary aria-label="جستجو">${searchIcon}</summary><form class="header-search" role="search"><input placeholder="جستجوی سرور، رم، هارد یا CPU" aria-label="جستجو"></form></details>
<a class="brand" href="/"><img src="/assets/logo.png" alt="آریا شبکه پیشرو" width="300" height="52"></a>
</div>
</div>
</header>`;
}
function footer() {
return `<footer class="footer"><div class="container footer-grid">
<div><img src="/assets/logo.png" alt="شرکت آریا شبکه پیشرو" width="263" height="45"><p>مارا در شبکه های اجتماعی دنبال کنید.</p><div class="socials"><a href="${contact.telegram}">Telegram</a><a href="${contact.instagram}">Instagram</a></div></div>
<div><h3>درباره ما</h3><p>آریا شبکه پیشرو شرکتی دانش بنیان، جوان و خلاق است. فعالیت مان را از سال ۱۳۹۵ با سرمایه ای اندک ولی با انگیزه سرشار و فکر و نیروی جوان آغاز کردیم. مجموعه ما در زمینه تامین تجهیزات شبکه از دو کمپانی HP و CISCO فعالیت دارد.</p></div>
<div><h3>تماس با ما</h3><a href="tel:88467222">88467222 (021)</a><a href="tel:22459734">22459734 (021)</a><p>${contact.address}</p></div>
<div><h3>صفحات</h3><a href="/">صفحه اصلی</a><a href="/about-us">درباره ما</a><a href="/contact-us">تماس با ما</a><a href="https://www.asphp.co/product-details/6232">خرید سرور اچ پی G9 DL380</a></div>
</div></footer>`;
}
function sectionTitle(fa, en, extra = "") {
return `<div class="section-title ${extra}"><span>${en}</span><h2>${fa}</h2></div>`;
}
function countdownMarkup() {
const unit = (name, label, value) => `<span class="flip-unit"><strong class="flip-card" data-unit="${name}" data-value="${value}">${value}</strong><small>${label}</small></span>`;
return `<div class="sale-countdown" data-countdown="sale" aria-label="زمان باقی مانده فروش ویژه"><span class="sale-countdown-label">پایان فروش ویژه</span>${unit("seconds", "ثانیه", "00")}${unit("minutes", "دقیقه", "00")}${unit("hours", "ساعت", "00")}${unit("days", "روز", "03")}</div>`;
}
function countdownScript() {
return `<script>
(() => {
const countdown = document.querySelector('[data-countdown="sale"]');
if (!countdown) return;
const target = Date.now() + 72 * 60 * 60 * 1000;
const set = (name, value) => {
const el = countdown.querySelector('[data-unit="' + name + '"]');
const display = String(value).padStart(2, '0');
if (el && el.dataset.value !== display) {
el.dataset.value = display;
el.textContent = display;
el.classList.remove('flip-changing');
void el.offsetWidth;
el.classList.add('flip-changing');
}
};
const tick = () => {
const diff = Math.max(0, target - Date.now());
set('days', Math.floor(diff / 86400000));
set('hours', Math.floor((diff % 86400000) / 3600000));
set('minutes', Math.floor((diff % 3600000) / 60000));
set('seconds', Math.floor((diff % 60000) / 1000));
};
tick();
setInterval(tick, 1000);
})();
</script>`;
}
function slotStyle(image) {
return image?.aspectRatio ? ` style="aspect-ratio:${image.aspectRatio}"` : "";
}
function linkedImageTag(item, className, fallbackHref, sizesAlt = "") {
const href = item?.href || fallbackHref || "#";
const alt = item?.alt || sizesAlt;
return `<a class="${className}" href="${href}"${slotStyle(item)}><img src="${item.url}" alt="${alt}"></a>`;
}
function home() {
return layout("شرکت آریا شبکه پیشرو | فروش تجهیزات سرور HP", `
<h1 class="sr-only">آریا شبکه پیشرو، فروش تجهیزات سرور HP و شبکه</h1><section class="hero-section"><div class="container"><div class="hero"><div class="hero-slider" aria-hidden="true">${sliderImages.map((slide, index) => slide.href ? `<a class="slide-card slide-${index + 1}" href="${slide.href}"${slotStyle(slide)}><img src="${slide.url}" alt="${slide.alt || ""}"></a>` : `<div class="slide-card slide-${index + 1}"${slotStyle(slide)}><img src="${slide.url}" alt="${slide.alt || ""}"></div>`).join("")}</div></div><div class="banner-row">${belowSliderBanners.map((banner, index) => linkedImageTag(banner, "promo-banner", "tel:02177133934", `بنر فروش تجهیزات سرور ${index + 1}`)).join("")}</div></div></section>
<section class="section" id="special-sale"><div class="container special-sale-frame"><div class="special-heading">${sectionTitle("فروش ویژه", "SPECIAL SALE", "right")}${countdownMarkup()}</div><div class="product-grid special-grid">${linkedImageTag(specialSaleBanner, "special-banner-card", "tel:02177133934", "فروش ویژه تجهیزات سرور")}${products.map((p) => `<a class="product-card" href="${p.link}"><div class="product-image"><img src="${p.image}" alt="${p.title}"></div><span>${p.category}</span><h3>${p.title}</h3><strong>تماس با فروشگاه</strong></a>`).join("")}</div></div></section>
<section class="section split-section"><div class="container split"><div>${sectionTitle("سرور (Server) چیست؟", "SERVER", "right")}<p>در ویکی پدیا نیز معنی سرور، سرویس دهنده ذکر شده است. به بیان ساده معنی سرور یا در پاسخ سوال server به چه معناست باید گفت، کامپیوتری همیشه روشن و قدرتمند است که کاربران در زمان‌های متفاوت، از آن انتظار پاسخ به درخواست‌ها را دارند.</p><a class="secondary-btn" href="https://www.asphp.co/article-details/191">درباره سرور بیشتر بدانید</a></div><div class="image-pair"><img src="${serverBanner.url}" alt="${serverBanner.alt || "تجهیزات سرور"}"${slotStyle(serverBanner)}></div></div></section>
<section class="section muted"><div class="container">${sectionTitle("خدمات آریا شبکه پیشرو", "SERVICES")}<div class="service-grid">${[...services].reverse().map((s) => `<article class="service-card"><img src="${s.icon}" alt="" width="64" height="64"><h3>${s.title}</h3><p>${s.body}</p></article>`).join("")}</div></div></section>
<section class="section about-band"><div class="container split"><div>${sectionTitle("آریا شبکه پیشرو", "ARYA SHABAKE PISHRO", "right")}<h3>شرکتی جوان خلاق، با انگیزه و دانش بنیان</h3><p>انضباط، مشتری مداری، ارائه محصولات با کیفیت و تضمین شده می باشد. برای مشاوره و خرید در زمینه تجهیزات شبکه با مشاوران ما در آریا شبکه پیشرو تماس بگیرید.</p><a class="primary-btn" href="tel:02177133934">تماس با ما</a></div><div class="image-pair"><img src="${aboutusBanner.url}" alt="${aboutusBanner.alt || "تجهیزات سرور آریا شبکه پیشرو"}"${slotStyle(aboutusBanner)}></div></div></section>
<section class="section feature-section" id="features"><div class="container feature-showcase"><div class="feature-copy">${sectionTitle("ویژگـــی مــــا", "PROCESS", "right")}<p>انضباط، مشتری مداری، ارائه محصولات با کیفیت و تضمین شده می باشد.</p></div><div class="feature-grid">${features.map((f) => `<div class="feature"><img src="${f.icon}" alt="" width="58" height="58"><p>${f.body}</p></div>`).join("")}</div></div></section>
<section class="section source-banner-section" id="source-frame"><div class="container source-banner-grid">${linkedImageTag(threeBanners[0], "source-banner source-banner-large", sourceBanners[0].href, sourceBanners[0].alt)}<div class="source-banner-stack">${threeBanners.slice(1).map((b, index) => linkedImageTag(b, "source-banner", sourceBanners[index + 1]?.href, sourceBanners[index + 1]?.alt)).join("")}</div></div></section>
<section class="section navy"><div class="container">${sectionTitle("طرح یک پروژه", "PROJECT A DESIGN", "light")}<div class="steps">${projectSteps.map((s) => `<article><strong>${s.number}</strong><h3>${s.title}</h3><p>${s.body}</p></article>`).join("")}</div></div></section>
<section class="cta"><div class="container cta-inner"><div class="cta-copy"><span>مشاوره خرید تجهیزات شبکه</span><p>برای انتخاب سرور، رم، هارد و تجهیزات شبکه با مشاوران آریا شبکه پیشرو تماس بگیرید؛ بهترین راهکارها با مناسب ترین قیمت ها در اختیار شما قرار می گیرد.</p></div><a class="cta-phone" href="tel:02177133934" aria-label="تماس با کارشناسان آریا شبکه پیشرو"><span class="cta-phone-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="M6.6 10.8c1.5 3 3.8 5.2 6.6 6.6l2.2-2.2c.3-.3.8-.4 1.2-.3 1.3.4 2.6.6 4 .6.7 0 1.2.5 1.2 1.2v3.5c0 .7-.5 1.2-1.2 1.2C10.3 22 2 13.7 2 3.4 2 2.7 2.5 2.2 3.2 2.2h3.5c.7 0 1.2.5 1.2 1.2 0 1.4.2 2.7.6 4 .1.4 0 .9-.3 1.2l-1.6 2.2Z" /></svg></span><span>با کارشناسان ما تماس بگیرید</span><strong>۰۲۱۷۷۱۳۳۹۳۴</strong></a></div></section>
<section class="section" id="articles"><div class="container">${sectionTitle("مقــــالــات", "ARTICLES")}<div class="article-carousel" aria-label="مقالات">${articles.map((a) => `<article class="article-card"><div class="article-image"><img src="${a.image}" alt="${a.title}"></div><time>${a.date}</time><h3>${a.title}</h3><p>${a.abstract}</p></article>`).join("")}</div></div></section><a class="telegram-float" href="${contact.telegram}">تلگرام</a>${countdownScript()}`);
}
function sitemapConfig() {
return {
domain: "asphp.ir",
origin: "https://www.asphp.ir",
generatedAt: new Date().toISOString(),
sitemapIndex: {
enabled: true,
url: "https://www.asphp.ir/sitemap.xml",
children: [
"https://www.asphp.ir/sitemap-main.xml",
"https://www.asphp.ir/sitemap-products.xml"
]
},
staticRoutes: [
{ path: "/", url: "https://www.asphp.ir/", priority: 1, changeFrequency: "daily" },
{ path: "/store", url: "https://www.asphp.ir/store", priority: 0.9, changeFrequency: "daily" },
{ path: "/blog", url: "https://www.asphp.ir/blog", priority: 0.8, changeFrequency: "weekly" },
{ path: "/about-us", url: "https://www.asphp.ir/about-us", priority: 0.6, changeFrequency: "monthly" },
{ path: "/contact-us", url: "https://www.asphp.ir/contact-us", priority: 0.6, changeFrequency: "monthly" }
],
exclude: ["/admin", "/auth", "/cart", "/checkout", "/dashboard", "/profile"],
canonicalTemplates: {
product: { path: "/products/{id}/{nameFaSlug}", source: "/tenants/asphp.ir/products/by-id/{id}" },
category: { path: "/products/category/{id}/{nameFaSlug}", source: "/tenants/asphp.ir/categories/by-id/{id}", listSource: "/tenants/asphp.ir/products?categoryId={id}" },
blog: { path: "/blog/{id}/{titleSlug}", source: "/tenants/asphp.ir/blogs/by-id/{id}" },
portfolio: { path: "/portfolios/{id}/{titleFaSlug}", source: "/tenants/asphp.ir/portfolios/by-id/{id}" }
},
slugRules: { keepPersianLetters: true, spaces: "-", strip: "punctuation" }
};
}
function about() {
return layout("درباره آریا شبکه پیشرو", `<section class="page-hero"><div class="container"><span>ABOUT ASPHP</span><h1>درباره آریا شبکه پیشرو</h1><p>شرکتی دانش بنیان، جوان و خلاق در زمینه تامین تجهیزات شبکه از دو کمپانی HP و CISCO.</p></div></section><section class="section"><div class="container split"><img src="/assets/about-office.jpg" alt="درباره شرکت آریا شبکه پیشرو"><div><h2>آریا شبکه پیشرو</h2><p>آریا شبکه پیشرو شرکتی دانش بنیان، جوان و خلاق است. فعالیت مان را از سال ۱۳۹۵ با سرمایه ای اندک ولی با انگیزه سرشار و فکر و نیروی جوان آغاز کردیم.</p><p>مجموعه ما در زمینه تامین تجهیزات شبکه از دو کمپانی HP و CISCO فعالیت دارد و تمرکز اصلی آن ارائه محصولات با کیفیت، مشاوره پیش از خرید و پشتیبانی پس از فروش است.</p></div></div></section>`);
}
function contactPage() {
return layout("تماس با آریا شبکه پیشرو", `<section class="page-hero contact-hero"><div class="container"><span>CONTACT ASPHP</span><h1>تماس با آریا شبکه پیشرو</h1><p>برای مشاوره و خرید در زمینه تجهیزات شبکه با کارشناسان ما در ارتباط باشید.</p></div></section><section class="section"><div class="container contact-grid"><div class="contact-panel"><h2>راه های ارتباطی</h2><p>${contact.address}</p>${contact.phones.map((p) => `<a href="tel:${p.replaceAll(" ", "")}">${p}</a>`).join("")}<div class="socials"><a href="${contact.instagram}">Instagram</a><a href="${contact.telegram}">Telegram</a></div></div><form class="contact-form"><label>نام و نام خانوادگی<input name="name" type="text"></label><label>شماره تماس<input name="cellNumber" type="tel"></label><label>موضوع<input name="title" type="text"></label><label>پیام<textarea name="text" rows="5"></textarea></label><button type="button">ارسال درخواست</button></form></div></section><section class="map-band"><div class="container"><h2>موقعیت شرکت</h2><p>عرض جغرافیایی: ${contact.latitude} | طول جغرافیایی: ${contact.longitude}</p></div></section>`);
}
function fallbackStoreItems() {
return products.map((p, index) => ({ ...p, id: `local-${index + 1}`, description: "برای قیمت، موجودی و کانفیگ اختصاصی این محصول با کارشناسان فروش تماس بگیرید." }));
}
function storePage() {
const cards = fallbackStoreItems().map((p) => `<a class="product-card" href="/store/${p.id}"><div class="product-image"><img src="${p.image}" alt="${p.title}"></div><span>${p.category}</span><h3>${p.title}</h3><strong>تماس با فروشگاه</strong></a>`).join("");
return layout("فروشگاه تجهیزات سرور", `<section class="page-hero store-hero"><div class="container"><span>STORE ITEMS</span><h1>فروشگاه تجهیزات سرور</h1><p>این صفحه به API Store Items متصل شده و در پیش نمایش از محصولات نمونه استفاده می کند.</p></div></section><section class="section"><div class="container"><form class="store-toolbar"><input name="q" placeholder="جستجوی سرور، رم، هارد یا CPU"><button>جستجو</button></form><p class="api-note">فعلا آیتمی از API فروشگاه برنگشت؛ نمایش محصولات نمونه فعال است.</p><div class="product-grid store-grid">${cards}</div></div></section>`);
}
function storeDetail(id) {
const item = fallbackStoreItems().find((p) => p.id === id) || fallbackStoreItems()[0];
const related = fallbackStoreItems().filter((p) => p.id !== item.id).map((p) => `<a class="product-card" href="/store/${p.id}"><div class="product-image"><img src="${p.image}" alt="${p.title}"></div><span>${p.category}</span><h3>${p.title}</h3><strong>تماس با فروشگاه</strong></a>`).join("");
return layout(item.title, `<section class="section product-detail"><div class="container detail-grid"><div class="gallery"><a class="gallery-main zoom-frame" href="${item.image}"><img src="${item.image}" alt="${item.title}"></a><div class="gallery-thumbs"><a href="${item.image}"><img src="${item.image}" alt=""></a><a href="/assets/banner-2.jpg"><img src="/assets/banner-2.jpg" alt=""></a><a href="/assets/banner-3.jpg"><img src="/assets/banner-3.jpg" alt=""></a></div></div><div class="detail-copy"><span>${item.category}</span><h1>${item.title}</h1><p>${item.description}</p><strong>تماس با فروشگاه</strong><div class="store-actions"><label>تعداد<select><option>1</option><option>2</option><option>3</option></select></label><button type="button">افزودن به سبد خرید</button></div></div></div></section><section class="section detail-tabs-section"><div class="container detail-tabs"><details open><summary>توضیحات</summary><div><p>${item.description}</p></div></details><details><summary>اطلاعات فنی</summary><div class="spec-table"><p><span>دسته بندی</span><strong>${item.category}</strong></p><p><span>وضعیت قیمت</span><strong>تماس با فروشگاه</strong></p></div></details><details><summary>نظرات</summary><div class="login-comment-box"><p>برای ثبت نظر درباره این محصول وارد حساب کاربری شوید.</p><a href="${customerUrl}">ورود به حساب کاربری</a></div></details></div></section><section class="section"><div class="container">${sectionTitle("محصولات مشابه", "RELATED")}<div class="product-grid store-grid">${related}</div></div></section>`);
}
function blogPage() {
const cards = articles.map((a, index) => `<a class="blog-card" href="/blog/local-blog-${index + 1}"><div class="blog-image"><img src="${a.image}" alt="${a.title}"></div><time>${a.date}</time><h2>${a.title}</h2><p>${a.abstract}</p></a>`).join("");
return layout("مقالات آریا شبکه پیشرو", `<section class="page-hero blog-hero"><div class="container"><span>BLOG</span><h1>مقالات آریا شبکه پیشرو</h1><p>این صفحه به API Blog متصل شده و در پیش نمایش از مقالات نمونه استفاده می کند.</p></div></section><section class="section"><div class="container"><p class="api-note">فعلا مقاله ای از API برنگشت؛ نمایش مقالات نمونه فعال است.</p><div class="blog-grid">${cards}</div></div></section>`);
}
function blogDetail(slug) {
const index = Math.max(0, Number(slug.replace("local-blog-", "")) - 1);
const article = articles[index] || articles[0];
return layout(article.title, `<article class="section blog-detail"><div class="container blog-detail-inner"><div class="blog-detail-image"><img src="${article.image}" alt="${article.title}"></div><time>${article.date}</time><h1>${article.title}</h1><p class="blog-abstract">${article.abstract}</p><div class="rich-text"><p>${article.abstract}</p></div></div></article>`);
}
createServer((req, res) => {
const url = new URL(req.url || "/", `http://${hostname}:${port}`);
if (url.pathname.startsWith("/assets/")) {
const relative = normalize(url.pathname.replace(/^\/assets\//, ""));
const file = join(root, "public/assets", relative);
res.setHeader("Content-Type", mime[extname(file)] || "application/octet-stream");
createReadStream(file).on("error", () => {
res.writeHead(404);
res.end("Not found");
}).pipe(res);
return;
}
if (url.pathname === "/meshkee/sitemap-config.json") {
res.setHeader("Content-Type", "application/json; charset=utf-8");
res.end(JSON.stringify(sitemapConfig(), null, 2));
} else if (url.pathname === "/sitemap.xml" || url.pathname === "/robots.txt") {
res.writeHead(404);
res.end("Not served by this preview. Production nginx proxies this to Meshkee.");
} else {
res.setHeader("Content-Type", "text/html; charset=utf-8");
if (url.pathname === "/" || url.pathname === "/index.html") res.end(home());
else if (url.pathname === "/about-us" || url.pathname === "/aboutus") res.end(about());
else if (url.pathname === "/contact-us" || url.pathname === "/contactus") res.end(contactPage());
else if (url.pathname === "/store") res.end(storePage());
else if (url.pathname.startsWith("/store/")) res.end(storeDetail(url.pathname.split("/").pop()));
else if (url.pathname === "/blog") res.end(blogPage());
else if (url.pathname.startsWith("/blog/")) res.end(blogDetail(url.pathname.split("/").pop()));
else {
res.writeHead(404);
res.end(layout("یافت نشد", `<section class="page-hero"><div class="container"><h1>404</h1><p>صفحه مورد نظر پیدا نشد.</p></div></section>`));
}
}
}).listen(port, hostname, () => {
console.log(`ASPHP preview ready: http://${hostname}:${port}`);
});