import { c as createComponent, d as renderComponent, r as renderTemplate, b as createAstro, m as maybeRenderHead } from '../chunks/astro/server_DrnzQWw3.mjs';
import 'kleur/colors';
import { $ as $$PostCard } from '../chunks/PostCard_D8td2Gog.mjs';
import { $ as $$Pagination } from '../chunks/Pagination_BeoGb-H9.mjs';
import { $ as $$BaseLayout } from '../chunks/BaseLayout_Bc2tHXHa.mjs';
import { r as readCms, d as getPaginatedPosts, b as getApprovedPosts } from '../chunks/cms_CRTVymfB.mjs';
export { renderers } from '../renderers.mjs';

const $$Astro = createAstro();
const $$Index = createComponent(async ($$result, $$props, $$slots) => {
  const Astro2 = $$result.createAstro($$Astro, $$props, $$slots);
  Astro2.self = $$Index;
  const cms = await readCms();
  const pageParam = Number(Astro2.url.searchParams.get("page") ?? "1");
  const requestedPage = Number.isFinite(pageParam) ? pageParam : 1;
  const { currentPage, totalPages, posts } = getPaginatedPosts(requestedPage, 4, getApprovedPosts(cms));
  return renderTemplate`${renderComponent($$result, "BaseLayout", $$BaseLayout, { "title": "\u0647\u0645\u0647 \u0627\u062E\u0628\u0627\u0631 | \u0631\u0648\u0633 \u0627\u0645\u0631\u0648\u0632" }, { "default": async ($$result2) => renderTemplate` ${maybeRenderHead()}<main class="max-w-7xl mx-auto px-4 lg:px-8 py-8"> <div class="mb-6"> <span class="text-brand text-sm font-bold">آرشیو</span> <h1 class="text-2xl font-black mt-1">همه اخبار</h1> <p class="text-gray-500 text-sm mt-2">لیست کامل نوشته‌ها و خبرهای منتشر شده در روس امروز</p> </div> <div class="grid grid-cols-1 lg:grid-cols-2 gap-4"> ${posts.map((post) => renderTemplate`${renderComponent($$result2, "PostCard", $$PostCard, { "post": post })}`)} </div> ${renderComponent($$result2, "Pagination", $$Pagination, { "currentPage": currentPage, "totalPages": totalPages })} </main> ` })}`;
}, "/Users/drfelfel/ruseemrooz/src/pages/posts/index.astro", void 0);

const $$file = "/Users/drfelfel/ruseemrooz/src/pages/posts/index.astro";
const $$url = "/posts";

const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
  __proto__: null,
  default: $$Index,
  file: $$file,
  url: $$url
}, Symbol.toStringTag, { value: 'Module' }));

const page = () => _page;

export { page };
