PageSourceSearch

https://blogbotz.com/build/assets/BlogForm-Cv1XcSeb.js

js blogbotz.com collected 2026-10-02 05:17:42 UTC 13,548 bytes, 1 lines download raw bytes

1import{u as ge,f as ue,r as a,a as N,j as e,A as ee,m as me,n as xe}from"./main-C2BHBFqc.js";const he=({className:l})=>e.jsx("svg",{className:l,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M10.5 19.5L3 12m0 0l7.5-7.5M3 12h18"})}),pe=({className:l})=>e.jsx("svg",{className:l,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M2.25 15.75l5.159-5.159a2.25 2.25 0 013.182 0l5.159 5.159m-1.5-1.5l1.409-1.409a2.25 2.25 0 013.182 0l2.909 2.909m-18 3.75h16.5a1.5 1.5 0 001.5-1.5V6a1.5 1.5 0 00-1.5-1.5H3.75A1.5 1.5 0 002.25 6v12a1.5 1.5 0 001.5 1.5zm10.5-11.25h.008v.008h-.008V8.25zm.375 0a.375.375 0 11-.75 0 .375.375 0 01.75 0z"})}),te=({className:l})=>e.jsx("svg",{className:l,fill:"none",viewBox:"0 0 24 24",strokeWidth:1.5,stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})});function fe(){const l=ge(),{id:x}=ue(),c=!!x,[se,L]=a.useState(c),[h,_]=a.useState(!1),[A,r]=a.useState(""),[B,n]=a.useState(""),[w,ae]=a.useState(!1),[g,M]=a.useState(""),[p,k]=a.useState(""),[b,S]=a.useState(""),[f,D]=a.useState(""),[y,F]=a.useState(""),[j,H]=a.useState(""),[C,T]=a.useState(""),[z,E]=a.useState(""),[G,R]=a.use
1State(""),[P,U]=a.useState("draft"),[O,W]=a.useState(""),[o,I]=a.useState([]),[$,K]=a.useState(""),[V,q]=a.useState(!1),[J,u]=a.useState(null);a.useEffect(()=>{c&&re()},[x]);const re=async()=>{try{L(!0);const s=(await N.get(`/admin/website-blogs/${x}`)).data.blog;M(s.title||""),k(s.slug||""),S(s.content||""),D(s.excerpt||""),F(s.meta_title||""),H(s.meta_description||""),T(s.featured_image||""),E(s.featured_image_alt||""),R(s.author_name||""),U(s.status||"draft"),W(s.published_at?s.published_at.split("T")[0]:""),I(s.tags||[]),u(s.featured_image||null)}catch{r("Failed to load blog")}finally{L(!1)}},Q=t=>t.toLowerCase().replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim(),le=t=>{const s=t.target.value;M(s),(!c||!p)&&k(Q(s))},X=async(t=null)=>{var d,m;if(h)return;if(!g.trim()){r("Title is required");return}if(!b.trim()){r("Content is required");return}r(""),n(""),_(!0);const s={title:g,slug:p||null,content:b,excerpt:f||null,meta_title:y||null,meta_description:j||null,featured_image:C||null,featured_image_alt:z||null,author_name:G||null,status:t||P,published_at:O||null,tags:o.length>0?o:null};try{if(c)await N.put(`/admin/website-blogs/${x}`,s),n("Blog updated successfully!");else{const i=await N.post("/admin/website-blogs",s);n("Blog created successfully!"),l(`/admin/website-settings/blogs/${i.data.blog.id}/edit`)}setTimeout(()=>n(""),3e3)}catch(i){r(((m=(d=i.response)==null?void 0:d.data)==null?void 0:m.message)||"Failed to save blog")}finally{_(!1)}},Y=()=>{const t=$.trim();t&&!o.includes(t)&&(I([...o,t]),K(""))},de=t=>{I(o.filter(s=>s!==t))},ne=t=>{t.key==="Enter"&&(t.preventDefault(),Y())},oe=async t=>{var m,i;const s=t.target.files[0];if(!s)return;if(!s.type.match(/^image\/(jpeg|jpg|png|gif|webp)$/)){r("Please upload a valid image file (JPEG, PNG, GIF, or WebP)");return}if(s.size>5*1024*1024){r("Image size must be less than 5MB");return}const d=new FileReader;d.onloadend=()=>{u(d.result)}
1,d.readAsDataURL(s),r(""),q(!0);try{const v=new FormData;v.append("image",s);const Z=await N.post("/admin/website-blogs/upload-image",v,{headers:{"Content-Type":"multipart/form-data"}});T(Z.data.url),u(Z.data.url),n("Image uploaded successfully!"),setTimeout(()=>n(""),3e3)}catch(v){r(((i=(m=v.response)==null?void 0:m.data)==null?void 0:i.message)||"Failed to upload image"),u(C||null)}finally{q(!1),t.target.value=""}},ie=()=>{T(""),E(""),u(null)},ce={toolbar:["heading","|","bold","italic","link","bulletedList","numberedList","|","blockQuote","insertTable","|","undo","redo"],heading:{options:[{model:"paragraph",title:"Paragraph",class:"ck-heading_paragraph"},{model:"heading2",view:"h2",title:"Heading 2",class:"ck-heading_heading2"},{model:"heading3",view:"h3",title:"Heading 3",class:"ck-heading_heading3"},{model:"heading4",view:"h4",title:"Heading 4",class:"ck-heading_heading4"}]},link:{addTargetToExternalLinks:!0,defaultProtocol:"https://"}};return se?e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-red-600"})}):e.jsxs("div",{className:"space-y-6",children:[A&&e.jsx(ee,{type:"error",message:A,onClose:()=>r("")}),B&&e.jsx(ee,{type:"success",message:B,onClose:()=>n("")}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("button",{onClick:()=>l("/admin/website-settings/blogs"),className:"p-2 text-gray-600 hover:text-gray-800 hover:bg-gray-100 rounded-lg transition-colors",children:e.jsx(he,{className:"w-5 h-5"})}),e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:c?"Edit Blog Post":"Add New Blog Post"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>X("draft"),disabled:h,className:"px-4 py-2 border border-gray-300 text-gray-700 rounded-lg hover:bg-gray-50 disabled:opacity-50",children:"Save Draft"}),e.jsx("button",{onClick:()=>X("published"),disabled:h,className:"px-4 py-2 bg-red-600 text-white rounded-lg hover:bg-red-700 disabled:opacity-50",children:h?"Saving...":P==="published"?"Update":"Publish"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:["Title ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",value:g,onChange:le,placeholder:"Enter blog title...",className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-red-500 text-lg"}),e.jsxs("div",{className:"mt-1 text-right text-xs text-gray-500",children:[g.length,"/255"]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"URL Slug"}),e.jsxs("div",{className:"flex items-center",children:[e.jsx("span",{className:"text-gray-500 text-sm mr-2",children:"/blog/"}),e.jsx("input",{type:"text",value:p,onChange:t=>k(Q(t.target.value)),placeholder:"url-slug",className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-red-500"})]}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Leave empty to auto-generate from title"})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("label",{className:"block text-sm font-medium text-gray-700",children:["Content ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("button",{type:"button",onClick:()=>ae(!w),className:"text-sm text-gray-600 hover:text-gray-900",children:w?"Visual Editor":"HTML Editor"})]}),w?e.jsx("textarea",{value:b,onChange:t=>S(t.target.value),rows:20,className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-red-500 font-mono text-sm",placeholder:"Enter HTML content..."}):e.jsx("div",{className:"border border-gray-300 rounded-lg overflow-hidden",children:e.jsx(me.CKEditor,{editor:xe,data:b,config:ce,onChange:(t,s)=>{const d=s.getData();S(d)}})})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Excerpt"}),e.jsx("textarea",{value:f,onChange:t=>D(t.target.value),rows:3,placeholder:"Brief summary of the blog post (auto-generated if left empty)",className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-red-500"}),e.jsxs("div",{className:"mt-1 text-right text-xs text-gray-500",children:[f.length,"/500"]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"SEO Settings"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Meta Title"}),e.jsx("input",{type:"text",value:y,onChange:t=>F(t.target.value),placeholder:"SEO title (defaults to blog title)",className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-red-500"}),e.jsxs("div",{className:"mt-1 text-right text-xs text-gray-500",children:[y.length,"/70"]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Meta Description"}),e.jsx("textarea",{value:j,onChange:t=>H(t.target.value),rows:3,placeholder:"SEO description (defaults to excerpt)",className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-red-500"}),e.jsxs("div",{className:"mt-1 text-right text-xs text-gray-500",children:[j.length,"/160"]})]}),e.jsxs("div",{className:"mt-4 p-4 bg-gray-50 rounded-lg",children:[e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Google Preview"}),e.jsx("div",{className:"text-blue-600 text-lg truncate",children:y||g||"Blog Post Title"}),e.jsxs("div",{className:"text-green-700 text-sm",children:["blogbotz.com/blog/",p||"your-blog-slug"]}),e.jsx("div",{className:"text-gray-600 text-sm mt-1 line-clamp-2",children:j||f||"Your meta description will appear here..."})]})]})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Publish"}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Status"}),e.jsxs("select",{value:P,onChange:t=>U(t.target.value),className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-red-500",children:[e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"published",children:"Published"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Publish Date"}),e.jsx("input",{type:"date",value:O,onChange:t=>W(t.target.value),className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-red-500"}),e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Leave empty to use current date when publishing"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Author Name"}),e.jsx("input",{type:"text",value:G,onChange:t=>R(t.target.value),placeholder:"Author name",className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-red-500"})]})]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Featured Image"}),J?e.jsxs("div",{className:"relative",children:[e.jsx("img",{src:J,alt:"Featured",className:"w-full h-40 object-cover rounded-lg"}),e.jsx("button",{onClick:ie,className:"absolute top-2 right-2 p-1 bg-red-600 text-white rounded-full hover:bg-red-700",children:e.jsx(te,{className:"w-4 h-4"})})]}):e.jsxs("label",{className:"flex flex-col items-center justify-center w-full h-40 border-2 border-gray-300 border-dashed rounded-lg cursor-pointer bg-gray-50 hover:bg-gray-100",children:[e.jsxs("div",{className:"flex flex-col items-center justify-center pt-5 pb-6",children:[e.jsx(pe,{className:"w-10 h-10 text-gray-400 mb-2"}),e.jsx("p",{className:"text-sm text-gray-500",children:V?"Uploading...":"Click to upload"}),e.jsx("p",{className:"text-xs text-gray-400",children:"PNG, JPG, GIF up to 5MB"})]}),e.jsx("input",{type:"file",accept:"image/*",onChange:oe,className:"hidden",disabled:V})]}),C&&e.jsxs("div",{className:"mt-4",children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Image Alt Text"}),e.jsx("input",{type:"text",value:z,onChange:t=>E(t.target.value),placeholder:"Describe the image for SEO",className:"w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-red-500"})]})]}),e.jsxs("div",{className:"bg-white rounded-lg shadow p-6",children:[e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Tags"}),e.jsxs("div",{className:"flex gap-2 mb-3",children:[e.jsx("input",{type:"text",value:$,onChange:t=>K(t.target.value),onKeyPress:ne,placeholder:"Add a tag",className:"flex-1 px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-red-500 focus:border-red-500"}),e.jsx("button",{type:"button",onClick:Y,className:"px-4 py-2 bg-gray-200 text-gray-700 rounded-lg hover:bg-gray-300",children:"Add"})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:o.map(t=>e.jsxs("span",{className:"inline-flex items-center px-3 py-1 bg-gray-100 text-gray-700 rounded-full text-sm",children:[t,e.jsx("button",{type:"button",onClick:()=>de(t),className:"ml-2 text-gray-500 hover:text-red-600",children:e.jsx(te,{className:"w-3 h-3"})})]},t))}),o.length===0&&e.jsx("p",{className:"text-sm text-gray-500",children:"No tags added yet"})]})]})]})]})}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.