next-seo-checker 1.5.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";var B=Object.defineProperty,te=Object.defineProperties,oe=Object.getOwnPropertyDescriptor,ie=Object.getOwnPropertyDescriptors,ne=Object.getOwnPropertyNames,V=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var Y=(i,o,d)=>o in i?B(i,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):i[o]=d,P=(i,o)=>{for(var d in o||(o={}))_.call(o,d)&&Y(i,d,o[d]);if(V)for(var d of V(o))se.call(o,d)&&Y(i,d,o[d]);return i},N=(i,o)=>te(i,ie(o));var re=(i,o)=>{for(var d in o)B(i,d,{get:o[d],enumerable:!0})},ae=(i,o,d,T)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of ne(o))!_.call(i,m)&&m!==d&&B(i,m,{get:()=>o[m],enumerable:!(T=oe(o,m))||T.enumerable});return i};var de=i=>ae(B({},"__esModule",{value:!0}),i);var le={};re(le,{NextSeoChecker:()=>X});module.exports=de(le);var r=require("react"),Q=require("next/navigation");var e=require("react/jsx-runtime");function X(){var H;let i=(0,Q.usePathname)(),[o,d]=(0,r.useState)(!1),[T,m]=(0,r.useState)(!1),[O,j]=(0,r.useState)("general"),[y,R]=(0,r.useState)({}),[z,K]=(0,r.useState)(""),[D,E]=(0,r.useState)(""),[M,A]=(0,r.useState)(""),[I,F]=(0,r.useState)(""),[w,Z]=(0,r.useState)({h1s:[],h2s:[],h3s:[],bodyText:"",images:[],url:"",wordCount:0}),W=process.env.NODE_ENV==="development",q=(0,r.useRef)(0),U=(0,r.useCallback)(async()=>{var t,n;try{let s=await(await fetch("/api/seo/save")).json(),a=s[i];if(!a){let x=i.replace(/^\//,""),f=Object.keys(s).find(c=>s[c].slug===x);f&&(a=s[f])}if(a)R(a),K(a.title||""),E(a.description||""),A(a.slug||"");else if(typeof document!="undefined"){let x=document.title,f=((t=document.querySelector('meta[name="description"]'))==null?void 0:t.getAttribute("content"))||"",c=((n=document.querySelector('meta[name="keywords"]'))==null?void 0:n.getAttribute("content"))||"",p=c?c.split(",").map(C=>C.trim()).filter(Boolean):[],h={title:x,description:f,keywords:p,slug:i.split("/").filter(Boolean).pop()||"home"};R(h),K(x),E(f),A(h.slug||"")}}catch(l){console.error("Failed to load SEO data")}},[i]);(0,r.useEffect)(()=>{if(d(!0),W){let t=setTimeout(U,500);return()=>clearTimeout(t)}},[W,U]);let ee=async()=>{let t=N(P({},y),{title:z,description:D,slug:M});try{if((await fetch("/api/seo/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pathname:i,overrides:t})})).ok&&(R(t),alert("SEO Changes & Permalink Mapping Saved! \u{1F680}"),typeof document!="undefined")){document.title=z;let l=document.querySelector('meta[name="description"]');l&&l.setAttribute("content",D)}}catch(n){alert("Failed to save to project.")}},$=async t=>{let n=N(P({},y),{keywords:t});try{await fetch("/api/seo/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pathname:i,overrides:n})}),R(n)}catch(l){}};(0,r.useEffect)(()=>{if(!o)return;let t=()=>{if(typeof document=="undefined")return;let s=Date.now();if(s-q.current<2e3)return;q.current=s;let a=Array.from(document.getElementsByTagName("h1")).map(u=>u.innerText),x=Array.from(document.getElementsByTagName("h2")).map(u=>u.innerText),f=Array.from(document.getElementsByTagName("h3")).map(u=>u.innerText),c=document.getElementById("next-seo-checker-root"),p=document.body.innerText;c&&(p=p.replace(c.innerText,""));let h=Array.from(document.getElementsByTagName("img")).filter(u=>!(c!=null&&c.contains(u))).map(u=>({alt:u.alt})),C=p.trim()===""?0:p.trim().split(/\s+/).length;Z({h1s:a,h2s:x,h3s:f,bodyText:p,images:h,url:window.location.pathname,wordCount:C})},n=setTimeout(t,1e3),l=new MutationObserver(s=>{let a=document.getElementById("next-seo-checker-root");s.some(f=>!(a!=null&&a.contains(f.target)))&&t()});return l.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),()=>{clearTimeout(n),l.disconnect()}},[i,o]);let L=(0,r.useMemo)(()=>{var C,u;if(!o)return[];let t=(y.title||(typeof document!="undefined"?document.title:"")).toLowerCase(),n=(y.description||(typeof document!="undefined"?(C=document.querySelector('meta[name="description"]'))==null?void 0:C.getAttribute("content"):"")||"").toLowerCase(),l=y.keywords||[],s=((u=l[0])==null?void 0:u.toLowerCase())||"",a=l.slice(1).map(g=>g.toLowerCase()),x=w.bodyText.toLowerCase(),f=y.slug||(i==="/"?"home":i.split("/").filter(Boolean).pop())||"",c=[{title:"Basic SEO",items:[]},{title:"Additional",items:[]},{title:"Title Readability",items:[]},{title:"Content Readability",items:[]}],p=c[0].items;if(s){let g=t.includes(s);p.push({id:"key-title",label:"Primary Keyword in Title",status:g?"success":"error",message:g?"Perfect! Keyword found in title.":"Critical: Primary keyword missing in title!"});let S=n.includes(s);p.push({id:"key-desc",label:"Primary Keyword in Description",status:S?"success":"error",message:S?"Keyword found in description.":"Critical: Primary keyword missing in description!"});let v=s.replace(/\s+/g,"-"),J=f.toLowerCase().includes(v);p.push({id:"key-url",label:"Keyword in Permalink",status:J?"success":"error",message:J?"Focus keyword used in URL slug.":"Error: Focus keyword not found in your URL slug!"});let G=x.substring(0,500).includes(s);p.push({id:"key-start",label:"Keyword in beginning",status:G?"success":"warning",message:G?"Keyword found at content start.":"Try using keyword in the first 10% of content."})}p.push({id:"word-count",label:"Word Count",status:w.wordCount>600?"success":"warning",message:`${w.wordCount} words. (Target: 600+)`});let h=c[1].items;if(a.length>0&&a.forEach((g,S)=>{let v=x.includes(g)||t.includes(g)||n.includes(g);h.push({id:`sec-key-${S}`,label:`Secondary Keyword: ${g}`,status:v?"success":"error",message:v?"Keyword used in content.":"Error: This keyword is not found anywhere!"})}),s){let g=[...w.h2s,...w.h3s].some(v=>v.toLowerCase().includes(s));h.push({id:"key-sub",label:"Primary in Subheadings",status:g?"success":"warning",message:g?"Keyword found in H2/H3.":"Focus keyword not found in subheadings."});let S=w.images.some(v=>v.alt.toLowerCase().includes(s));h.push({id:"key-alt",label:"Image Alt Tags",status:S?"success":"warning",message:S?"Keyword found in image alt text.":"Add your focus keyword to image alt tags."})}return c},[w,y,o]),k=(0,r.useMemo)(()=>{let t=0,n=0;return L.forEach(l=>l.items.forEach(s=>{n++,s.status==="success"?t++:s.status==="warning"&&(t+=.5)})),n===0?0:Math.round(t/n*100)},[L]);if(!W||!o)return null;let b={wrapper:{fontFamily:"-apple-system, system-ui, sans-serif",color:"#111827"},trigger:{position:"fixed",bottom:"20px",right:"20px",zIndex:99999,background:k>=80?"#10b981":k>=50?"#f59e0b":"#ef4444",color:"white",padding:"10px 20px",borderRadius:"30px",cursor:"pointer",fontWeight:800,border:"2px solid white",boxShadow:"0 4px 15px rgba(0,0,0,0.1)"},panel:{position:"fixed",bottom:0,left:0,right:0,height:T?"600px":"0px",background:"#fff",zIndex:99998,boxShadow:"0 -4px 30px rgba(0,0,0,0.1)",transition:"height 0.3s cubic-bezier(0.4, 0, 0.2, 1)",display:"flex",flexDirection:"column"},sidebar:{width:"240px",borderRight:"1px solid #e5e7eb",padding:"24px",display:"flex",flexDirection:"column",gap:"8px",background:"#f9fafb"},main:{flex:1,padding:"32px 40px",overflowY:"auto",background:"#fff"},tab:t=>({padding:"12px 16px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:600,background:t?"#fff":"transparent",color:t?"#2563eb":"#64748b",boxShadow:t?"0 1px 3px rgba(0,0,0,0.1)":"none",transition:"all 0.2s"}),keywordTag:t=>({background:t?"#dcfce7":"#f3f4f6",color:t?"#15803d":"#374151",padding:"6px 12px",borderRadius:"20px",fontSize:"12px",fontWeight:700,marginRight:"8px",border:"1px solid #e2e8f0",display:"inline-flex",alignItems:"center",gap:"4px"})};return(0,e.jsxs)("div",{id:"next-seo-checker-root",style:b.wrapper,children:[!T&&(0,e.jsxs)("div",{style:b.trigger,onClick:()=>m(!0),children:["SEO Score ",k]}),(0,e.jsxs)("div",{style:b.panel,children:[(0,e.jsxs)("div",{style:{height:"64px",padding:"0 40px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #e5e7eb"},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[(0,e.jsx)("span",{style:{fontSize:"20px"},children:"\u{1F680}"}),(0,e.jsx)("div",{style:{fontWeight:800,fontSize:"18px"},children:"Next SEO Checker"}),(0,e.jsxs)("div",{style:{background:k>=80?"#d1fae5":"#fef3c7",color:k>=80?"#059669":"#d97706",padding:"4px 12px",borderRadius:"12px",fontSize:"14px",fontWeight:800},children:[k,"/100"]})]}),(0,e.jsx)("button",{onClick:()=>m(!1),style:{background:"none",border:"none",fontSize:"28px",cursor:"pointer",color:"#9ca3af"},children:"\xD7"})]}),(0,e.jsxs)("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[(0,e.jsxs)("div",{style:b.sidebar,children:[(0,e.jsx)("div",{style:b.tab(O==="general"),onClick:()=>j("general"),children:"\u2728 General"}),(0,e.jsx)("div",{style:b.tab(O==="edit"),onClick:()=>j("edit"),children:"\u{1F4DD} Snippet Editor"})]}),(0,e.jsxs)("div",{style:b.main,children:[O==="general"&&(0,e.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:[(0,e.jsxs)("div",{style:{background:"#f9fafb",padding:"24px",borderRadius:"15px",border:"1px solid #e5e7eb"},children:[(0,e.jsx)("div",{style:{fontSize:"11px",fontWeight:800,color:"#9ca3af",textTransform:"uppercase",marginBottom:"15px",letterSpacing:"0.5px"},children:"Focus Keywords"}),(0,e.jsxs)("div",{style:{display:"flex",gap:"10px",marginBottom:"15px"},children:[(0,e.jsx)("input",{style:{flex:1,padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",outline:"none",fontSize:"14px"},value:I,onChange:t=>F(t.target.value),placeholder:"Add focus keyword..."}),(0,e.jsx)("button",{onClick:()=>{I&&($([...y.keywords||[],I]),F(""))},style:{padding:"0 24px",background:"#2563eb",color:"white",border:"none",borderRadius:"10px",fontWeight:700,cursor:"pointer"},children:"Add"})]}),(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px"},children:(H=y.keywords)==null?void 0:H.map((t,n)=>(0,e.jsxs)("span",{style:b.keywordTag(n===0),children:[n===0&&"\u2605 "," ",t,(0,e.jsx)("span",{onClick:()=>{var s;let l=(s=y.keywords)==null?void 0:s.filter(a=>a!==t);$(l||[])},style:{cursor:"pointer",opacity:.5,marginLeft:"4px"},children:"\xD7"})]},t))})]}),L.map(t=>(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:"12px",fontWeight:800,color:"#9ca3af",textTransform:"uppercase",marginBottom:"12px",marginLeft:"4px"},children:t.title}),(0,e.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:"12px"},children:t.items.map(n=>(0,e.jsxs)("div",{style:{padding:"16px",borderRadius:"12px",border:"1px solid #f3f4f6",background:"#fff",display:"flex",gap:"12px",alignItems:"flex-start",borderLeft:`4px solid ${n.status==="success"?"#10b981":n.status==="warning"?"#f59e0b":"#ef4444"}`},children:[(0,e.jsx)("div",{style:{fontSize:"16px"},children:n.status==="success"?"\u2705":n.status==="warning"?"\u26A0\uFE0F":"\u274C"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:"14px",fontWeight:700,marginBottom:"2px"},children:n.label}),(0,e.jsx)("div",{style:{fontSize:"12px",color:"#6b7280"},children:n.message})]})]},n.id))})]},t.title))]}),O==="edit"&&(0,e.jsx)("div",{style:{maxWidth:"650px"},children:(0,e.jsxs)("div",{style:{background:"#fff",padding:"32px",borderRadius:"15px",border:"1px solid #e5e7eb",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[(0,e.jsxs)("div",{style:{marginBottom:"24px"},children:[(0,e.jsx)("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"SEO Title"}),(0,e.jsx)("input",{style:{width:"100%",padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",fontSize:"15px",outline:"none"},value:z,onChange:t=>K(t.target.value)}),(0,e.jsxs)("div",{style:{fontSize:"11px",marginTop:"6px",color:z.length>60?"#ef4444":"#9ca3af"},children:[z.length," / 60 characters"]})]}),(0,e.jsxs)("div",{style:{marginBottom:"24px"},children:[(0,e.jsx)("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"Permalink (Slug)"}),(0,e.jsxs)("div",{style:{display:"flex",alignItems:"center",background:"#f3f4f6",borderRadius:"10px",padding:"0 12px",border:"1px solid #d1d5db"},children:[(0,e.jsx)("span",{style:{fontSize:"13px",color:"#9ca3af",marginRight:"4px"},children:"/"}),(0,e.jsx)("input",{style:{flex:1,background:"transparent",border:"none",padding:"12px 4px",fontSize:"15px",outline:"none"},value:M,onChange:t=>A(t.target.value.replace(/\s+/g,"-").toLowerCase())})]})]}),(0,e.jsxs)("div",{style:{marginBottom:"32px"},children:[(0,e.jsx)("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"Meta Description"}),(0,e.jsx)("textarea",{style:{width:"100%",padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",fontSize:"15px",minHeight:"120px",outline:"none",resize:"vertical"},value:D,onChange:t=>E(t.target.value)}),(0,e.jsxs)("div",{style:{fontSize:"11px",marginTop:"6px",color:D.length>160?"#ef4444":"#9ca3af"},children:[D.length," / 160 characters"]})]}),(0,e.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:(0,e.jsx)("button",{onClick:ee,style:{padding:"12px 24px",background:"#2563eb",color:"white",border:"none",borderRadius:"10px",fontWeight:700,cursor:"pointer",fontSize:"14px"},children:"Save to Project (Server-Side)"})})]})})]})]})]})]})}0&&(module.exports={NextSeoChecker});
2
+ "use strict";var $=Object.defineProperty,pe=Object.defineProperties,ue=Object.getOwnPropertyDescriptor,ge=Object.getOwnPropertyDescriptors,fe=Object.getOwnPropertyNames,ne=Object.getOwnPropertySymbols;var se=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var oe=(o,s,c)=>s in o?$(o,s,{enumerable:!0,configurable:!0,writable:!0,value:c}):o[s]=c,U=(o,s)=>{for(var c in s||(s={}))se.call(s,c)&&oe(o,c,s[c]);if(ne)for(var c of ne(s))ye.call(s,c)&&oe(o,c,s[c]);return o},G=(o,s)=>pe(o,ge(s));var me=(o,s)=>{for(var c in s)$(o,c,{get:s[c],enumerable:!0})},xe=(o,s,c,O)=>{if(s&&typeof s=="object"||typeof s=="function")for(let k of fe(s))!se.call(o,k)&&k!==c&&$(o,k,{get:()=>s[k],enumerable:!(O=ue(s,k))||O.enumerable});return o};var be=o=>xe($({},"__esModule",{value:!0}),o);var he={};me(he,{NextSeoChecker:()=>re});module.exports=be(he);var r=require("react"),ie=require("next/navigation");var t=require("react/jsx-runtime");function re(){var ee;let o=(0,ie.usePathname)(),[s,c]=(0,r.useState)(!1),[O,k]=(0,r.useState)(!1),[W,J]=(0,r.useState)("general"),[a,N]=(0,r.useState)({}),[B,j]=(0,r.useState)(""),[K,F]=(0,r.useState)(""),[V,Y]=(0,r.useState)(""),[M,_]=(0,r.useState)(""),[v,I]=(0,r.useState)(null),[w,ae]=(0,r.useState)({h1s:[],h2s:[],h3s:[],bodyText:"",images:[],url:"",wordCount:0,links:[]}),q=process.env.NODE_ENV==="development",Q=(0,r.useRef)(0);(0,r.useEffect)(()=>{var e;(e=a.keywords)!=null&&e.length&&!v&&I(a.keywords[0])},[a.keywords,v]);let X=(0,r.useCallback)(async()=>{var e,n,i;try{let g=await(await fetch("/api/seo/save")).json(),d=g[o];if(!d){let b=o.replace(/^\//,""),u=Object.keys(g).find(f=>g[f].slug===b);u&&(d=g[u])}if(d)N(d),j(d.title||""),F(d.description||""),Y(d.slug||""),(e=d.keywords)!=null&&e.length&&I(d.keywords[0]);else if(typeof document!="undefined"){let b=document.title,u=((n=document.querySelector('meta[name="description"]'))==null?void 0:n.getAttribute("content"))||"",f=((i=document.querySelector('meta[name="keywords"]'))==null?void 0:i.getAttribute("content"))||"",C=f?f.split(",").map(z=>z.trim()).filter(Boolean):[],l={title:b,description:u,keywords:C,slug:o.split("/").filter(Boolean).pop()||"home"};N(l),j(b),F(u),Y(l.slug||""),C.length&&I(C[0])}}catch(y){console.error("Failed to load SEO data")}},[o]);(0,r.useEffect)(()=>{if(c(!0),q){let e=setTimeout(X,500);return()=>clearTimeout(e)}},[q,X]);let de=async()=>{let e=G(U({},a),{title:B,description:K,slug:V});try{if((await fetch("/api/seo/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pathname:o,overrides:e})})).ok&&(N(e),alert("SEO Changes & Permalink Mapping Saved! \u{1F680}"),typeof document!="undefined")){document.title=B;let i=document.querySelector('meta[name="description"]');i&&i.setAttribute("content",K)}}catch(n){alert("Failed to save to project.")}},Z=async e=>{let n=G(U({},a),{keywords:e});try{await fetch("/api/seo/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pathname:o,overrides:n})}),N(n),e.length>0&&(!v||!e.includes(v))&&I(e[e.length-1])}catch(i){}};(0,r.useEffect)(()=>{if(!s)return;let e=()=>{if(typeof document=="undefined")return;let y=Date.now();if(y-Q.current<2e3)return;Q.current=y;let g=Array.from(document.getElementsByTagName("h1")).map(p=>p.innerText),d=Array.from(document.getElementsByTagName("h2")).map(p=>p.innerText),b=Array.from(document.getElementsByTagName("h3")).map(p=>p.innerText),u=document.getElementById("next-seo-checker-root"),f=document.body.innerText;u&&(f=f.replace(u.innerText,""));let C=Array.from(document.getElementsByTagName("img")).filter(p=>!(u!=null&&u.contains(p))).map(p=>({alt:p.alt})),l=Array.from(document.getElementsByTagName("a")).filter(p=>!(u!=null&&u.contains(p))).map(p=>({href:p.href,rel:p.rel})),z=f.trim()===""?0:f.trim().split(/\s+/).length;ae({h1s:g,h2s:d,h3s:b,bodyText:f,images:C,url:window.location.pathname,wordCount:z,links:l})},n=setTimeout(e,1e3),i=new MutationObserver(y=>{let g=document.getElementById("next-seo-checker-root");y.some(b=>!(g!=null&&g.contains(b.target)))&&e()});return i.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),()=>{clearTimeout(n),i.disconnect()}},[o,s]);let T=(0,r.useCallback)(e=>e.replace(/İ/g,"i").replace(/I/g,"\u0131").toLowerCase().replace(/[ğĞ]/g,"g").replace(/[üÜ]/g,"u").replace(/[şŞ]/g,"s").replace(/[ıİi]/g,"i").replace(/[öÖ]/g,"o").replace(/[çÇ]/g,"c").trim(),[]),D=(0,r.useCallback)(e=>{var p,te;let n=a.title||(typeof document!="undefined"?document.title:""),i=a.description||(typeof document!="undefined"?(p=document.querySelector('meta[name="description"]'))==null?void 0:p.getAttribute("content"):"")||"",y=T(n),g=T(i),d=e?T(e):"",b=T(w.bodyText),u=T(a.slug||(o==="/"?"home":o.split("/").filter(Boolean).pop())||""),f=e===((te=a.keywords)==null?void 0:te[0]),C=!a.keywords||a.keywords.length===0,l=[];if(f||C||e===null){let m=n.length;l.push({id:"title-length",label:"Title Length",status:m>60?"error":m<30?"warning":"success",message:m>60?`Too long (${m}/60). Truncated in search.`:m<30?`Too short (${m}). Use more space!`:`Good length (${m}/60).`});let x=i.length;l.push({id:"desc-length",label:"Description Length",status:x>160?"error":x<120?"warning":"success",message:x>160?`Too long (${x}/160). Truncated in search.`:x<120?`Too short (${x}). Aim for 120-160.`:`Good length (${x}/160).`}),l.push({id:"word-count",label:"Word Count",status:w.wordCount>600?"success":"warning",message:`${w.wordCount} words. (Target: 600+)`});let P=typeof window!="undefined"?window.location.host:"",R=w.links.filter(A=>{try{return new URL(A.href).host!==P}catch(ce){return!1}}),h=R.some(A=>!A.rel.includes("nofollow"));l.push({id:"ext-links",label:"External Links",status:R.length>0&&h?"success":"warning",message:R.length>0?h?"Great! At least one external link with DoFollow found.":"External links found but all are NoFollow.":"No external links found."})}if(d){if(f){let h=y.includes(d);l.push({id:"key-title",label:"Primary Keyword in Title",status:h?"success":"error",message:h?"Keyword found in title.":"Keyword missing in title!"});let A=g.includes(d);l.push({id:"key-desc",label:"Primary Keyword in Description",status:A?"success":"error",message:A?"Keyword found in description.":"Keyword missing in description!"})}if(o!=="/"&&f){let h=u.includes(d.replace(/\s+/g,"-"));l.push({id:"key-url",label:"Keyword in Permalink",status:h?"success":"error",message:h?"Keyword used in URL.":"Keyword not found in URL!"})}let m=new RegExp(d,"gi"),x=(b.match(m)||[]).length,P=w.wordCount>0?x/w.wordCount*100:0;l.push({id:"key-density",label:"Keyword Density",status:P>3||P<.5&&x<2?"warning":"success",message:`Density: ${P.toFixed(2)}% (${x} times).`});let R=[...w.h2s,...w.h3s].some(h=>T(h).includes(d));l.push({id:"key-sub",label:"Keyword in Subheadings",status:R?"success":"warning",message:R?"Keyword found in H2/H3.":"Keyword missing in subheadings."})}let z=0;return l.forEach(m=>{m.status==="success"?z++:m.status==="warning"&&(z+=.5)}),{items:l,score:l.length===0?0:Math.round(z/l.length*100)}},[w,a,T,o]),H=(0,r.useMemo)(()=>{var n;let e={};return(n=a.keywords)==null||n.forEach(i=>{e[i]=D(i).score}),e},[a.keywords,D]),L=(0,r.useMemo)(()=>{var i;let e=a.title||(typeof document!="undefined"?document.title:""),n=a.description||(typeof document!="undefined"?(i=document.querySelector('meta[name="description"]'))==null?void 0:i.getAttribute("content"):"")||"";return{titleError:e.length>60,descError:n.length>160}},[a.title,a.description]),le=(0,r.useMemo)(()=>{var i;if(!s)return[];let{items:e}=D(v);return[{title:(v===((i=a.keywords)==null?void 0:i[0])?"Primary":"Secondary")+" Keyword Analysis: "+(v||""),items:e}]},[s,D,v,a.keywords]),E=(0,r.useMemo)(()=>{let e=a.keywords||[];if(e.length===0)return D(null).score;let n=Object.values(H).reduce((i,y)=>i+y,0);return Math.round(n/e.length)},[H,a.keywords,D]);if(!q||!s)return null;let S={wrapper:{fontFamily:"-apple-system, system-ui, sans-serif",color:"#111827"},trigger:{position:"fixed",bottom:"20px",right:"20px",zIndex:99999,background:E>=80?"#10b981":E>=50?"#f59e0b":"#ef4444",color:"white",padding:"10px 20px",borderRadius:"30px",cursor:"pointer",fontWeight:800,border:"2px solid white",boxShadow:"0 4px 15px rgba(0,0,0,0.1)"},panel:{position:"fixed",bottom:0,left:0,right:0,height:O?"600px":"0px",background:"#fff",zIndex:99998,boxShadow:"0 -4px 30px rgba(0,0,0,0.1)",transition:"height 0.3s cubic-bezier(0.4, 0, 0.2, 1)",display:"flex",flexDirection:"column"},sidebar:{width:"240px",borderRight:"1px solid #e5e7eb",padding:"24px",display:"flex",flexDirection:"column",gap:"8px",background:"#f9fafb"},main:{flex:1,padding:"32px 40px",overflowY:"auto",background:"#fff"},tab:(e,n)=>({padding:"12px 16px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:600,background:e?"#fff":"transparent",color:n?"#ef4444":e?"#2563eb":"#64748b",boxShadow:e?"0 1px 3px rgba(0,0,0,0.1)":"none",transition:"all 0.2s",border:n?"1px solid #fecaca":"none"}),keywordTag:(e,n)=>{let i=n>=80?"#10b981":n>=50?"#f59e0b":"#ef4444";return{background:e?i:"#f3f4f6",color:e?"white":"#374151",padding:"8px 16px",borderRadius:"20px",fontSize:"12px",fontWeight:700,marginRight:"8px",border:`2px solid ${i}`,display:"inline-flex",alignItems:"center",gap:"8px",cursor:"pointer",transition:"all 0.2s",opacity:e?1:.8}}};return(0,t.jsxs)("div",{id:"next-seo-checker-root",style:S.wrapper,children:[!O&&(0,t.jsxs)("div",{style:S.trigger,onClick:()=>k(!0),children:["Total Score: ",E]}),(0,t.jsxs)("div",{style:S.panel,children:[(0,t.jsxs)("div",{style:{height:"64px",padding:"0 40px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #e5e7eb"},children:[(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[(0,t.jsx)("span",{style:{fontSize:"20px"},children:"\u{1F680}"}),(0,t.jsx)("div",{style:{fontWeight:800,fontSize:"18px"},children:"Next SEO Checker"}),(0,t.jsxs)("div",{style:{background:E>=80?"#d1fae5":"#fef3c7",color:E>=80?"#059669":"#d97706",padding:"4px 12px",borderRadius:"12px",fontSize:"14px",fontWeight:800},children:["Page Health Score: ",E,"/100"]})]}),(0,t.jsx)("button",{onClick:()=>k(!1),style:{background:"none",border:"none",fontSize:"28px",cursor:"pointer",color:"#9ca3af"},children:"\xD7"})]}),(0,t.jsxs)("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[(0,t.jsxs)("div",{style:S.sidebar,children:[(0,t.jsx)("div",{style:S.tab(W==="general"),onClick:()=>J("general"),children:"\u2728 General"}),(0,t.jsxs)("div",{style:S.tab(W==="edit",L.titleError||L.descError),onClick:()=>J("edit"),children:["\u{1F4DD} Snippet Editor ",(L.titleError||L.descError)&&"\u26A0\uFE0F"]})]}),(0,t.jsxs)("div",{style:S.main,children:[W==="general"&&(0,t.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:[(0,t.jsxs)("div",{style:{background:"#f9fafb",padding:"24px",borderRadius:"15px",border:"1px solid #e5e7eb"},children:[(0,t.jsx)("div",{style:{fontSize:"11px",fontWeight:800,color:"#9ca3af",textTransform:"uppercase",marginBottom:"15px",letterSpacing:"0.5px"},children:"Keywords Performance (Select to view details)"}),(0,t.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"20px"},children:(ee=a.keywords)==null?void 0:ee.map((e,n)=>(0,t.jsxs)("span",{style:S.keywordTag(v===e,H[e]||0),onClick:()=>I(e),children:[n===0&&"\u2605 "," ",e,(0,t.jsx)("span",{onClick:i=>{var g;i.stopPropagation();let y=(g=a.keywords)==null?void 0:g.filter(d=>d!==e);Z(y||[])},style:{cursor:"pointer",opacity:.5},children:"\xD7"})]},e))}),(0,t.jsxs)("div",{style:{display:"flex",gap:"10px"},children:[(0,t.jsx)("input",{style:{flex:1,padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",outline:"none",fontSize:"14px"},value:M,onChange:e=>_(e.target.value),placeholder:"Add focus keyword..."}),(0,t.jsx)("button",{onClick:()=>{M&&(Z([...a.keywords||[],M]),_(""))},style:{padding:"0 24px",background:"#2563eb",color:"white",border:"none",borderRadius:"10px",fontWeight:700,cursor:"pointer"},children:"Add"})]})]}),le.map(e=>(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{style:{fontSize:"12px",fontWeight:800,color:"#9ca3af",textTransform:"uppercase",marginBottom:"12px",marginLeft:"4px"},children:e.title}),(0,t.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:"12px"},children:e.items.map(n=>(0,t.jsxs)("div",{style:{padding:"16px",borderRadius:"12px",border:"1px solid #f3f4f6",background:"#fff",display:"flex",gap:"12px",alignItems:"flex-start",borderLeft:`4px solid ${n.status==="success"?"#10b981":n.status==="warning"?"#f59e0b":"#ef4444"}`},children:[(0,t.jsx)("div",{style:{fontSize:"16px"},children:n.status==="success"?"\u2705":n.status==="warning"?"\u26A0\uFE0F":"\u274C"}),(0,t.jsxs)("div",{children:[(0,t.jsx)("div",{style:{fontSize:"14px",fontWeight:700,marginBottom:"2px"},children:n.label}),(0,t.jsx)("div",{style:{fontSize:"12px",color:"#6b7280"},children:n.message})]})]},n.id))})]},e.title))]}),W==="edit"&&(0,t.jsx)("div",{style:{maxWidth:"650px"},children:(0,t.jsxs)("div",{style:{background:"#fff",padding:"32px",borderRadius:"15px",border:"1px solid #e5e7eb",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[(0,t.jsxs)("div",{style:{marginBottom:"24px"},children:[(0,t.jsx)("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"SEO Title"}),(0,t.jsx)("input",{style:{width:"100%",padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",fontSize:"15px",outline:"none"},value:B,onChange:e=>j(e.target.value)}),(0,t.jsxs)("div",{style:{fontSize:"11px",marginTop:"6px",color:B.length>60?"#ef4444":"#9ca3af"},children:[B.length," / 60 characters"]})]}),(0,t.jsxs)("div",{style:{marginBottom:"24px"},children:[(0,t.jsx)("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"Permalink (Slug)"}),(0,t.jsxs)("div",{style:{display:"flex",alignItems:"center",background:"#f3f4f6",borderRadius:"10px",padding:"0 12px",border:"1px solid #d1d5db",opacity:.7},children:[(0,t.jsx)("span",{style:{fontSize:"13px",color:"#9ca3af",marginRight:"4px"},children:"/"}),(0,t.jsx)("input",{style:{flex:1,background:"transparent",border:"none",padding:"12px 4px",fontSize:"15px",outline:"none",cursor:"not-allowed"},value:V,readOnly:!0})]}),(0,t.jsx)("div",{style:{fontSize:"11px",marginTop:"6px",color:"#9ca3af"},children:"Permalink is managed by the page structure and cannot be edited here."})]}),(0,t.jsxs)("div",{style:{marginBottom:"32px"},children:[(0,t.jsx)("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"Meta Description"}),(0,t.jsx)("textarea",{style:{width:"100%",padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",fontSize:"15px",minHeight:"120px",outline:"none",resize:"vertical"},value:K,onChange:e=>F(e.target.value)}),(0,t.jsxs)("div",{style:{fontSize:"11px",marginTop:"6px",color:K.length>160?"#ef4444":"#9ca3af"},children:[K.length," / 160 characters"]})]}),(0,t.jsx)("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:(0,t.jsx)("button",{onClick:de,style:{padding:"12px 24px",background:"#2563eb",color:"white",border:"none",borderRadius:"10px",fontWeight:700,cursor:"pointer",fontSize:"14px"},children:"Save to Project (Server-Side)"})})]})})]})]})]})]})}0&&(module.exports={NextSeoChecker});
package/dist/client.mjs CHANGED
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- var ee=Object.defineProperty,te=Object.defineProperties;var oe=Object.getOwnPropertyDescriptors;var V=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,ne=Object.prototype.propertyIsEnumerable;var Y=(s,r,p)=>r in s?ee(s,r,{enumerable:!0,configurable:!0,writable:!0,value:p}):s[r]=p,W=(s,r)=>{for(var p in r||(r={}))ie.call(r,p)&&Y(s,p,r[p]);if(V)for(var p of V(r))ne.call(r,p)&&Y(s,p,r[p]);return s},L=(s,r)=>te(s,oe(r));import{useEffect as _,useState as m,useMemo as Q,useCallback as se,useRef as re}from"react";import{usePathname as ae}from"next/navigation";import{jsx as o,jsxs as n}from"react/jsx-runtime";function de(){var H;let s=ae(),[r,p]=m(!1),[P,N]=m(!1),[D,j]=m("general"),[y,O]=m({}),[T,R]=m(""),[z,B]=m(""),[M,K]=m(""),[E,F]=m(""),[w,X]=m({h1s:[],h2s:[],h3s:[],bodyText:"",images:[],url:"",wordCount:0}),A=process.env.NODE_ENV==="development",q=re(0),U=se(async()=>{var e,t;try{let i=await(await fetch("/api/seo/save")).json(),a=i[s];if(!a){let x=s.replace(/^\//,""),f=Object.keys(i).find(l=>i[l].slug===x);f&&(a=i[f])}if(a)O(a),R(a.title||""),B(a.description||""),K(a.slug||"");else if(typeof document!="undefined"){let x=document.title,f=((e=document.querySelector('meta[name="description"]'))==null?void 0:e.getAttribute("content"))||"",l=((t=document.querySelector('meta[name="keywords"]'))==null?void 0:t.getAttribute("content"))||"",c=l?l.split(",").map(C=>C.trim()).filter(Boolean):[],h={title:x,description:f,keywords:c,slug:s.split("/").filter(Boolean).pop()||"home"};O(h),R(x),B(f),K(h.slug||"")}}catch(d){console.error("Failed to load SEO data")}},[s]);_(()=>{if(p(!0),A){let e=setTimeout(U,500);return()=>clearTimeout(e)}},[A,U]);let Z=async()=>{let e=L(W({},y),{title:T,description:z,slug:M});try{if((await fetch("/api/seo/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pathname:s,overrides:e})})).ok&&(O(e),alert("SEO Changes & Permalink Mapping Saved! \u{1F680}"),typeof document!="undefined")){document.title=T;let d=document.querySelector('meta[name="description"]');d&&d.setAttribute("content",z)}}catch(t){alert("Failed to save to project.")}},$=async e=>{let t=L(W({},y),{keywords:e});try{await fetch("/api/seo/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pathname:s,overrides:t})}),O(t)}catch(d){}};_(()=>{if(!r)return;let e=()=>{if(typeof document=="undefined")return;let i=Date.now();if(i-q.current<2e3)return;q.current=i;let a=Array.from(document.getElementsByTagName("h1")).map(u=>u.innerText),x=Array.from(document.getElementsByTagName("h2")).map(u=>u.innerText),f=Array.from(document.getElementsByTagName("h3")).map(u=>u.innerText),l=document.getElementById("next-seo-checker-root"),c=document.body.innerText;l&&(c=c.replace(l.innerText,""));let h=Array.from(document.getElementsByTagName("img")).filter(u=>!(l!=null&&l.contains(u))).map(u=>({alt:u.alt})),C=c.trim()===""?0:c.trim().split(/\s+/).length;X({h1s:a,h2s:x,h3s:f,bodyText:c,images:h,url:window.location.pathname,wordCount:C})},t=setTimeout(e,1e3),d=new MutationObserver(i=>{let a=document.getElementById("next-seo-checker-root");i.some(f=>!(a!=null&&a.contains(f.target)))&&e()});return d.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),()=>{clearTimeout(t),d.disconnect()}},[s,r]);let I=Q(()=>{var C,u;if(!r)return[];let e=(y.title||(typeof document!="undefined"?document.title:"")).toLowerCase(),t=(y.description||(typeof document!="undefined"?(C=document.querySelector('meta[name="description"]'))==null?void 0:C.getAttribute("content"):"")||"").toLowerCase(),d=y.keywords||[],i=((u=d[0])==null?void 0:u.toLowerCase())||"",a=d.slice(1).map(g=>g.toLowerCase()),x=w.bodyText.toLowerCase(),f=y.slug||(s==="/"?"home":s.split("/").filter(Boolean).pop())||"",l=[{title:"Basic SEO",items:[]},{title:"Additional",items:[]},{title:"Title Readability",items:[]},{title:"Content Readability",items:[]}],c=l[0].items;if(i){let g=e.includes(i);c.push({id:"key-title",label:"Primary Keyword in Title",status:g?"success":"error",message:g?"Perfect! Keyword found in title.":"Critical: Primary keyword missing in title!"});let S=t.includes(i);c.push({id:"key-desc",label:"Primary Keyword in Description",status:S?"success":"error",message:S?"Keyword found in description.":"Critical: Primary keyword missing in description!"});let v=i.replace(/\s+/g,"-"),J=f.toLowerCase().includes(v);c.push({id:"key-url",label:"Keyword in Permalink",status:J?"success":"error",message:J?"Focus keyword used in URL slug.":"Error: Focus keyword not found in your URL slug!"});let G=x.substring(0,500).includes(i);c.push({id:"key-start",label:"Keyword in beginning",status:G?"success":"warning",message:G?"Keyword found at content start.":"Try using keyword in the first 10% of content."})}c.push({id:"word-count",label:"Word Count",status:w.wordCount>600?"success":"warning",message:`${w.wordCount} words. (Target: 600+)`});let h=l[1].items;if(a.length>0&&a.forEach((g,S)=>{let v=x.includes(g)||e.includes(g)||t.includes(g);h.push({id:`sec-key-${S}`,label:`Secondary Keyword: ${g}`,status:v?"success":"error",message:v?"Keyword used in content.":"Error: This keyword is not found anywhere!"})}),i){let g=[...w.h2s,...w.h3s].some(v=>v.toLowerCase().includes(i));h.push({id:"key-sub",label:"Primary in Subheadings",status:g?"success":"warning",message:g?"Keyword found in H2/H3.":"Focus keyword not found in subheadings."});let S=w.images.some(v=>v.alt.toLowerCase().includes(i));h.push({id:"key-alt",label:"Image Alt Tags",status:S?"success":"warning",message:S?"Keyword found in image alt text.":"Add your focus keyword to image alt tags."})}return l},[w,y,r]),k=Q(()=>{let e=0,t=0;return I.forEach(d=>d.items.forEach(i=>{t++,i.status==="success"?e++:i.status==="warning"&&(e+=.5)})),t===0?0:Math.round(e/t*100)},[I]);if(!A||!r)return null;let b={wrapper:{fontFamily:"-apple-system, system-ui, sans-serif",color:"#111827"},trigger:{position:"fixed",bottom:"20px",right:"20px",zIndex:99999,background:k>=80?"#10b981":k>=50?"#f59e0b":"#ef4444",color:"white",padding:"10px 20px",borderRadius:"30px",cursor:"pointer",fontWeight:800,border:"2px solid white",boxShadow:"0 4px 15px rgba(0,0,0,0.1)"},panel:{position:"fixed",bottom:0,left:0,right:0,height:P?"600px":"0px",background:"#fff",zIndex:99998,boxShadow:"0 -4px 30px rgba(0,0,0,0.1)",transition:"height 0.3s cubic-bezier(0.4, 0, 0.2, 1)",display:"flex",flexDirection:"column"},sidebar:{width:"240px",borderRight:"1px solid #e5e7eb",padding:"24px",display:"flex",flexDirection:"column",gap:"8px",background:"#f9fafb"},main:{flex:1,padding:"32px 40px",overflowY:"auto",background:"#fff"},tab:e=>({padding:"12px 16px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:600,background:e?"#fff":"transparent",color:e?"#2563eb":"#64748b",boxShadow:e?"0 1px 3px rgba(0,0,0,0.1)":"none",transition:"all 0.2s"}),keywordTag:e=>({background:e?"#dcfce7":"#f3f4f6",color:e?"#15803d":"#374151",padding:"6px 12px",borderRadius:"20px",fontSize:"12px",fontWeight:700,marginRight:"8px",border:"1px solid #e2e8f0",display:"inline-flex",alignItems:"center",gap:"4px"})};return n("div",{id:"next-seo-checker-root",style:b.wrapper,children:[!P&&n("div",{style:b.trigger,onClick:()=>N(!0),children:["SEO Score ",k]}),n("div",{style:b.panel,children:[n("div",{style:{height:"64px",padding:"0 40px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #e5e7eb"},children:[n("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[o("span",{style:{fontSize:"20px"},children:"\u{1F680}"}),o("div",{style:{fontWeight:800,fontSize:"18px"},children:"Next SEO Checker"}),n("div",{style:{background:k>=80?"#d1fae5":"#fef3c7",color:k>=80?"#059669":"#d97706",padding:"4px 12px",borderRadius:"12px",fontSize:"14px",fontWeight:800},children:[k,"/100"]})]}),o("button",{onClick:()=>N(!1),style:{background:"none",border:"none",fontSize:"28px",cursor:"pointer",color:"#9ca3af"},children:"\xD7"})]}),n("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[n("div",{style:b.sidebar,children:[o("div",{style:b.tab(D==="general"),onClick:()=>j("general"),children:"\u2728 General"}),o("div",{style:b.tab(D==="edit"),onClick:()=>j("edit"),children:"\u{1F4DD} Snippet Editor"})]}),n("div",{style:b.main,children:[D==="general"&&n("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:[n("div",{style:{background:"#f9fafb",padding:"24px",borderRadius:"15px",border:"1px solid #e5e7eb"},children:[o("div",{style:{fontSize:"11px",fontWeight:800,color:"#9ca3af",textTransform:"uppercase",marginBottom:"15px",letterSpacing:"0.5px"},children:"Focus Keywords"}),n("div",{style:{display:"flex",gap:"10px",marginBottom:"15px"},children:[o("input",{style:{flex:1,padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",outline:"none",fontSize:"14px"},value:E,onChange:e=>F(e.target.value),placeholder:"Add focus keyword..."}),o("button",{onClick:()=>{E&&($([...y.keywords||[],E]),F(""))},style:{padding:"0 24px",background:"#2563eb",color:"white",border:"none",borderRadius:"10px",fontWeight:700,cursor:"pointer"},children:"Add"})]}),o("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px"},children:(H=y.keywords)==null?void 0:H.map((e,t)=>n("span",{style:b.keywordTag(t===0),children:[t===0&&"\u2605 "," ",e,o("span",{onClick:()=>{var i;let d=(i=y.keywords)==null?void 0:i.filter(a=>a!==e);$(d||[])},style:{cursor:"pointer",opacity:.5,marginLeft:"4px"},children:"\xD7"})]},e))})]}),I.map(e=>n("div",{children:[o("div",{style:{fontSize:"12px",fontWeight:800,color:"#9ca3af",textTransform:"uppercase",marginBottom:"12px",marginLeft:"4px"},children:e.title}),o("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:"12px"},children:e.items.map(t=>n("div",{style:{padding:"16px",borderRadius:"12px",border:"1px solid #f3f4f6",background:"#fff",display:"flex",gap:"12px",alignItems:"flex-start",borderLeft:`4px solid ${t.status==="success"?"#10b981":t.status==="warning"?"#f59e0b":"#ef4444"}`},children:[o("div",{style:{fontSize:"16px"},children:t.status==="success"?"\u2705":t.status==="warning"?"\u26A0\uFE0F":"\u274C"}),n("div",{children:[o("div",{style:{fontSize:"14px",fontWeight:700,marginBottom:"2px"},children:t.label}),o("div",{style:{fontSize:"12px",color:"#6b7280"},children:t.message})]})]},t.id))})]},e.title))]}),D==="edit"&&o("div",{style:{maxWidth:"650px"},children:n("div",{style:{background:"#fff",padding:"32px",borderRadius:"15px",border:"1px solid #e5e7eb",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[n("div",{style:{marginBottom:"24px"},children:[o("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"SEO Title"}),o("input",{style:{width:"100%",padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",fontSize:"15px",outline:"none"},value:T,onChange:e=>R(e.target.value)}),n("div",{style:{fontSize:"11px",marginTop:"6px",color:T.length>60?"#ef4444":"#9ca3af"},children:[T.length," / 60 characters"]})]}),n("div",{style:{marginBottom:"24px"},children:[o("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"Permalink (Slug)"}),n("div",{style:{display:"flex",alignItems:"center",background:"#f3f4f6",borderRadius:"10px",padding:"0 12px",border:"1px solid #d1d5db"},children:[o("span",{style:{fontSize:"13px",color:"#9ca3af",marginRight:"4px"},children:"/"}),o("input",{style:{flex:1,background:"transparent",border:"none",padding:"12px 4px",fontSize:"15px",outline:"none"},value:M,onChange:e=>K(e.target.value.replace(/\s+/g,"-").toLowerCase())})]})]}),n("div",{style:{marginBottom:"32px"},children:[o("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"Meta Description"}),o("textarea",{style:{width:"100%",padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",fontSize:"15px",minHeight:"120px",outline:"none",resize:"vertical"},value:z,onChange:e=>B(e.target.value)}),n("div",{style:{fontSize:"11px",marginTop:"6px",color:z.length>160?"#ef4444":"#9ca3af"},children:[z.length," / 160 characters"]})]}),o("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:o("button",{onClick:Z,style:{padding:"12px 24px",background:"#2563eb",color:"white",border:"none",borderRadius:"10px",fontWeight:700,cursor:"pointer",fontSize:"14px"},children:"Save to Project (Server-Side)"})})]})})]})]})]})]})}export{de as NextSeoChecker};
2
+ var pe=Object.defineProperty,ue=Object.defineProperties;var ge=Object.getOwnPropertyDescriptors;var ie=Object.getOwnPropertySymbols;var fe=Object.prototype.hasOwnProperty,ye=Object.prototype.propertyIsEnumerable;var re=(r,d,f)=>d in r?pe(r,d,{enumerable:!0,configurable:!0,writable:!0,value:f}):r[d]=f,H=(r,d)=>{for(var f in d||(d={}))fe.call(d,f)&&re(r,f,d[f]);if(ie)for(var f of ie(d))ye.call(d,f)&&re(r,f,d[f]);return r},U=(r,d)=>ue(r,ge(d));import{useEffect as G,useState as v,useMemo as L,useCallback as J,useRef as me}from"react";import{usePathname as xe}from"next/navigation";import{jsx as s,jsxs as i}from"react/jsx-runtime";function be(){var oe;let r=xe(),[d,f]=v(!1),[V,Y]=v(!1),[P,_]=v("general"),[o,W]=v({}),[O,$]=v(""),[B,j]=v(""),[Q,X]=v(""),[F,Z]=v(""),[w,K]=v(null),[k,ae]=v({h1s:[],h2s:[],h3s:[],bodyText:"",images:[],url:"",wordCount:0,links:[]}),M=process.env.NODE_ENV==="development",ee=me(0);G(()=>{var e;(e=o.keywords)!=null&&e.length&&!w&&K(o.keywords[0])},[o.keywords,w]);let te=J(async()=>{var e,t,n;try{let u=await(await fetch("/api/seo/save")).json(),a=u[r];if(!a){let b=r.replace(/^\//,""),p=Object.keys(u).find(g=>u[g].slug===b);p&&(a=u[p])}if(a)W(a),$(a.title||""),j(a.description||""),X(a.slug||""),(e=a.keywords)!=null&&e.length&&K(a.keywords[0]);else if(typeof document!="undefined"){let b=document.title,p=((t=document.querySelector('meta[name="description"]'))==null?void 0:t.getAttribute("content"))||"",g=((n=document.querySelector('meta[name="keywords"]'))==null?void 0:n.getAttribute("content"))||"",C=g?g.split(",").map(z=>z.trim()).filter(Boolean):[],l={title:b,description:p,keywords:C,slug:r.split("/").filter(Boolean).pop()||"home"};W(l),$(b),j(p),X(l.slug||""),C.length&&K(C[0])}}catch(y){console.error("Failed to load SEO data")}},[r]);G(()=>{if(f(!0),M){let e=setTimeout(te,500);return()=>clearTimeout(e)}},[M,te]);let de=async()=>{let e=U(H({},o),{title:O,description:B,slug:Q});try{if((await fetch("/api/seo/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pathname:r,overrides:e})})).ok&&(W(e),alert("SEO Changes & Permalink Mapping Saved! \u{1F680}"),typeof document!="undefined")){document.title=O;let n=document.querySelector('meta[name="description"]');n&&n.setAttribute("content",B)}}catch(t){alert("Failed to save to project.")}},ne=async e=>{let t=U(H({},o),{keywords:e});try{await fetch("/api/seo/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pathname:r,overrides:t})}),W(t),e.length>0&&(!w||!e.includes(w))&&K(e[e.length-1])}catch(n){}};G(()=>{if(!d)return;let e=()=>{if(typeof document=="undefined")return;let y=Date.now();if(y-ee.current<2e3)return;ee.current=y;let u=Array.from(document.getElementsByTagName("h1")).map(c=>c.innerText),a=Array.from(document.getElementsByTagName("h2")).map(c=>c.innerText),b=Array.from(document.getElementsByTagName("h3")).map(c=>c.innerText),p=document.getElementById("next-seo-checker-root"),g=document.body.innerText;p&&(g=g.replace(p.innerText,""));let C=Array.from(document.getElementsByTagName("img")).filter(c=>!(p!=null&&p.contains(c))).map(c=>({alt:c.alt})),l=Array.from(document.getElementsByTagName("a")).filter(c=>!(p!=null&&p.contains(c))).map(c=>({href:c.href,rel:c.rel})),z=g.trim()===""?0:g.trim().split(/\s+/).length;ae({h1s:u,h2s:a,h3s:b,bodyText:g,images:C,url:window.location.pathname,wordCount:z,links:l})},t=setTimeout(e,1e3),n=new MutationObserver(y=>{let u=document.getElementById("next-seo-checker-root");y.some(b=>!(u!=null&&u.contains(b.target)))&&e()});return n.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),()=>{clearTimeout(t),n.disconnect()}},[r,d]);let T=J(e=>e.replace(/İ/g,"i").replace(/I/g,"\u0131").toLowerCase().replace(/[ğĞ]/g,"g").replace(/[üÜ]/g,"u").replace(/[şŞ]/g,"s").replace(/[ıİi]/g,"i").replace(/[öÖ]/g,"o").replace(/[çÇ]/g,"c").trim(),[]),D=J(e=>{var c,se;let t=o.title||(typeof document!="undefined"?document.title:""),n=o.description||(typeof document!="undefined"?(c=document.querySelector('meta[name="description"]'))==null?void 0:c.getAttribute("content"):"")||"",y=T(t),u=T(n),a=e?T(e):"",b=T(k.bodyText),p=T(o.slug||(r==="/"?"home":r.split("/").filter(Boolean).pop())||""),g=e===((se=o.keywords)==null?void 0:se[0]),C=!o.keywords||o.keywords.length===0,l=[];if(g||C||e===null){let m=t.length;l.push({id:"title-length",label:"Title Length",status:m>60?"error":m<30?"warning":"success",message:m>60?`Too long (${m}/60). Truncated in search.`:m<30?`Too short (${m}). Use more space!`:`Good length (${m}/60).`});let x=n.length;l.push({id:"desc-length",label:"Description Length",status:x>160?"error":x<120?"warning":"success",message:x>160?`Too long (${x}/160). Truncated in search.`:x<120?`Too short (${x}). Aim for 120-160.`:`Good length (${x}/160).`}),l.push({id:"word-count",label:"Word Count",status:k.wordCount>600?"success":"warning",message:`${k.wordCount} words. (Target: 600+)`});let I=typeof window!="undefined"?window.location.host:"",R=k.links.filter(A=>{try{return new URL(A.href).host!==I}catch(ce){return!1}}),h=R.some(A=>!A.rel.includes("nofollow"));l.push({id:"ext-links",label:"External Links",status:R.length>0&&h?"success":"warning",message:R.length>0?h?"Great! At least one external link with DoFollow found.":"External links found but all are NoFollow.":"No external links found."})}if(a){if(g){let h=y.includes(a);l.push({id:"key-title",label:"Primary Keyword in Title",status:h?"success":"error",message:h?"Keyword found in title.":"Keyword missing in title!"});let A=u.includes(a);l.push({id:"key-desc",label:"Primary Keyword in Description",status:A?"success":"error",message:A?"Keyword found in description.":"Keyword missing in description!"})}if(r!=="/"&&g){let h=p.includes(a.replace(/\s+/g,"-"));l.push({id:"key-url",label:"Keyword in Permalink",status:h?"success":"error",message:h?"Keyword used in URL.":"Keyword not found in URL!"})}let m=new RegExp(a,"gi"),x=(b.match(m)||[]).length,I=k.wordCount>0?x/k.wordCount*100:0;l.push({id:"key-density",label:"Keyword Density",status:I>3||I<.5&&x<2?"warning":"success",message:`Density: ${I.toFixed(2)}% (${x} times).`});let R=[...k.h2s,...k.h3s].some(h=>T(h).includes(a));l.push({id:"key-sub",label:"Keyword in Subheadings",status:R?"success":"warning",message:R?"Keyword found in H2/H3.":"Keyword missing in subheadings."})}let z=0;return l.forEach(m=>{m.status==="success"?z++:m.status==="warning"&&(z+=.5)}),{items:l,score:l.length===0?0:Math.round(z/l.length*100)}},[k,o,T,r]),q=L(()=>{var t;let e={};return(t=o.keywords)==null||t.forEach(n=>{e[n]=D(n).score}),e},[o.keywords,D]),N=L(()=>{var n;let e=o.title||(typeof document!="undefined"?document.title:""),t=o.description||(typeof document!="undefined"?(n=document.querySelector('meta[name="description"]'))==null?void 0:n.getAttribute("content"):"")||"";return{titleError:e.length>60,descError:t.length>160}},[o.title,o.description]),le=L(()=>{var n;if(!d)return[];let{items:e}=D(w);return[{title:(w===((n=o.keywords)==null?void 0:n[0])?"Primary":"Secondary")+" Keyword Analysis: "+(w||""),items:e}]},[d,D,w,o.keywords]),E=L(()=>{let e=o.keywords||[];if(e.length===0)return D(null).score;let t=Object.values(q).reduce((n,y)=>n+y,0);return Math.round(t/e.length)},[q,o.keywords,D]);if(!M||!d)return null;let S={wrapper:{fontFamily:"-apple-system, system-ui, sans-serif",color:"#111827"},trigger:{position:"fixed",bottom:"20px",right:"20px",zIndex:99999,background:E>=80?"#10b981":E>=50?"#f59e0b":"#ef4444",color:"white",padding:"10px 20px",borderRadius:"30px",cursor:"pointer",fontWeight:800,border:"2px solid white",boxShadow:"0 4px 15px rgba(0,0,0,0.1)"},panel:{position:"fixed",bottom:0,left:0,right:0,height:V?"600px":"0px",background:"#fff",zIndex:99998,boxShadow:"0 -4px 30px rgba(0,0,0,0.1)",transition:"height 0.3s cubic-bezier(0.4, 0, 0.2, 1)",display:"flex",flexDirection:"column"},sidebar:{width:"240px",borderRight:"1px solid #e5e7eb",padding:"24px",display:"flex",flexDirection:"column",gap:"8px",background:"#f9fafb"},main:{flex:1,padding:"32px 40px",overflowY:"auto",background:"#fff"},tab:(e,t)=>({padding:"12px 16px",borderRadius:"8px",cursor:"pointer",fontSize:"14px",fontWeight:600,background:e?"#fff":"transparent",color:t?"#ef4444":e?"#2563eb":"#64748b",boxShadow:e?"0 1px 3px rgba(0,0,0,0.1)":"none",transition:"all 0.2s",border:t?"1px solid #fecaca":"none"}),keywordTag:(e,t)=>{let n=t>=80?"#10b981":t>=50?"#f59e0b":"#ef4444";return{background:e?n:"#f3f4f6",color:e?"white":"#374151",padding:"8px 16px",borderRadius:"20px",fontSize:"12px",fontWeight:700,marginRight:"8px",border:`2px solid ${n}`,display:"inline-flex",alignItems:"center",gap:"8px",cursor:"pointer",transition:"all 0.2s",opacity:e?1:.8}}};return i("div",{id:"next-seo-checker-root",style:S.wrapper,children:[!V&&i("div",{style:S.trigger,onClick:()=>Y(!0),children:["Total Score: ",E]}),i("div",{style:S.panel,children:[i("div",{style:{height:"64px",padding:"0 40px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #e5e7eb"},children:[i("div",{style:{display:"flex",alignItems:"center",gap:"15px"},children:[s("span",{style:{fontSize:"20px"},children:"\u{1F680}"}),s("div",{style:{fontWeight:800,fontSize:"18px"},children:"Next SEO Checker"}),i("div",{style:{background:E>=80?"#d1fae5":"#fef3c7",color:E>=80?"#059669":"#d97706",padding:"4px 12px",borderRadius:"12px",fontSize:"14px",fontWeight:800},children:["Page Health Score: ",E,"/100"]})]}),s("button",{onClick:()=>Y(!1),style:{background:"none",border:"none",fontSize:"28px",cursor:"pointer",color:"#9ca3af"},children:"\xD7"})]}),i("div",{style:{display:"flex",flex:1,overflow:"hidden"},children:[i("div",{style:S.sidebar,children:[s("div",{style:S.tab(P==="general"),onClick:()=>_("general"),children:"\u2728 General"}),i("div",{style:S.tab(P==="edit",N.titleError||N.descError),onClick:()=>_("edit"),children:["\u{1F4DD} Snippet Editor ",(N.titleError||N.descError)&&"\u26A0\uFE0F"]})]}),i("div",{style:S.main,children:[P==="general"&&i("div",{style:{display:"flex",flexDirection:"column",gap:"24px"},children:[i("div",{style:{background:"#f9fafb",padding:"24px",borderRadius:"15px",border:"1px solid #e5e7eb"},children:[s("div",{style:{fontSize:"11px",fontWeight:800,color:"#9ca3af",textTransform:"uppercase",marginBottom:"15px",letterSpacing:"0.5px"},children:"Keywords Performance (Select to view details)"}),s("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px",marginBottom:"20px"},children:(oe=o.keywords)==null?void 0:oe.map((e,t)=>i("span",{style:S.keywordTag(w===e,q[e]||0),onClick:()=>K(e),children:[t===0&&"\u2605 "," ",e,s("span",{onClick:n=>{var u;n.stopPropagation();let y=(u=o.keywords)==null?void 0:u.filter(a=>a!==e);ne(y||[])},style:{cursor:"pointer",opacity:.5},children:"\xD7"})]},e))}),i("div",{style:{display:"flex",gap:"10px"},children:[s("input",{style:{flex:1,padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",outline:"none",fontSize:"14px"},value:F,onChange:e=>Z(e.target.value),placeholder:"Add focus keyword..."}),s("button",{onClick:()=>{F&&(ne([...o.keywords||[],F]),Z(""))},style:{padding:"0 24px",background:"#2563eb",color:"white",border:"none",borderRadius:"10px",fontWeight:700,cursor:"pointer"},children:"Add"})]})]}),le.map(e=>i("div",{children:[s("div",{style:{fontSize:"12px",fontWeight:800,color:"#9ca3af",textTransform:"uppercase",marginBottom:"12px",marginLeft:"4px"},children:e.title}),s("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:"12px"},children:e.items.map(t=>i("div",{style:{padding:"16px",borderRadius:"12px",border:"1px solid #f3f4f6",background:"#fff",display:"flex",gap:"12px",alignItems:"flex-start",borderLeft:`4px solid ${t.status==="success"?"#10b981":t.status==="warning"?"#f59e0b":"#ef4444"}`},children:[s("div",{style:{fontSize:"16px"},children:t.status==="success"?"\u2705":t.status==="warning"?"\u26A0\uFE0F":"\u274C"}),i("div",{children:[s("div",{style:{fontSize:"14px",fontWeight:700,marginBottom:"2px"},children:t.label}),s("div",{style:{fontSize:"12px",color:"#6b7280"},children:t.message})]})]},t.id))})]},e.title))]}),P==="edit"&&s("div",{style:{maxWidth:"650px"},children:i("div",{style:{background:"#fff",padding:"32px",borderRadius:"15px",border:"1px solid #e5e7eb",boxShadow:"0 1px 3px rgba(0,0,0,0.05)"},children:[i("div",{style:{marginBottom:"24px"},children:[s("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"SEO Title"}),s("input",{style:{width:"100%",padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",fontSize:"15px",outline:"none"},value:O,onChange:e=>$(e.target.value)}),i("div",{style:{fontSize:"11px",marginTop:"6px",color:O.length>60?"#ef4444":"#9ca3af"},children:[O.length," / 60 characters"]})]}),i("div",{style:{marginBottom:"24px"},children:[s("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"Permalink (Slug)"}),i("div",{style:{display:"flex",alignItems:"center",background:"#f3f4f6",borderRadius:"10px",padding:"0 12px",border:"1px solid #d1d5db",opacity:.7},children:[s("span",{style:{fontSize:"13px",color:"#9ca3af",marginRight:"4px"},children:"/"}),s("input",{style:{flex:1,background:"transparent",border:"none",padding:"12px 4px",fontSize:"15px",outline:"none",cursor:"not-allowed"},value:Q,readOnly:!0})]}),s("div",{style:{fontSize:"11px",marginTop:"6px",color:"#9ca3af"},children:"Permalink is managed by the page structure and cannot be edited here."})]}),i("div",{style:{marginBottom:"32px"},children:[s("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"Meta Description"}),s("textarea",{style:{width:"100%",padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",fontSize:"15px",minHeight:"120px",outline:"none",resize:"vertical"},value:B,onChange:e=>j(e.target.value)}),i("div",{style:{fontSize:"11px",marginTop:"6px",color:B.length>160?"#ef4444":"#9ca3af"},children:[B.length," / 160 characters"]})]}),s("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:s("button",{onClick:de,style:{padding:"12px 24px",background:"#2563eb",color:"white",border:"none",borderRadius:"10px",fontWeight:700,cursor:"pointer",fontSize:"14px"},children:"Save to Project (Server-Side)"})})]})})]})]})]})]})}export{be as NextSeoChecker};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-seo-checker",
3
- "version": "1.5.0",
3
+ "version": "1.6.0",
4
4
  "description": "Professional live SEO optimizer and permalink management suite for Next.js.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -59,4 +59,4 @@
59
59
  "tsup": "^8.3.5",
60
60
  "typescript": "^5"
61
61
  }
62
- }
62
+ }