PageSourceSearch

https://www.homedirect.ro/assets/js/BlogPostPage-DnCxECfG.js

js homedirect.ro collected 2026-10-02 01:09:55 UTC 11,637 bytes, 3 lines download raw bytes

1import{j as e}from"./mui-DO0ZjxHu.js";import{m as re,u as oe,r as a,L as g}from"./react-vendor-DboxtvDn.js";import{A as ce,y as le,k as o,H as me,bp as de,cS as x,E as H,aL as U,bU as B,i as W,aK as pe,aP as ue,aJ as he,es as ge,D as xe,aN as je,T as be,cK as ye,aU as z}from"./index-D_rdfsZe.js";function ve(){const{slug:j}=re(),K=oe(),{currentUser:i}=a.useContext(ce),{showError:r}=le(),[t,M]=a.useState(null),[G,S]=a.useState(!0),[b,A]=a.useState(!1),[I,$]=a.useState(0),[L,T]=a.useState(!1),[J,F]=a.useState(!1),[y,q]=a.useState([]),[Y,P]=a.useState(!1),[R,Q]=a.useState([]),[c,_]=a.useState(""),[D,f]=a.useState(null),[l,N]=a.useState(""),[E,m]=a.useState(!1),w=a.useRef(null);a.useEffect(()=>{X()},[j]),a.useEffect(()=>{if(!t?.id)return;d(),V();const s=`blog-view-${t.id}`;if(w.current!==t.id){if(sessionStorage.getItem(s)){w.current=t.id;return}w.current=t.id,sessionStorage.setItem(s,"1"),o.post(`/blog/posts/${t.id}/view`).catch(()=>{})}},[t?.id]);const V=async()=>{try{const s=await o.get(`/blog/posts/${t.id}/related`);Q(s.data||[])}catch{}};a.useEffect(()=>{t?.id&&(self.SWG_BASIC=self.SWG_BASIC||[],self.SWG_BASIC.push(s=>{s.init({type:"NewsArticle",isPartOfType:["Product"],isPartOfProductId:"CAow7v_KDA:openaccess",clientOptions:{theme:"light",lang:"ro"}})}))},[t?.id]);const X=async()=>{try{S(!0);const s=await o.get(`/blog/posts/${j}`);M(s.data),A(!!s.data.liked),$(s.data._count?.likes||0)}catch(s){s.response?.status===404?K("/blog",{replace:!0}):r("Nu s-a putut încărca articolul")}finally{S(!1)}},d=async()=>{try{P(!0);const s=await o.get(`/blog/comments/${t.id}`);q(s.data||[])}catch{}finally{P(!1)}},Z=async()=>{if(!i){r("Trebuie să fii autentificat pentru a aprecia");return}if(!L)try{T(!0);const s=await o.post(`/blog/posts/${t.id}/like`);A(s.data.liked),$(s.data.count)}catch{r("Eroare la apreciere")}finally{T(!1)}},ee=async s=>{if(s.preventDefault(),!i){r("Trebuie să fii autentificat pentru a comenta");return}if(c.trim())try{m(!0),await o.post("/blog/comments",{postId:t.id,content:c.trim()}),_(""),d()}catch{r("Eroare la trimiterea comentariului")}finally{m(!1)}},te=async s=>{if(l.trim())try{m(!0),await o.post("/blog/comments",{postId:t.id,content:l.trim(),parentId:s}),N(""),f(null),d()}catch{r("Eroare la trimiterea răspunsului")}finally{m(!1)}},O=async s=>{if(window.confirm("Sigur vrei să ștergi acest comentariu?"))try{await o.delete(`/blog/comments/${s}`),d()}catch{r("Eroare la ștergere")}},p=()=>`${window.location.origin}/blog/${j}`,se=()=>{window.open(`https://www.facebook.com/sharer/sharer.php?u=${encodeURIComponent(p())}`,"_blank","width=600,height=400")},ae=()=>{const s=`${t.title}
2
3${p()}`;window.open(`https://wa.me/?text=${encodeURIComponent(s)}`,"_blank")},ne=()=>{window.open(`https://twitter.com/intent/tweet?text=${encodeURIComponent(t.title)}&url=${encodeURIComponent(p())}`,"_blank","width=600,height=400")},ie=async()=>{try{await navigator.clipboard.writeText(p()),F(!0),setTimeout(()=>F(!1),2e3)}catch{r("Nu s-a putut copia linkul")}},v=s=>s?new Date(s).toLocaleDateString("ro-RO",{day:"numeric",month:"long",year:"numeric"}):"";if(G)return e.jsx("div",{className:"blog-post-page",children:e.jsx("div",{className:"bp-loading",children:"Se încarcă articolul..."})});if(!t)return null;const k=t.metaTitle||t.title,u=t.metaDescription||t.excerpt||t.title,C=t.ogImage||t.coverImage||`${window.location.origin}/images/og-image.png`,h=`${window.location.origin}/blog/${t.slug}`;return e.jsxs("div",{className:"blog-post-page",children:[e.jsxs(me,{children:[e.jsxs("title",{children:[k," — Blog HomeDirect"]}),e.jsx("meta",{name:"description",content:u}),t.metaKeywords&&e.jsx("meta",{name:"keywords",content:t.metaKeywords}),e.jsx("link",{rel:"canonical",href:h}),e.jsx("link",{rel:"alternate",type:"application/rss+xml",title:"Blog HomeDirect.ro",href:`${window.location.origin}/api/blog/rss.xml`}),e.jsx("script",{async:!0,type:"application/javascript",src:"https://news.google.com/swg/js/v1/swg-basic.js"}),e.jsx("meta",{property:"og:type",content:"article"}),e.jsx("meta",{property:"og:title",content:k}),e.jsx("meta",{property:"og:description",content:u}),e.jsx("meta",{property:"og:image",content:C}
3),e.jsx("meta",{property:"og:image:width",content:"1200"}),e.jsx("meta",{property:"og:image:height",content:"630"}),e.jsx("meta",{property:"og:url",content:h}),e.jsx("meta",{property:"og:site_name",content:"HomeDirect.ro"}),e.jsx("meta",{property:"og:locale",content:"ro_RO"}),e.jsx("meta",{property:"article:published_time",content:t.publishedAt||t.createdAt}),t.updatedAt&&e.jsx("meta",{property:"article:modified_time",content:t.updatedAt}),t.author?.username&&e.jsx("meta",{property:"article:author",content:t.author.username}),t.category?.name&&e.jsx("meta",{property:"article:section",content:t.category.name}),e.jsx("meta",{name:"twitter:card",content:"summary_large_image"}),e.jsx("meta",{name:"twitter:title",content:k}),e.jsx("meta",{name:"twitter:description",content:u}),e.jsx("meta",{name:"twitter:image",content:C}),t.coverImage&&e.jsx("link",{rel:"preload",as:"image",href:t.coverImage,fetchpriority:"high"}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"BlogPosting",headline:t.title,description:u,image:C,datePublished:t.publishedAt||t.createdAt,dateModified:t.updatedAt,author:{"@type":"Person",name:t.author?.username||"HomeDirect"},publisher:{"@type":"Organization",name:"HomeDirect.ro",logo:{"@type":"ImageObject",url:`${window.location.origin}/logo.png`}},mainEntityOfPage:{"@type":"WebPage","@id":h}})}),e.jsx("script",{type:"application/ld+json",children:JSON.stringify({"@context":"https://schema.org","@type":"BreadcrumbList",itemListElement:[{"@type":"ListItem",position:1,name:"Acasă",item:window.location.origin},{"@type":"ListItem",position:2,name:"Blog",item:`${window.location.origin}/blog`},...t.category?[{"@type":"ListItem",position:3,name:t.category.name,item:`${window.location.origin}/blog?cat=${t.category.slug}`}]:[],{"@type":"ListItem",position:t.category?4:3,name:t.title,item:h}]})})]}),t.coverImage&&e.jsxs("div",{className:"bp-hero",children:[e.jsx("img",{src:t.coverImage,alt:t.title}),e.jsx("div",{className:"bp-hero-overlay"})]}),e.jsxs("article",{className:"bp-article",children:[e.jsxs("div",{className:"bp-breadcrumb",children:[e.jsxs(g,{to:"/blog",children:[e.jsx(de,{})," Înapoi la blog"]}),t.category&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"sep",children:"·"}),e.jsx(g,{to:`/blog?cat=${t.category.slug}`,children:t.category.name})]})]}),e.jsx("h1",{className:"bp-title",children:t.title}),e.jsxs("div",{className:"bp-meta",children:[e.jsxs("div",{className:"bp-author",children:[e.jsx(x,{src:t.author?.avatar,alt:t.author?.username||"Author",className:"bp-avatar lg"}),e.jsxs("div",{children:[e.jsx("div",{className:"author-name",children:t.author?.username||"Admin"}),e.jsxs("div",{className:"author-date",children:[v(t.publishedAt||t.createdAt)," · ",e.jsx(H,{})," ",t.readingMinutes||1," min citire"]})]})]}),e.jsxs("div",{className:"bp-stats",children:[e.jsxs("span",{children:[e.jsx(U,{})," ",t.views||0]}),e.jsxs("span",{children:[e.jsx(B,{})," ",t._count?.comments||0]}),e.jsxs("span",{children:[e.jsx(W,{})," ",I]})]})]}),t.excerpt&&e.jsx("p",{className:"bp-excerpt",children:t.excerpt}),e.jsx("div",{className:"bp-content ql-editor",dangerouslySetInnerHTML:{__html:t.content}}),e.jsxs("div",{className:"bp-footer-actions",children:[e.jsxs("button",{className:`like-btn ${b?"liked":""}`,onClick:Z,disabled:L,children:[b?e.jsx(W,{}):e.jsx(pe,{}),e.jsx("span",{children:b?"Apreciat":"Apreciază"}),e.jsx("span",{className:"count",children:I})]}),e.jsxs("div",{className:"footer-share",children:[e.jsx("button",{onClick:se,className:"share-btn facebook",children:e.jsx(ue,{})}),e.jsx("button",{onClick:ae,className:"share-btn whatsapp",children:e.jsx(he,{})}),e.jsx("button",{onClick:ne,className:"share-btn twitter",children:e.jsx(ge,{})}),e.jsx("button",{onClick:ie,className:"share-btn copy",children:J?e.jsx(xe,{}):e.jsx(je,{})})]})]}),R.length>0&&e.jsxs("section",{className:"bp-related",children:[e.jsx("h2",{children:"Articole similare"}),e.jsx("div",{className:"bp-related-grid",children:R.map(s=>e.jsxs(g,{to:`/blog/${s.slug}`,className:"bp-related-card",children:[e.jsxs("div",{className:"bp-related-image",children:[s.coverImage?e.jsx("img",{src:s.coverImage,alt:s.title,loading:"lazy"}):e.jsx("div",{className:"bp-related-placeholder",children:"HomeDirect"}),s.category&&e.jsx("span",{className:"bp-related-category",children:s.category.name})]}),e.jsxs("div",{className:"bp-related-body",children:[e.jsx("h3",{children:s.title}),s.excerpt&&e.jsx("p",{children:s.excerpt}),e.jsxs("div",{className:"bp-related-meta",children:[e.jsx(H,{})," ",s.readingMinutes||1," min · ",e.jsx(U,{})," ",s.views||0]})]})]},s.id))})]}),e.jsxs("section",{className:"bp-comments",children:[e.jsxs("h2",{children:[e.jsx(B,{})," Comentarii (",y.reduce((s,n)=>s+1+(n.replies?.length||0),0),")"]}),i?e.jsxs("form",{className:"comment-form",onSubmit:ee,children:[e.jsx(x,{src:i.avatar,alt:i.username||"You",className:"bp-avatar"}),e.jsxs("div",{className:"comment-input-wrap",children:[e.jsx("textarea",{rows:3,placeholder:"Scrie un comentariu...",value:c,onChange:s=>_(s.target.value),maxLength:1e3}),e.jsxs("button",{type:"submit",disabled:E||!c.trim(),children:[e.jsx(be,{})," Trimite"]})]})]}):e.jsxs("div",{className:"login-prompt",children:[e.jsx(g,{to:"/login",children:"Autentifică-te"})," pentru a lăsa un comentariu."]}
3),Y?e.jsx("div",{className:"bp-loading",children:"Se încarcă comentariile..."}):y.length===0?e.jsx("div",{className:"no-comments",children:"Fii primul care comentează!"}):e.jsx("ul",{className:"comments-list",children:y.map(s=>e.jsxs("li",{className:"comment",children:[e.jsx(x,{src:s.author?.avatar,alt:s.author?.username||"User",className:"bp-avatar"}),e.jsxs("div",{className:"comment-body",children:[e.jsxs("div",{className:"comment-header",children:[e.jsx("span",{className:"author",children:s.author?.username}),e.jsx("span",{className:"date",children:v(s.createdAt)})]}),e.jsx("div",{className:"comment-content",children:s.content}),e.jsxs("div",{className:"comment-actions",children:[i&&e.jsxs("button",{onClick:()=>f(D===s.id?null:s.id),children:[e.jsx(ye,{})," Răspunde"]}),i&&(i.id===s.author?.id||i.isAdmin)&&e.jsxs("button",{className:"danger",onClick:()=>O(s.id),children:[e.jsx(z,{})," Șterge"]})]}),D===s.id&&e.jsxs("div",{className:"reply-form",children:[e.jsx("textarea",{rows:2,value:l,onChange:n=>N(n.target.value),placeholder:"Scrie un răspuns...",autoFocus:!0}),e.jsxs("div",{className:"reply-actions",children:[e.jsx("button",{type:"button",className:"cancel",onClick:()=>{f(null),N("")},children:"Anulează"}),e.jsx("button",{type:"button",className:"submit",disabled:E||!l.trim(),onClick:()=>te(s.id),children:"Trimite"})]})]}),s.replies?.length>0&&e.jsx("ul",{className:"replies-list",children:s.replies.map(n=>e.jsxs("li",{className:"comment reply",children:[e.jsx(x,{src:n.author?.avatar,alt:n.author?.username||"User",className:"bp-avatar sm"}),e.jsxs("div",{className:"comment-body",children:[e.jsxs("div",{className:"comment-header",children:[e.jsx("span",{className:"author",children:n.author?.username}),e.jsx("span",{className:"date",children:v(n.createdAt)})]}),e.jsx("div",{className:"comment-content",children:n.content}),i&&(i.id===n.author?.id||i.isAdmin)&&e.jsx("div",{className:"comment-actions",children:e.jsxs("button",{className:"danger",onClick:()=>O(n.id),children:[e.jsx(z,{})," Șterge"]})})]})]},n.id))})]})]},s.id))})]})]})]})}export{ve 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.