next-seo-checker 1.3.0 → 1.5.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.
@@ -0,0 +1,8 @@
1
+ import { NextResponse } from 'next/server';
2
+
3
+ declare function POST(req: Request): Promise<NextResponse<{
4
+ success: boolean;
5
+ }>>;
6
+ declare function GET(): Promise<NextResponse<any>>;
7
+
8
+ export { GET, POST };
@@ -0,0 +1,8 @@
1
+ import { NextResponse } from 'next/server';
2
+
3
+ declare function POST(req: Request): Promise<NextResponse<{
4
+ success: boolean;
5
+ }>>;
6
+ declare function GET(): Promise<NextResponse<any>>;
7
+
8
+ export { GET, POST };
@@ -0,0 +1 @@
1
+ "use strict";var l=Object.create;var c=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,j=Object.prototype.hasOwnProperty;var m=(r,e)=>{for(var s in e)c(r,s,{get:e[s],enumerable:!0})},f=(r,e,s,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of S(e))!j.call(r,t)&&t!==s&&c(r,t,{get:()=>e[t],enumerable:!(a=p(e,t))||a.enumerable});return r};var d=(r,e,s)=>(s=r!=null?l(y(r)):{},f(e||!r||!r.__esModule?c(s,"default",{value:r,enumerable:!0}):s,r)),O=r=>f(c({},"__esModule",{value:!0}),r);var x={};m(x,{GET:()=>v,POST:()=>h});module.exports=O(x);var o=require("next/server"),n=d(require("fs")),u=d(require("path"));async function h(r){try{let e=await r.json(),{pathname:s,overrides:a}=e,t=u.default.join(process.cwd(),"seo-overrides.json"),i={};return n.default.existsSync(t)&&(i=JSON.parse(n.default.readFileSync(t,"utf-8"))),i[s]=a,n.default.writeFileSync(t,JSON.stringify(i,null,2)),o.NextResponse.json({success:!0})}catch(e){return console.error("SEO Save Error:",e),o.NextResponse.json({success:!1,error:"Failed to save SEO data"},{status:500})}}async function v(){try{let r=u.default.join(process.cwd(),"seo-overrides.json");if(!n.default.existsSync(r))return o.NextResponse.json({});let e=JSON.parse(n.default.readFileSync(r,"utf-8"));return o.NextResponse.json(e)}catch(r){return o.NextResponse.json({})}}0&&(module.exports={GET,POST});
@@ -0,0 +1 @@
1
+ import"./chunk-HGGX55FR.mjs";import{NextResponse as s}from"next/server";import t from"fs";import a from"path";async function l(r){try{let e=await r.json(),{pathname:c,overrides:i}=e,o=a.join(process.cwd(),"seo-overrides.json"),n={};return t.existsSync(o)&&(n=JSON.parse(t.readFileSync(o,"utf-8"))),n[c]=i,t.writeFileSync(o,JSON.stringify(n,null,2)),s.json({success:!0})}catch(e){return console.error("SEO Save Error:",e),s.json({success:!1,error:"Failed to save SEO data"},{status:500})}}async function p(){try{let r=a.join(process.cwd(),"seo-overrides.json");if(!t.existsSync(r))return s.json({});let e=JSON.parse(t.readFileSync(r,"utf-8"));return s.json(e)}catch(r){return s.json({})}}export{p as GET,l as POST};
package/dist/client.js CHANGED
@@ -1 +1,2 @@
1
- "use strict";var D=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?D(i,o,{enumerable:!0,configurable:!0,writable:!0,value:d}):i[o]=d,I=(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},W=(i,o)=>te(i,ie(o));var re=(i,o)=>{for(var d in o)D(i,d,{get:o[d],enumerable:!0})},ae=(i,o,d,k)=>{if(o&&typeof o=="object"||typeof o=="function")for(let y of ne(o))!_.call(i,y)&&y!==d&&D(i,y,{get:()=>o[y],enumerable:!(k=oe(o,y))||k.enumerable});return i};var de=i=>ae(D({},"__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),[k,y]=(0,r.useState)(!1),[R,L]=(0,r.useState)("general"),[f,E]=(0,r.useState)({}),[C,P]=(0,r.useState)(""),[T,N]=(0,r.useState)(""),[j,F]=(0,r.useState)(""),[B,M]=(0,r.useState)(""),[h,Z]=(0,r.useState)({h1s:[],h2s:[],h3s:[],bodyText:"",images:[],url:"",wordCount:0}),K=process.env.NODE_ENV==="development",U=(0,r.useRef)(0),$=(0,r.useCallback)(async()=>{var t;try{let a=await(await fetch("/api/seo/save")).json(),n=a[i];if(!n){let l=i.replace(/^\//,""),m=Object.keys(a).find(v=>a[v].slug===l);m&&(n=a[m])}n&&(E(n),P(n.title||(typeof document!="undefined"?document.title:"")),N(n.description||(typeof document!="undefined"?(t=document.querySelector('meta[name="description"]'))==null?void 0:t.getAttribute("content"):"")||""),F(n.slug||i.split("/").pop()||""))}catch(s){console.error("Failed to load SEO data from server")}},[i]);(0,r.useEffect)(()=>{d(!0),K&&$()},[K,$]);let ee=async()=>{let t=W(I({},f),{title:C,description:T,slug:j});try{if((await fetch("/api/seo/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pathname:i,overrides:t})})).ok&&(E(t),alert("SEO Changes & Permalink Mapping Saved! \u{1F680}"),typeof document!="undefined")){document.title=C;let a=document.querySelector('meta[name="description"]');a&&a.setAttribute("content",T)}}catch(s){alert("Failed to save to project.")}},q=async t=>{let s=W(I({},f),{keywords:t});try{await fetch("/api/seo/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pathname:i,overrides:s})}),E(s)}catch(a){}};(0,r.useEffect)(()=>{if(!o)return;let t=()=>{if(typeof document=="undefined")return;let n=Date.now();if(n-U.current<2e3)return;U.current=n;let l=Array.from(document.getElementsByTagName("h1")).map(c=>c.innerText),m=Array.from(document.getElementsByTagName("h2")).map(c=>c.innerText),v=Array.from(document.getElementsByTagName("h3")).map(c=>c.innerText),g=document.getElementById("next-seo-checker-root"),u=document.body.innerText;g&&(u=u.replace(g.innerText,""));let z=Array.from(document.getElementsByTagName("img")).filter(c=>!(g!=null&&g.contains(c))).map(c=>({alt:c.alt})),O=u.trim()===""?0:u.trim().split(/\s+/).length;Z({h1s:l,h2s:m,h3s:v,bodyText:u,images:z,url:window.location.pathname,wordCount:O})},s=setTimeout(t,1e3),a=new MutationObserver(n=>{let l=document.getElementById("next-seo-checker-root");n.some(v=>!(l!=null&&l.contains(v.target)))&&t()});return a.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),()=>{clearTimeout(s),a.disconnect()}},[i,o]);let A=(0,r.useMemo)(()=>{var O,c;if(!o)return[];let t=(f.title||(typeof document!="undefined"?document.title:"")).toLowerCase(),s=(f.description||(typeof document!="undefined"?(O=document.querySelector('meta[name="description"]'))==null?void 0:O.getAttribute("content"):"")||"").toLowerCase(),a=f.keywords||[],n=((c=a[0])==null?void 0:c.toLowerCase())||"",l=a.slice(1).map(p=>p.toLowerCase()),m=h.bodyText.toLowerCase(),v=f.slug||(i==="/"?"home":i.split("/").filter(Boolean).pop())||"",g=[{title:"Basic SEO",items:[]},{title:"Additional",items:[]},{title:"Title Readability",items:[]},{title:"Content Readability",items:[]}],u=g[0].items;if(n){let p=t.includes(n);u.push({id:"key-title",label:"Primary Keyword in Title",status:p?"success":"error",message:p?"Perfect! Keyword found in title.":"Critical: Primary keyword missing in title!"});let w=s.includes(n);u.push({id:"key-desc",label:"Primary Keyword in Description",status:w?"success":"error",message:w?"Keyword found in description.":"Critical: Primary keyword missing in description!"});let b=n.replace(/\s+/g,"-"),J=v.toLowerCase().includes(b);u.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=m.substring(0,500).includes(n);u.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."})}u.push({id:"word-count",label:"Word Count",status:h.wordCount>600?"success":"warning",message:`${h.wordCount} words. (Target: 600+)`});let z=g[1].items;if(l.length>0&&l.forEach((p,w)=>{let b=m.includes(p)||t.includes(p)||s.includes(p);z.push({id:`sec-key-${w}`,label:`Secondary Keyword: ${p}`,status:b?"success":"error",message:b?"Keyword used in content.":"Error: This keyword is not found anywhere!"})}),n){let p=[...h.h2s,...h.h3s].some(b=>b.toLowerCase().includes(n));z.push({id:"key-sub",label:"Primary in Subheadings",status:p?"success":"warning",message:p?"Keyword found in H2/H3.":"Focus keyword not found in subheadings."});let w=h.images.some(b=>b.alt.toLowerCase().includes(n));z.push({id:"key-alt",label:"Image Alt Tags",status:w?"success":"warning",message:w?"Keyword found in image alt text.":"Add your focus keyword to image alt tags."})}return g},[h,f,o]),S=(0,r.useMemo)(()=>{let t=0,s=0;return A.forEach(a=>a.items.forEach(n=>{s++,n.status==="success"?t++:n.status==="warning"&&(t+=.5)})),s===0?0:Math.round(t/s*100)},[A]);if(!K||!o)return null;let x={wrapper:{fontFamily:"-apple-system, system-ui, sans-serif",color:"#111827"},trigger:{position:"fixed",bottom:"20px",right:"20px",zIndex:99999,background:S>=80?"#10b981":S>=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:k?"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:x.wrapper,children:[!k&&(0,e.jsxs)("div",{style:x.trigger,onClick:()=>y(!0),children:["SEO Score ",S]}),(0,e.jsxs)("div",{style:x.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:S>=80?"#d1fae5":"#fef3c7",color:S>=80?"#059669":"#d97706",padding:"4px 12px",borderRadius:"12px",fontSize:"14px",fontWeight:800},children:[S,"/100"]})]}),(0,e.jsx)("button",{onClick:()=>y(!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:x.sidebar,children:[(0,e.jsx)("div",{style:x.tab(R==="general"),onClick:()=>L("general"),children:"\u2728 General"}),(0,e.jsx)("div",{style:x.tab(R==="edit"),onClick:()=>L("edit"),children:"\u{1F4DD} Snippet Editor"})]}),(0,e.jsxs)("div",{style:x.main,children:[R==="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:B,onChange:t=>M(t.target.value),placeholder:"Add focus keyword..."}),(0,e.jsx)("button",{onClick:()=>{B&&(q([...f.keywords||[],B]),M(""))},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=f.keywords)==null?void 0:H.map((t,s)=>(0,e.jsxs)("span",{style:x.keywordTag(s===0),children:[s===0&&"\u2605 "," ",t,(0,e.jsx)("span",{onClick:()=>{var n;let a=(n=f.keywords)==null?void 0:n.filter(l=>l!==t);q(a||[])},style:{cursor:"pointer",opacity:.5,marginLeft:"4px"},children:"\xD7"})]},t))})]}),A.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(s=>(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 ${s.status==="success"?"#10b981":s.status==="warning"?"#f59e0b":"#ef4444"}`},children:[(0,e.jsx)("div",{style:{fontSize:"16px"},children:s.status==="success"?"\u2705":s.status==="warning"?"\u26A0\uFE0F":"\u274C"}),(0,e.jsxs)("div",{children:[(0,e.jsx)("div",{style:{fontSize:"14px",fontWeight:700,marginBottom:"2px"},children:s.label}),(0,e.jsx)("div",{style:{fontSize:"12px",color:"#6b7280"},children:s.message})]})]},s.id))})]},t.title))]}),R==="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:C,onChange:t=>P(t.target.value)}),(0,e.jsxs)("div",{style:{fontSize:"11px",marginTop:"6px",color:C.length>60?"#ef4444":"#9ca3af"},children:[C.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:j,onChange:t=>F(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:T,onChange:t=>N(t.target.value)}),(0,e.jsxs)("div",{style:{fontSize:"11px",marginTop:"6px",color:T.length>160?"#ef4444":"#9ca3af"},children:[T.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});
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});
package/dist/client.mjs CHANGED
@@ -1 +1,2 @@
1
- import{a as B,b as K}from"./chunk-HGGX55FR.mjs";import{useEffect as G,useState as f,useMemo as V,useCallback as X,useRef as Z}from"react";import{usePathname as ee}from"next/navigation";import{jsx as i,jsxs as n}from"react/jsx-runtime";function te(){var q;let p=ee(),[w,Y]=f(!1),[A,I]=f(!1),[T,W]=f("general"),[c,R]=f({}),[S,L]=f(""),[k,P]=f(""),[N,j]=f(""),[O,F]=f(""),[m,_]=f({h1s:[],h2s:[],h3s:[],bodyText:"",images:[],url:"",wordCount:0}),D=process.env.NODE_ENV==="development",M=Z(0),U=X(async()=>{var e;try{let s=await(await fetch("/api/seo/save")).json(),t=s[p];if(!t){let r=p.replace(/^\//,""),y=Object.keys(s).find(b=>s[b].slug===r);y&&(t=s[y])}t&&(R(t),L(t.title||(typeof document!="undefined"?document.title:"")),P(t.description||(typeof document!="undefined"?(e=document.querySelector('meta[name="description"]'))==null?void 0:e.getAttribute("content"):"")||""),j(t.slug||p.split("/").pop()||""))}catch(o){console.error("Failed to load SEO data from server")}},[p]);G(()=>{Y(!0),D&&U()},[D,U]);let Q=async()=>{let e=K(B({},c),{title:S,description:k,slug:N});try{if((await fetch("/api/seo/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pathname:p,overrides:e})})).ok&&(R(e),alert("SEO Changes & Permalink Mapping Saved! \u{1F680}"),typeof document!="undefined")){document.title=S;let s=document.querySelector('meta[name="description"]');s&&s.setAttribute("content",k)}}catch(o){alert("Failed to save to project.")}},$=async e=>{let o=K(B({},c),{keywords:e});try{await fetch("/api/seo/save",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({pathname:p,overrides:o})}),R(o)}catch(s){}};G(()=>{if(!w)return;let e=()=>{if(typeof document=="undefined")return;let t=Date.now();if(t-M.current<2e3)return;M.current=t;let r=Array.from(document.getElementsByTagName("h1")).map(a=>a.innerText),y=Array.from(document.getElementsByTagName("h2")).map(a=>a.innerText),b=Array.from(document.getElementsByTagName("h3")).map(a=>a.innerText),u=document.getElementById("next-seo-checker-root"),l=document.body.innerText;u&&(l=l.replace(u.innerText,""));let C=Array.from(document.getElementsByTagName("img")).filter(a=>!(u!=null&&u.contains(a))).map(a=>({alt:a.alt})),z=l.trim()===""?0:l.trim().split(/\s+/).length;_({h1s:r,h2s:y,h3s:b,bodyText:l,images:C,url:window.location.pathname,wordCount:z})},o=setTimeout(e,1e3),s=new MutationObserver(t=>{let r=document.getElementById("next-seo-checker-root");t.some(b=>!(r!=null&&r.contains(b.target)))&&e()});return s.observe(document.body,{childList:!0,subtree:!0,attributes:!0}),()=>{clearTimeout(o),s.disconnect()}},[p,w]);let E=V(()=>{var z,a;if(!w)return[];let e=(c.title||(typeof document!="undefined"?document.title:"")).toLowerCase(),o=(c.description||(typeof document!="undefined"?(z=document.querySelector('meta[name="description"]'))==null?void 0:z.getAttribute("content"):"")||"").toLowerCase(),s=c.keywords||[],t=((a=s[0])==null?void 0:a.toLowerCase())||"",r=s.slice(1).map(d=>d.toLowerCase()),y=m.bodyText.toLowerCase(),b=c.slug||(p==="/"?"home":p.split("/").filter(Boolean).pop())||"",u=[{title:"Basic SEO",items:[]},{title:"Additional",items:[]},{title:"Title Readability",items:[]},{title:"Content Readability",items:[]}],l=u[0].items;if(t){let d=e.includes(t);l.push({id:"key-title",label:"Primary Keyword in Title",status:d?"success":"error",message:d?"Perfect! Keyword found in title.":"Critical: Primary keyword missing in title!"});let h=o.includes(t);l.push({id:"key-desc",label:"Primary Keyword in Description",status:h?"success":"error",message:h?"Keyword found in description.":"Critical: Primary keyword missing in description!"});let x=t.replace(/\s+/g,"-"),H=b.toLowerCase().includes(x);l.push({id:"key-url",label:"Keyword in Permalink",status:H?"success":"error",message:H?"Focus keyword used in URL slug.":"Error: Focus keyword not found in your URL slug!"});let J=y.substring(0,500).includes(t);l.push({id:"key-start",label:"Keyword in beginning",status:J?"success":"warning",message:J?"Keyword found at content start.":"Try using keyword in the first 10% of content."})}l.push({id:"word-count",label:"Word Count",status:m.wordCount>600?"success":"warning",message:`${m.wordCount} words. (Target: 600+)`});let C=u[1].items;if(r.length>0&&r.forEach((d,h)=>{let x=y.includes(d)||e.includes(d)||o.includes(d);C.push({id:`sec-key-${h}`,label:`Secondary Keyword: ${d}`,status:x?"success":"error",message:x?"Keyword used in content.":"Error: This keyword is not found anywhere!"})}),t){let d=[...m.h2s,...m.h3s].some(x=>x.toLowerCase().includes(t));C.push({id:"key-sub",label:"Primary in Subheadings",status:d?"success":"warning",message:d?"Keyword found in H2/H3.":"Focus keyword not found in subheadings."});let h=m.images.some(x=>x.alt.toLowerCase().includes(t));C.push({id:"key-alt",label:"Image Alt Tags",status:h?"success":"warning",message:h?"Keyword found in image alt text.":"Add your focus keyword to image alt tags."})}return u},[m,c,w]),v=V(()=>{let e=0,o=0;return E.forEach(s=>s.items.forEach(t=>{o++,t.status==="success"?e++:t.status==="warning"&&(e+=.5)})),o===0?0:Math.round(e/o*100)},[E]);if(!D||!w)return null;let g={wrapper:{fontFamily:"-apple-system, system-ui, sans-serif",color:"#111827"},trigger:{position:"fixed",bottom:"20px",right:"20px",zIndex:99999,background:v>=80?"#10b981":v>=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:A?"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:g.wrapper,children:[!A&&n("div",{style:g.trigger,onClick:()=>I(!0),children:["SEO Score ",v]}),n("div",{style:g.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:[i("span",{style:{fontSize:"20px"},children:"\u{1F680}"}),i("div",{style:{fontWeight:800,fontSize:"18px"},children:"Next SEO Checker"}),n("div",{style:{background:v>=80?"#d1fae5":"#fef3c7",color:v>=80?"#059669":"#d97706",padding:"4px 12px",borderRadius:"12px",fontSize:"14px",fontWeight:800},children:[v,"/100"]})]}),i("button",{onClick:()=>I(!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:g.sidebar,children:[i("div",{style:g.tab(T==="general"),onClick:()=>W("general"),children:"\u2728 General"}),i("div",{style:g.tab(T==="edit"),onClick:()=>W("edit"),children:"\u{1F4DD} Snippet Editor"})]}),n("div",{style:g.main,children:[T==="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:[i("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:[i("input",{style:{flex:1,padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",outline:"none",fontSize:"14px"},value:O,onChange:e=>F(e.target.value),placeholder:"Add focus keyword..."}),i("button",{onClick:()=>{O&&($([...c.keywords||[],O]),F(""))},style:{padding:"0 24px",background:"#2563eb",color:"white",border:"none",borderRadius:"10px",fontWeight:700,cursor:"pointer"},children:"Add"})]}),i("div",{style:{display:"flex",flexWrap:"wrap",gap:"8px"},children:(q=c.keywords)==null?void 0:q.map((e,o)=>n("span",{style:g.keywordTag(o===0),children:[o===0&&"\u2605 "," ",e,i("span",{onClick:()=>{var t;let s=(t=c.keywords)==null?void 0:t.filter(r=>r!==e);$(s||[])},style:{cursor:"pointer",opacity:.5,marginLeft:"4px"},children:"\xD7"})]},e))})]}),E.map(e=>n("div",{children:[i("div",{style:{fontSize:"12px",fontWeight:800,color:"#9ca3af",textTransform:"uppercase",marginBottom:"12px",marginLeft:"4px"},children:e.title}),i("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:"12px"},children:e.items.map(o=>n("div",{style:{padding:"16px",borderRadius:"12px",border:"1px solid #f3f4f6",background:"#fff",display:"flex",gap:"12px",alignItems:"flex-start",borderLeft:`4px solid ${o.status==="success"?"#10b981":o.status==="warning"?"#f59e0b":"#ef4444"}`},children:[i("div",{style:{fontSize:"16px"},children:o.status==="success"?"\u2705":o.status==="warning"?"\u26A0\uFE0F":"\u274C"}),n("div",{children:[i("div",{style:{fontSize:"14px",fontWeight:700,marginBottom:"2px"},children:o.label}),i("div",{style:{fontSize:"12px",color:"#6b7280"},children:o.message})]})]},o.id))})]},e.title))]}),T==="edit"&&i("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:[i("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"SEO Title"}),i("input",{style:{width:"100%",padding:"12px 16px",borderRadius:"10px",border:"1px solid #d1d5db",fontSize:"15px",outline:"none"},value:S,onChange:e=>L(e.target.value)}),n("div",{style:{fontSize:"11px",marginTop:"6px",color:S.length>60?"#ef4444":"#9ca3af"},children:[S.length," / 60 characters"]})]}),n("div",{style:{marginBottom:"24px"},children:[i("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:[i("span",{style:{fontSize:"13px",color:"#9ca3af",marginRight:"4px"},children:"/"}),i("input",{style:{flex:1,background:"transparent",border:"none",padding:"12px 4px",fontSize:"15px",outline:"none"},value:N,onChange:e=>j(e.target.value.replace(/\s+/g,"-").toLowerCase())})]})]}),n("div",{style:{marginBottom:"32px"},children:[i("label",{style:{display:"block",fontSize:"13px",fontWeight:800,color:"#374151",marginBottom:"8px"},children:"Meta Description"}),i("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=>P(e.target.value)}),n("div",{style:{fontSize:"11px",marginTop:"6px",color:k.length>160?"#ef4444":"#9ca3af"},children:[k.length," / 160 characters"]})]}),i("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:i("button",{onClick:Q,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{te as NextSeoChecker};
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};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "next-seo-checker",
3
- "version": "1.3.0",
3
+ "version": "1.5.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",
@@ -18,11 +18,16 @@
18
18
  "import": "./dist/server.mjs",
19
19
  "require": "./dist/server.js",
20
20
  "types": "./dist/server.d.ts"
21
+ },
22
+ "./api": {
23
+ "import": "./dist/api-handler.mjs",
24
+ "require": "./dist/api-handler.js",
25
+ "types": "./dist/api-handler.d.ts"
21
26
  }
22
27
  },
23
28
  "scripts": {
24
29
  "dev": "next dev",
25
- "build": "tsup src/client.ts src/server.ts --format cjs,esm --dts --minify --clean --tsconfig tsconfig.build.json",
30
+ "build": "tsup",
26
31
  "build:next": "next build",
27
32
  "start": "next start",
28
33
  "lint": "eslint"