Files
ruseemrooz/dist/server/pages/posts/_slug_.astro.mjs
mrfelfel dfb0e857f1 fix
2026-07-18 19:41:33 +03:30

51 lines
4.3 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { c as createComponent, d as renderComponent, r as renderTemplate, b as createAstro, m as maybeRenderHead, a as addAttribute } from '../../chunks/astro/server_DrnzQWw3.mjs';
import 'kleur/colors';
import { $ as $$BaseLayout } from '../../chunks/BaseLayout_Bc2tHXHa.mjs';
import { $ as $$PostCard } from '../../chunks/PostCard_D8td2Gog.mjs';
import { r as readCms, b as getApprovedPosts, c as getPostBySlug, h as formatPostShamsiDate, e as getCategoryPath, p as parseImageBlock } from '../../chunks/cms_CRTVymfB.mjs';
export { renderers } from '../../renderers.mjs';
const $$Astro = createAstro();
const $$slug = createComponent(async ($$result, $$props, $$slots) => {
const Astro2 = $$result.createAstro($$Astro, $$props, $$slots);
Astro2.self = $$slug;
const cms = await readCms();
const posts = getApprovedPosts(cms);
const post = getPostBySlug(posts, Astro2.params.slug ?? "");
if (!post) {
return Astro2.redirect("/posts/");
}
const dateLabel = formatPostShamsiDate(post);
const relatedPosts = posts.filter((item) => item.slug !== post.slug).slice(0, 3);
return renderTemplate`${renderComponent($$result, "BaseLayout", $$BaseLayout, { "title": `${post.title} | \u0631\u0648\u0633 \u0627\u0645\u0631\u0648\u0632`, "description": post.excerpt }, { "default": async ($$result2) => renderTemplate` ${maybeRenderHead()}<main class="max-w-7xl mx-auto px-4 lg:px-8 py-8"> <article class="bg-white rounded-2xl shadow-sm overflow-hidden"> <div class="img-placeholder h-64 sm:h-80 lg:h-96 relative overflow-hidden"> ${post.image ? renderTemplate`<img${addAttribute(post.image, "src")}${addAttribute(post.title, "alt")} class="w-full h-full object-cover">` : renderTemplate`<div class="absolute inset-0 flex items-center justify-center text-gray-400"> <span class="material-icons text-6xl opacity-30">image</span> </div>`} </div> <div class="max-w-3xl mx-auto p-5 sm:p-8"> <a${addAttribute(getCategoryPath(post.category), "href")} class="text-brand text-sm font-bold">${post.category}</a> <h1 class="text-2xl sm:text-4xl font-black leading-snug mt-3">${post.title}</h1> <p class="text-gray-500 leading-relaxed mt-4">${post.excerpt}</p> <div class="flex flex-wrap items-center gap-3 text-xs text-gray-400 border-y border-gray-100 py-4 my-6"> <span class="material-icons text-base">schedule</span> <span>${dateLabel}</span> <span>·</span> <span>${post.readTime} مطالعه</span> <span>·</span> <span>تحریریه روس امروز</span> </div> <div class="space-y-5 text-gray-700 leading-8 text-base"> ${post.body.map((paragraph) => {
const imageBlock = parseImageBlock(paragraph);
if (imageBlock) {
return renderTemplate`<figure class="my-7"> <img${addAttribute(imageBlock.src, "src")}${addAttribute(imageBlock.caption || post.title, "alt")} class="w-full rounded-2xl object-cover" loading="lazy"> ${imageBlock.caption && renderTemplate`<figcaption class="text-xs text-gray-400 mt-2 text-center">${imageBlock.caption}</figcaption>`} </figure>`;
}
if (paragraph === "---") {
return renderTemplate`<hr class="border-gray-100 my-7">`;
}
if (paragraph.startsWith("## ")) {
return renderTemplate`<h2 class="text-xl font-black text-gray-900 mt-8">${paragraph.replace(/^##\s+/, "")}</h2>`;
}
if (paragraph.startsWith("> ")) {
return renderTemplate`<blockquote class="border-r-4 border-brand bg-red-50/60 rounded-l-xl px-4 py-3 text-gray-700">${paragraph.replace(/^>\s+/, "")}</blockquote>`;
}
return renderTemplate`<p>${paragraph}</p>`;
})} </div> </div> </article> <section class="mt-10"> <div class="flex items-center justify-between mb-4"> <h2 class="font-bold text-lg">نوشتههای مرتبط</h2> <a href="/posts/" class="text-brand text-sm hover:underline">همه اخبار</a> </div> <div class="grid grid-cols-1 lg:grid-cols-3 gap-4"> ${relatedPosts.map((relatedPost) => renderTemplate`${renderComponent($$result2, "PostCard", $$PostCard, { "post": relatedPost })}`)} </div> </section> </main> ` })}`;
}, "/Users/drfelfel/ruseemrooz/src/pages/posts/[slug].astro", void 0);
const $$file = "/Users/drfelfel/ruseemrooz/src/pages/posts/[slug].astro";
const $$url = "/posts/[slug]";
const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
__proto__: null,
default: $$slug,
file: $$file,
url: $$url
}, Symbol.toStringTag, { value: 'Module' }));
const page = () => _page;
export { page };