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, i as searchPosts, 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 query = Astro2.url.searchParams.get("q")?.trim() ?? "";
  const results = searchPosts(getApprovedPosts(cms), query);
  const title = query ? `\u062C\u0633\u062A\u062C\u0648: ${query} | \u0631\u0648\u0633 \u0627\u0645\u0631\u0648\u0632` : "\u062C\u0633\u062A\u062C\u0648 | \u0631\u0648\u0633 \u0627\u0645\u0631\u0648\u0632";
  return renderTemplate`${renderComponent($$result, "BaseLayout", $$BaseLayout, { "title": title, "description": "\u062C\u0633\u062A\u062C\u0648 \u062F\u0631 \u062E\u0628\u0631\u0647\u0627 \u0648 \u062A\u062D\u0644\u06CC\u0644\u200C\u0647\u0627\u06CC \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="bg-white rounded-2xl shadow-sm p-5 sm:p-6 mb-6"> <span class="text-brand text-sm font-bold">جستجو</span> <h1 class="text-2xl font-black mt-1">جستجو در روس امروز</h1> <form action="/search/" method="get" class="mt-5 flex gap-2"> <input type="search" name="q"${addAttribute(query, "value")} placeholder="عبارت مورد نظر را وارد کنید..." class="flex-1 bg-gray-100 text-gray-700 text-sm rounded-xl px-4 py-3 outline-none focus:ring-1 focus:ring-brand focus:bg-white"> <button type="submit" class="bg-brand text-white text-sm font-bold px-5 py-3 rounded-xl hover:bg-red-700 transition-colors">
جستجو
</button> </form> </div> ${query ? renderTemplate`<section> <div class="flex items-center justify-between mb-4"> <h2 class="font-bold text-lg">نتایج برای «${query}»</h2> <span class="text-sm text-gray-400">${results.length} نتیجه</span> </div> ${results.length > 0 ? renderTemplate`<div class="grid grid-cols-1 lg:grid-cols-2 gap-4"> ${results.map((post) => renderTemplate`${renderComponent($$result2, "PostCard", $$PostCard, { "post": post })}`)} </div>` : renderTemplate`<div class="bg-white rounded-2xl shadow-sm p-8 text-center text-gray-500">
نتیجه‌ای برای این عبارت پیدا نشد.
</div>`} </section>` : renderTemplate`<section class="bg-white rounded-2xl shadow-sm p-5"> <h2 class="font-bold text-base mb-3">موضوعات پیشنهادی</h2> <div class="flex flex-wrap gap-2"> ${cms.settings.hotTopics.map((tag) => renderTemplate`<a${addAttribute(`/search/?q=${encodeURIComponent(tag)}`, "href")} class="bg-gray-100 hover:bg-red-50 hover:text-brand text-gray-600 text-xs px-3 py-1.5 rounded-full transition-colors">
#${tag} </a>`)} </div> </section>`} </main> ` })}`;
}, "/Users/drfelfel/ruseemrooz/src/pages/search/index.astro", void 0);

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

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 };
