import { e as createComponent, k as renderComponent, r as renderTemplate, h as createAstro, u as unescapeHTML, m as maybeRenderHead, g as addAttribute, am as Fragment } from '../../chunks/astro/server_DePCulMI.mjs';
import 'piccolore';
import { $ as $$Layout } from '../../chunks/Layout_DxAv3UTa.mjs';
import { g as getBlogPostBySlug, a as getRelatedPosts } from '../../chunks/blog_DtV0Ytrn.mjs';
import { g as getProductsFromDB } from '../../chunks/products_DQrRaeeW.mjs';
import { $ as $$ProductCard } from '../../chunks/ProductCard_7e_PI4fu.mjs';
export { renderers } from '../../renderers.mjs';

var __freeze = Object.freeze;
var __defProp = Object.defineProperty;
var __template = (cooked, raw) => __freeze(__defProp(cooked, "raw", { value: __freeze(cooked.slice()) }));
var _a;
const $$Astro = createAstro();
const $$slug = createComponent(async ($$result, $$props, $$slots) => {
  const Astro2 = $$result.createAstro($$Astro, $$props, $$slots);
  Astro2.self = $$slug;
  const { slug } = Astro2.params;
  const post = await getBlogPostBySlug(slug);
  if (!post) {
    return Astro2.redirect("/blog");
  }
  const related = await getRelatedPosts(post.category, post.slug, 3);
  const productBlockRegex = /<!--\s*products:([^>]+?)\s*-->/g;
  const segments = [];
  let lastIndex = 0;
  let match;
  while ((match = productBlockRegex.exec(post.content)) !== null) {
    if (match.index > lastIndex) {
      segments.push({ type: "html", html: post.content.slice(lastIndex, match.index) });
    }
    const paramStr = match[1].trim();
    const opts = {};
    if (paramStr.includes(":")) {
      for (const part of paramStr.split(",")) {
        const [k, v] = part.split(":").map((s) => s.trim());
        if (k && v) opts[k] = v;
      }
    } else {
      opts.model = paramStr;
    }
    try {
      const products = await getProductsFromDB({
        brand: opts.brand,
        model: opts.model,
        limit: parseInt(opts.limit || "4")
      });
      segments.push({ type: "products", html: "", products });
    } catch {
    }
    lastIndex = match.index + match[0].length;
  }
  if (lastIndex < post.content.length) {
    segments.push({ type: "html", html: post.content.slice(lastIndex) });
  }
  const categoryMap = {
    guides: "Koopgidsen",
    deals: "Deals",
    comparisons: "Vergelijkingen",
    trends: "Trends"
  };
  const wordCount = post.content.replace(/<[^>]+>/g, "").replace(/<!--[^>]+-->/g, "").split(/\s+/).length;
  const readingTime = Math.max(1, Math.round(wordCount / 200));
  function formatDate(d) {
    if (!d) return "";
    return new Date(d).toLocaleDateString("nl-NL", { day: "numeric", month: "long", year: "numeric" });
  }
  const canonicalUrl = `https://sneakerpicks.nl/blog/${post.slug}`;
  const jsonLd = {
    "@context": "https://schema.org",
    "@type": "Article",
    headline: post.title,
    description: post.seo_description || post.excerpt,
    image: post.cover_image,
    author: { "@type": "Organization", name: post.author },
    publisher: { "@type": "Organization", name: "SneakerPicks", url: "https://sneakerpicks.nl" },
    datePublished: post.published_at,
    dateModified: post.updated_at,
    mainEntityOfPage: canonicalUrl
  };
  return renderTemplate`${renderComponent($$result, "Layout", $$Layout, { "title": post.seo_title || `${post.title} | SneakerPicks Blog`, "description": post.seo_description || post.excerpt || "" }, { "default": async ($$result2) => renderTemplate`  ${maybeRenderHead()}<main class="mx-auto max-w-4xl px-4 py-10 sm:px-6"> <!-- Breadcrumb --> <nav class="mb-6 text-sm text-text-secondary" aria-label="Breadcrumb"> <ol class="flex flex-wrap items-center gap-1.5"> <li><a href="/" class="hover:text-accent">Home</a></li> <li class="text-text-secondary/50">/</li> <li><a href="/blog" class="hover:text-accent">Blog</a></li> <li class="text-text-secondary/50">/</li> <li><a${addAttribute(`/blog?category=${post.category}`, "href")} class="hover:text-accent">${categoryMap[post.category] || post.category}</a></li> <li class="text-text-secondary/50">/</li> <li class="truncate text-text">${post.title}</li> </ol> </nav> <!-- Cover image --> ${post.cover_image && renderTemplate`<div class="mb-8 overflow-hidden rounded-2xl"> <img${addAttribute(post.cover_image, "src")}${addAttribute(post.title, "alt")} class="w-full object-cover"> </div>`} <!-- Meta --> <div class="mb-8"> <div class="mb-3 flex flex-wrap items-center gap-3"> <span class="rounded-full bg-accent/10 px-3 py-1 text-xs font-semibold text-accent"> ${categoryMap[post.category] || post.category} </span> <span class="text-sm text-text-secondary">${formatDate(post.published_at)}</span> <span class="text-sm text-text-secondary">· ${readingTime} min leestijd</span> </div> <h1 class="text-3xl font-black tracking-tight sm:text-4xl">${post.title}</h1> </div> <!-- Content with product blocks --> <article class="prose prose-invert max-w-none prose-headings:font-bold prose-a:text-accent prose-a:no-underline hover:prose-a:underline prose-strong:text-text prose-li:text-text-secondary prose-p:text-text-secondary"> ${segments.map((seg) => seg.type === "html" ? renderTemplate`${renderComponent($$result2, "Fragment", Fragment, {}, { "default": async ($$result3) => renderTemplate`${unescapeHTML(seg.html)}` })}` : seg.products && seg.products.length > 0 ? renderTemplate`<div class="not-prose my-8"> <div class="grid grid-cols-2 gap-3 sm:gap-4 lg:grid-cols-4"> ${seg.products.map((sneaker, i) => renderTemplate`${renderComponent($$result2, "ProductCard", $$ProductCard, { "sneaker": sneaker, "index": i })}`)} </div> </div>` : null)} </article> <!-- Share --> <div class="mt-10 flex flex-wrap items-center gap-3 border-t border-border/50 pt-6"> <span class="text-sm font-semibold text-text-secondary">Deel dit artikel:</span> <a${addAttribute(`https://twitter.com/intent/tweet?url=${encodeURIComponent(canonicalUrl)}&text=${encodeURIComponent(post.title)}`, "href")} target="_blank" rel="noopener" class="rounded-lg bg-bg-elevated px-3 py-1.5 text-sm text-text-secondary hover:text-text transition-colors">
𝕏 Twitter
</a> <a${addAttribute(`https://wa.me/?text=${encodeURIComponent(post.title + " " + canonicalUrl)}`, "href")} target="_blank" rel="noopener" class="rounded-lg bg-bg-elevated px-3 py-1.5 text-sm text-text-secondary hover:text-text transition-colors">
WhatsApp
</a> <button${addAttribute(`navigator.clipboard.writeText('${canonicalUrl}');this.textContent='Gekopieerd!'`, "onclick")} class="rounded-lg bg-bg-elevated px-3 py-1.5 text-sm text-text-secondary hover:text-text transition-colors">
🔗 Kopieer link
</button> </div> <!-- Related --> ${related.length > 0 && renderTemplate`<div class="mt-12"> <h2 class="mb-6 text-2xl font-bold">Gerelateerde artikelen</h2> <div class="grid gap-4 sm:grid-cols-3"> ${related.map((r) => renderTemplate`<a${addAttribute(`/blog/${r.slug}`, "href")} class="group rounded-2xl border border-border/50 bg-bg-card p-4 transition-all hover:border-accent/50"> ${r.cover_image && renderTemplate`<div class="mb-3 aspect-video overflow-hidden rounded-xl"> <img${addAttribute(r.cover_image, "src")}${addAttribute(r.title, "alt")} class="h-full w-full object-cover" loading="lazy"> </div>`} <h3 class="text-sm font-bold group-hover:text-accent transition-colors">${r.title}</h3> <span class="mt-1 block text-xs text-text-secondary">${formatDate(r.published_at)}</span> </a>`)} </div> </div>`} </main> `, "head": async ($$result2) => renderTemplate(_a || (_a = __template(['<script type="application/ld+json">', "<\/script>"])), unescapeHTML(JSON.stringify(jsonLd))) })}`;
}, "C:/Users/Roel/clawd/sneakerpicks/src/pages/blog/[slug].astro", void 0);

const $$file = "C:/Users/Roel/clawd/sneakerpicks/src/pages/blog/[slug].astro";
const $$url = "/blog/[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 };
