1import{r as d,j as e}from"./react-core-Bqpqi34S.js";import{T as $,f as u,S as U,p as y,q as z,Z as O,O as K,D as Z,h,l as x,U as C,V as D,W,B as G,aJ as Q,aM as J,i as k,j as A,s as g,Y as V}from"./index-z8t6FwzL.js";import{u as p}from"./query-vendor-CrtQ-Yrb.js";import{B as Y}from"./Breadcrumbs-CZZHrfwD.js";import{A as X}from"./ArticleCardSkeleton-CnVQ6B3e.js";import{F as ee}from"./FormattedDate-P8-5J-Rl.js";import{b as se,u as ae,a as te,L as _}from"./router-CvGM0cUe.js";import"./ui-nav-CigGr8qy.js";import"./tiptap-editor-BSx0zDC6.js";import"./formatDistanceToNow-DgdhEenT.js";import"./endOfMonth-D5NyAdWh.js";import"./endOfDay-DsPzjlyX.js";const v=12,m="https://der-business-tipp.de";function pe(){const{topicSlug:n}=se(),N=ae(),[w,R]=te(),i=Math.max(1,parseInt(w.get("seite")||"1",10)),{data:a,isLoading:L}=p({queryKey:["guide-topic",n],queryFn:async()=>{const{data:s,error:r}=await g.from("guide_topics").select("id, name, slug, description, hub_image_url").eq("slug",n).eq("is_active",!0).maybeSingle();if(r)throw r;return s},enabled:!!n,staleTime:10*60*1e3}),{data:c,isLoading:E}=p({queryKey:["topic-hub-guides",a==null?void 0:a.id,i],queryFn:async()=>{if(!(a!=null&&a.id))return{guides:[],total:0};const s=(i-1)*v,r=s+v-1,{data:I,error:P,count:H}=await g.from("guides").select(` 2 ${V}, 3 id, title, slug, meta_description, preview_text, 4 tile_image_url, view_count, published_at, 5 company:companies!fk_guides_company(id, company_name, city, slug, logo_url) 6 `,{count:"exact"}).eq("topic_id",a.id).eq("status","published").eq("is_active",!0).order("published_at",{ascending:!1,nullsFirst:!1}).range(s,r);if(P)throw P;return{guides:I||[],total:H||0}},enabled:!!(a!=null&&a.id),staleTime:5*60*1e3}),{data:F=[]}=p({queryKey:["related-guide-topics",a==null?void 0:a.id],queryFn:async()=>{const{data:s}=await g.from("guide_topics").select("id, name, slug").eq("is_active",!0).neq("id",a.id).order("display_order").limit(8);return s||[]},enabled:!!(a!=null&&a.id),staleTime:10*60*1e3}),{data:t}=p({queryKey:["hub-content-cache","guide_topic",n],queryFn:async()=>{const{data:s}=await g.from("hub_content_cache").select("intro_text, faqs, title_override, meta_description_override").eq("hub_type","guide_topic").eq("hub_slug",n).eq("is_visible",!0).maybeSingle();return s},enabled:!!n,staleTime:10*60*1e3});d.useEffect(()=>{i>1&&window.scrollTo({top:0,behavior:"smooth"})},[i]);const o=(c==null?void 0:c.guides)||[],l=(c==null?void 0:c.total)||0,b=Math.max(1,Math.ceil(l/v)),f=`${m}/ratgeber/thema/${n}`,M=i>1?`/ratgeber/thema/${n}?seite=${i}`:`/ratgeber/thema/${n}`,B=d.useMemo(()=>{if(!a)return"Themen-Hub";const s=l>0?`${l} Ratgeber`:"Praxis-Ratgeber";return`${a.name}: ${s} für Unternehmer & KMU`},[a,l]),j=d.useMemo(()=>{var s,r;return a?(t==null?void 0:t.meta_description_override)||((s=t==null?void 0:t.intro_text)==null?void 0:s.replace(/<[^>]*>/g,"").slice(0,155))||((r=a.description)==null?void 0:r.slice(0,155))||`Praxis-Ratgeber, Tipps und Anleitungen rund um ${a.name} für Unternehmer, Selbstständige und Mittelstand.`:""},[a,t]),q=d.useMemo(()=>a?{"@context":"https://schema.org","@type":"CollectionPage",name:`${a.name} â Ratgeber`,url:f,description:j,isPartOf:{"@type":"WebSite",name:"Der Business Tipp",url:m},mainEntity:{"@type":"ItemList",numberOfItems:l,itemListElement:o.slice(0,20).map((s,r)=>({"@type":"ListItem",position:r+1,url:`${m}${$(s)}`,name:s.title}))}}:null,[a,o,l,f,j]),T=d.useMemo(()=>{const s=(t==null?void 0:t.faqs)||[];return s.length?{"@context":"https://schema.org","@type":"FAQPage",mainEntity:s.map(r=>({"@type":"Question",name:r.q,acceptedAnswer:{"@type":"Answer",text:r.a}}))}:null},[t]),S=s=>{const r=new URLSearchParams(w);s===1?r.delete("seite"):r.set("seite",String(s)),R(r)};return!L&&!a?e.jsxs("div",{className:"container mx-auto px-4 py-16 text-center",children:[e.jsx("h1",{className:"text-3xl font-bold mb-4",children:"Thema nicht gefunden"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:"Das angefragte Ratgeber-Thema existiert nicht."}),e.jsx(u,{onClick:()=>
6N("/ratgeber/themen"),children:"Zur Themen-Ãbersicht"})]}):e.jsxs(e.Fragment,{children:[e.jsx(U,{title:(t==null?void 0:t.title_override)||B,description:j,canonical:M,ogType:"website"}),e.jsx(y,{data:z([{name:"Startseite",url:m},{name:"Ratgeber",url:`${m}/ratgeber`},{name:"Themen",url:`${m}/ratgeber/themen`},{name:(a==null?void 0:a.name)||"",url:f}])}),q&&e.jsx(y,{data:q}),T&&e.jsx(y,{data:T}),e.jsx("div",{className:"bg-muted py-8",children:e.jsxs("div",{className:"container mx-auto px-4 max-w-7xl",children:[e.jsx(Y,{items:[{label:"Ratgeber",href:"/ratgeber"},{label:"Themen",href:"/ratgeber/themen"},{label:(a==null?void 0:a.name)||""}],className:"mb-6"}),e.jsxs("header",{className:"bg-background rounded-lg p-6 md:p-10 shadow-sm mb-8",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx(O,{className:"h-5 w-5 text-primary"}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground uppercase tracking-wide",children:"Themen-Hub"})]}),e.jsx("h1",{className:"text-3xl md:text-5xl font-bold mb-4",children:a==null?void 0:a.name}),(a==null?void 0:a.description)&&e.jsx("p",{className:"text-lg text-muted-foreground mb-4 max-w-3xl",children:a.description}),(t==null?void 0:t.intro_text)&&e.jsx("div",{className:"prose prose-lg max-w-none mt-4 text-foreground",dangerouslySetInnerHTML:{__html:K(t.intro_text)}}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 mt-6 text-sm text-muted-foreground",children:[e.jsxs(Z,{variant:"secondary",children:[l," ","Ratgeber"]}),e.jsx(_,{to:"/ratgeber/themen",className:"underline hover:text-primary",children:"Alle Themen ansehen"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[1fr_280px] gap-8",children:[e.jsxs("main",{children:[E?e.jsx(X,{count:6}):o.length===0?e.jsx(h,{children:e.jsx(x,{className:"py-12 text-center text-muted-foreground",children:"Aktuell sind keine veröffentlichten Ratgeber zu diesem Thema verfügbar."})}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:o.map(s=>e.jsx(_,{to:`${$(s)}`,className:"group",children:e.jsxs(h,{className:"h-full overflow-hidden transition-all hover:shadow-lg hover:-translate-y-0.5",children:[s.tile_image_url&&e.jsx("div",{className:"aspect-[16/9] overflow-hidden bg-muted",children:e.jsx("img",{src:s.tile_image_url,alt:s.title,loading:"lazy",className:"w-full h-full object-cover transition-transform group-hover:scale-105"})}),e.jsxs(x,{className:"p-5 space-y-2",children:[e.jsx("h3",{className:"font-semibold text-lg leading-tight group-hover:text-primary transition-colors",children:s.title}),s.meta_description&&e.jsx("p",{className:"text-sm text-muted-foreground line-clamp-2",children:s.meta_description}),s.company&&e.jsxs("div",{className:"flex items-center gap-2 pt-2 text-xs text-muted-foreground",children:[e.jsxs(C,{className:"h-6 w-6",children:[e.jsx(D,{src:s.company.logo_url||void 0}),e.jsx(W,{children:e.jsx(G,{className:"h-3 w-3"})})]}),e.jsxs("span",{children:[s.company.company_name,s.company.city?` · ${s.company.city}`:""]}),s.published_at&&e.jsxs(e.Fragment,{children:[e.jsx("span",{children:"·"}),e.jsx(ee,{value:s.published_at})]})]})]})]})},s.id))}),b>1&&e.jsxs("nav",{className:"flex items-center justify-center gap-2 mt-10","aria-label":"Seitennavigation",children:[e.jsxs(u,{variant:"outline",size:"sm",disabled:i<=1,onClick:()=>S(i-1),children:[e.jsx(Q,{className:"h-4 w-4"})," Zurück"]}),e.jsxs("span",{className:"text-sm text-muted-foreground px-3",children:["Seite ",i," von ",b]}),e.jsxs(u,{variant:"outline",size:"sm",disabled:i>=b,onClick:()=>S(i+1),children:["Weiter ",e.jsx(J,{className:"h-4 w-4"})]})]})]}),Array.isArray(t==null?void 0:t.faqs)&&t.faqs.length>0&&e.jsxs("section",{className:"mt-12 bg-background rounded-lg p-6 md:p-8 shadow-sm",children:[e.jsxs("h2",{className:"text-2xl font-bold mb-6",children:["Häufige Fragen zu ",a==null?void 0:a.name]}),e.jsx("div",{className:"space-y-4",children:t.faqs.map((s,r)=>e.jsxs("details",{className:"border border-border rounded-lg p-4",children:[e.jsx("summary",{className:"font-semibold cursor-pointer",children:s.q}),e.jsx("p",{className:"mt-3 text-muted-foreground",children:s.a})]},r))})]})]}),e.jsxs("aside",{className:"space-y-6",children:[e.jsxs(h,{children:[e.jsx(k,{children:e.jsx(A,{className:"text-lg",children:"Weitere Themen"})}),e.jsx(x,{children:e.jsx("ul",{className:"space-y-2",children:F.map(s=>e.jsx("li",{children:e.jsx(_,{to:`/ratgeber/thema/${s.slug}`,className:"text-sm hover:text-primary hover:underline block py-1",children:s.name})},s.id))})})]}),e.jsxs(h,{children:[e.jsx(k,{children:e.jsx(A,{className:"text-lg",children:"Alle Ratgeber"})}),e.jsx(x,{children:e.jsx(u,{variant:"outline",className:"w-full",onClick:()=>N("/ratgeber"),children:"Zur Hauptübersicht"})})]})]})]})]})})]})}export{pe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.