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