1import{f as D,g as M,h as L,o as l,c as u,b as s,i as O,w as o,a as e,d as i,F as j,r as Y,j as P,t as r,k as y,l as d,m as a,n as R,p as K,q as z,s as Q,v as X,x as q,y as Z,z as B,A as ee,B as te,C as se,D as oe,E as le,G as ae}from"./aCHmRW9u.js";import{_ as E}from"./CCi8zC-C.js";import{_ as ne}from"./gfvOXkdB.js";import{_ as ie}from"./C4e-X6DA.js";import{t as re}from"./yI7HeE6Z.js";const me={class:"max-w-4xl mx-auto"},ue={class:"relative pb-4"},ce={class:"relative flex justify-center"},de={class:"mb-6 space-y-4 sm:mb-12"},_e={class:"rounded-md border border-dark/20 bg-white p-4 shadow-sm sm:p-5"},fe={class:"mb-3 flex flex-wrap items-start justify-between gap-3"},pe={class:"flex flex-wrap items-center gap-2"},be=["datetime"],ve={key:0,class:"ml-4 space-y-3 border-l border-dark/20 pl-4 sm:ml-8 sm:pl-5"},ge={class:"mb-3"},xe={class:"flex flex-wrap items-center gap-2"},he=["datetime"],ye={class:"relative pb-4"},ke={class:"relative flex justify-center"},we={key:0,class:"rounded-md border border-primary/30 bg-white p-4 shadow-sm"},Ce={key:0,class:"my-4 rounded-md bg-white p-3 ring-1 ring-primary"},Ne=D({__name:"Comments",props:{commentCollectionName:{},targetTemplateName:{},targetCollectionSlug:{},relatedPostId:{},comments:{default:()=>[]}},async setup(_){let b,k;const C=X(),{siteCode:n,apiUrl:v}=C.public,V=M(_.targetTemplateName,_.targetCollectionSlug,v,n,_.commentCollectionName),c=q(null),w=q(!1),{data:S,refresh:N}=([b,k]=L(()=>Z(V,{server:!1,default:()=>({success:!0,data:{comments:_.comments}})},"$JUsux8FJrp")),b=await b,k(),b),$=B(()=>S.value?.data?.comments||_.comments),g=f=>f?typeof f=="string"?f:f.value||"":"",x=f=>f.comment_author_type==="netlio_staff"?"Netlio Staff":f.comment_author_type==="website_author"?"Website Author":"",T=B(()=>[{name:"name",type:"text",placeholder:"Your Name",required:!0,defaultValue:""},{name:"comment",type:"textarea",placeholder:c.value?`Reply to ${g(c.value.fields.name)||"this comment"}`:"Your Comment",required:!0,defaultValue:"",fieldOptions:{rows:"4"}}]),I=B(()=>({comment_template:_.commentCollectionName,comment_parent_collection:c.value?.id||null})),J=async()=>{c.value=null,w.value=!0,await N()};return(f,t)=>{const U=ie,A=P,F=E,W=K,h=z,G=Q,H=O;return l(),u("div",null,[s(H,{light:"","no-t-padding":""},{default:o(()=>[e("div",me,[e("div",ue,[t[2]||(t[2]=e("div",{class:"absolute inset-0 flex items-center"},[e("div",{class:"w-full border-b border-dark/30"})],-1)),e("div",ce,[s(U,{class:"bg-light px-4 mb-3"},{default:o(()=>[...t[1]||(t[1]=[i("Comments",-1)])]),_:1})])]),e("div",de,[(l(!0),u(j,null,Y($.value,m=>(l(),u("div",{key:m.id,class:"space-y-3"},[e("article",_e,[e("div",fe,[e("div",null,[e("div",pe,[s(A,{as:"h5"},{default:o(()=>[i(r(g(m.fields.name)),1)]),_:2},1024),x(m)?(l(),y(F,{key:0,small:""},{default:o(()=>[i(r(x(m)),1)]),_:2},1024)):d("",!0)]),e("time",{datetime:m.created_at,class:"mt-1 block text-xs font-medium uppercase tracking-wide text-dark/50"},r(a(R)(m.created_at)),9,be)]),s(W,{small:"",onClick:p=>c.value=m},{default:o(()=>[...t[3]||(t[3]=[i(" Reply ",-1)])]),_:1},8,["onClick"])]),s(h,{field:m.fields.comment},null,8,["field"])]),m.replies?.length?(l(),u("div",ve,[(l(!0),u(j,null,Y(m.replies,p=>(l(),u("article",{key:p.id,class:"rounded-md border border-dark/20 bg-white p-4 shadow-sm sm:p-5"},[e("div",ge,[e("div",xe,[s(A,{as:"h6"},{default:o(()=>[i(r(g(p.fields.name)),1)]),_:2},1024),x(p)?(l(),y(F,{key:0,small:""},{default:o(()=>[i(r(x(p)),1)]),_:2},1024)):d("",!0)]),e("time",{datetime:p.created_at,class:"mt-1 block text-xs font-medium uppercase tracking-wide text-dark/50"},r(a(R)(p.created_at)),9,he)]),s(h,{field:p.fields.comment},null,8,["field"])]))),128))])):d("",!0)]))),128)),$.value.length===0?(l(),y(h,{key:0,small:"",class:"my-6"},{default:o(()=>[...t[4]||(t[4]=[e("i",null,"There are no comments yet, be the first to comment...",-1)])]),_:1})):d("",!0)]),e("div",ye,[t[5]||(t[5]=e("div",{class:"absolute inset-0 flex items-center"},[e("div",{class:"w-full border-b border-dark/30"})],-1)),e("div",ke,[s(U,{class:"bg-light px-4 mb-3"},{default:o(()=>[i(r(w.value?"Comment submitted":"Leave a comment"),1)]),_:1})])]),e("div",null,[w.value?(l(),u("div",we,[s(h,{small:""},{default:o(()=>[...t[6]||(t[6]=[i(" Your comment has been successfully submitted. It will be visible once it has been approved. ",-1)])]),_:1})])):(l(),u(j,{key:1},[s(h,{small:""},{default:o(()=>[...t[7]||(t[7]=[i("Your comment will first need to be approved before it is visible.",-1)])]),_:1}),c.value?(l(),u("div",Ce,[s(h,{small:""},{default:o(()=>[t[8]||(t[8]=i(" Replying to ",-1)),e("strong",null,r(g(c.value.fields.name)||"comment"),1)]),_:1}),e("button",{class:"mt-2 text-sm font-semibold text-accent hover:underline cursor-pointer",type:"button",onClick:t[0]||(t[0]=m=>c.value=null)}," Cancel reply ")])):d("",!0),s(G,{"default-values":T.value,"collection-name":_.commentCollectionName,"action-url":
1a(V),"extra-body":I.value,onSuccess:J},null,8,["default-values","collection-name","action-url","extra-body"])],64))])])]),_:1})])}}}),$e=Object.assign(Ne,{__name:"UiComments"}),Ve={class:"max-w-4xl mx-auto"},Se={key:0,class:"mb-6 max-h-[50vh]"},Te={class:"max-w-4xl mx-auto"},Fe=D({__name:"[slug]",async setup(_){let b,k;const C=ee(),n=te("blog-posts",C.params.slug,!0);n.slug!==C.params.slug&&([b,k]=L(()=>ae(`/blog/${n.slug}`,{})),await b,k()),se({collection:n,title:n.fields.heading.value,description:re(n.fields.content.value,155,oe),appendWebsiteTitle:!0});const v=n.fields;return(V,c)=>{const w=le,S=E,N=P,$=ne,g=O,x=z,T=$e;return l(),u("div",null,[s(g,{first:"",primary:""},{default:o(()=>[e("div",Ve,[a(v).image?.src?(l(),u("div",Se,[s(w,{field:a(v)?.image,class:"size-full mx-auto object-contain rounded-2xl max-h-[50vh]"},null,8,["field"])])):d("",!0),e("div",null,[a(v).category?(l(),y(S,{key:0,class:"mb-3"},{default:o(()=>[i(r(a(v).category.fields.name.value),1)]),_:1})):d("",!0),s(N,{as:"h1",light:"",class:"mb-3"},{default:o(()=>[i(r(a(n).fields.heading.value),1)]),_:1}),a(n).fields.subheading.value?(l(),y(N,{key:1,as:"h3",light:""},{default:o(()=>[i(r(a(n).fields.subheading.value),1)]),_:1})):d("",!0),a(n).fields.date.value?(l(),y($,{key:2},{default:o(()=>[i(r(a(R)(a(n).fields.date.value)),1)]),_:1})):d("",!0)])])]),_:1}),s(g,{light:""},{default:o(()=>[e("div",Te,[s(x,{field:a(v).content},null,8,["field"])])]),_:1}),s(T,{"comment-collection-name":"blog-comments","target-template-name":"blog-posts","target-collection-slug":a(n).slug},null,8,["target-collection-slug"])])}}});export{Fe 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.