UNPKG

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 2.63 kB
"use strict";var A=Object.create;var n=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var W=Object.getOwnPropertyNames,p=Object.getOwnPropertySymbols,k=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable;var l=(e,t,r)=>t in e?n(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,o=(e,t)=>{for(var r in t||(t={}))g.call(t,r)&&l(e,r,t[r]);if(p)for(var r of p(t))u.call(t,r)&&l(e,r,t[r]);return e};var x=(e,t)=>{var r={};for(var s in e)g.call(e,s)&&t.indexOf(s)<0&&(r[s]=e[s]);if(e!=null&&p)for(var s of p(e))t.indexOf(s)<0&&u.call(e,s)&&(r[s]=e[s]);return r};var I=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},d=(e,t,r,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let c of W(t))!g.call(e,c)&&c!==r&&n(e,c,{get:()=>t[c],enumerable:!(s=B(t,c))||s.enumerable});return e};var M=(e,t,r)=>(r=e!=null?A(k(e)):{},d(t||!e||!e.__esModule?n(r,"default",{value:e,enumerable:!0}):r,e)),D=e=>d(n({},"__esModule",{value:!0}),e);var H={};I(H,{ArticleSchema:()=>z,LocalBusinessSchema:()=>v,OrganizationSchema:()=>L,ProductSchema:()=>C,SchemaMarkup:()=>P,WebsiteSchema:()=>b});module.exports=D(H);var R=M(require("next/script"));var m=require("react");var a=class a{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 a.instance||(a.instance=new a(t)),a.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 c=t,{"@context":r}=c;return x(c,["@context"])})}}getConfig(){return this.config}reset(){this.schemas.length=0,this.config={}}};a.instance=null;var S=a,h=S.getInstance(),i=(0,m.cache)(e=>{h.addSchema(e)}),w=(0,m.cache)(e=>{h.setConfig(e)}),f=(0,m.cache)(()=>h.getSchemas()),y=(0,m.cache)(()=>h.getConfig());var O=require("react/jsx-runtime"),P=()=>{let e=f(),t=y();return e?(0,O.jsx)(R.default,{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);0&&(module.exports={ArticleSchema,LocalBusinessSchema,OrganizationSchema,ProductSchema,SchemaMarkup,WebsiteSchema}); //# sourceMappingURL=index.js.map