next-schema-buddy
Version:
A simple and lightweight Schema.org implementation for Next.js applications. Easily add structured data to your Next.js pages with type-safe components.
2 lines • 1.95 kB
JavaScript
var x=Object.defineProperty;var a=Object.getOwnPropertySymbols;var y=Object.prototype.hasOwnProperty,l=Object.prototype.propertyIsEnumerable;var f=(e,t,r)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,o=(e,t)=>{for(var r in t||(t={}))y.call(t,r)&&f(e,r,t[r]);if(a)for(var r of a(t))l.call(t,r)&&f(e,r,t[r]);return e};var u=(e,t)=>{var r={};for(var s in e)y.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&a)for(var s of a(e))t.indexOf(s)<0&&l.call(e,s)&&(r[s]=e[s]);return r};import R from"next/script";import{cache as n}from"react";var c=class c{constructor(t){var r,s;this.schemas=(r=t==null?void 0:t.initialSchemas)!=null?r:[],this.config=(s=t==null?void 0:t.initialConfig)!=null?s:{}}static getInstance(t){return c.instance||(c.instance=new c(t)),c.instance}addSchema(t){this.schemas.push(o({"@context":"https://schema.org"},t))}setConfig(t){this.config=t}getSchemas(){return this.schemas.length===0?null:{"@context":"https://schema.org","@graph":this.schemas.map(t=>{let S=t,{"@context":r}=S;return u(S,["@context"])})}}getConfig(){return this.config}reset(){this.schemas.length=0,this.config={}}};c.instance=null;var p=c,m=p.getInstance(),i=n(e=>{m.addSchema(e)}),d=n(e=>{m.setConfig(e)}),h=n(()=>m.getSchemas()),g=n(()=>m.getConfig());import{jsx as O}from"react/jsx-runtime";var P=()=>{let e=h(),t=g();return e?O(R,{id:"schema-markup",type:"application/ld+json",dangerouslySetInnerHTML:{__html:JSON.stringify(e,null,t.indentation)}}):null};var b=({data:e})=>(i(o({"@type":"WebSite"},e)),null);var C=({data:e})=>(i(o({"@type":"Product"},e)),null);var L=({data:e})=>(i(o({"@type":"Organization"},e)),null);var v=({data:e})=>(i(o({"@type":e["@type"]||"LocalBusiness"},e)),null);var z=({data:e})=>(i(o({"@type":e["@type"]||"Article"},e)),null);export{z as ArticleSchema,v as LocalBusinessSchema,L as OrganizationSchema,C as ProductSchema,P as SchemaMarkup,b as WebsiteSchema};
//# sourceMappingURL=index.mjs.map