UNPKG

atom-nextjs

Version:

Build a blog in NextJS using components, TailwindCSS, and Atom CMS.

3 lines (2 loc) 13.4 kB
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("react")),r=e(require("rehype-sanitize")),n=e(require("remark-gfm")),a=require("next-mdx-remote/rsc"),o=e(require("next/link")),i=e(require("react-loading-skeleton"));function c(e,t,r,n,a,o,i){try{var c=e[o](i),s=c.value}catch(e){return void r(e)}c.done?t(s):Promise.resolve(s).then(n,a)}function s(e){return function(){var t=this,r=arguments;return new Promise((function(n,a){var o=e.apply(t,r);function i(e){c(o,n,a,i,s,"next",e)}function s(e){c(o,n,a,i,s,"throw",e)}i(void 0)}))}}function u(){u=function(){return t};var e,t={},r=Object.prototype,n=r.hasOwnProperty,a=Object.defineProperty||function(e,t,r){e[t]=r.value},o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",c=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function l(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{l({},"")}catch(e){l=function(e,t,r){return e[t]=r}}function f(e,t,r,n){var o=Object.create((t&&t.prototype instanceof y?t:y).prototype),i=new O(n||[]);return a(o,"_invoke",{value:j(e,r,i)}),o}function p(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}t.wrap=f;var h="suspendedStart",m="executing",d="completed",v={};function y(){}function g(){}function x(){}var w={};l(w,i,(function(){return this}));var E=Object.getPrototypeOf,b=E&&E(E(S([])));b&&b!==r&&n.call(b,i)&&(w=b);var k=x.prototype=y.prototype=Object.create(w);function N(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function L(e,t){function r(a,o,i,c){var s=p(e[a],e,o);if("throw"!==s.type){var u=s.arg,l=u.value;return l&&"object"==typeof l&&n.call(l,"__await")?t.resolve(l.__await).then((function(e){r("next",e,i,c)}),(function(e){r("throw",e,i,c)})):t.resolve(l).then((function(e){u.value=e,i(u)}),(function(e){return r("throw",e,i,c)}))}c(s.arg)}var o;a(this,"_invoke",{value:function(e,n){function a(){return new t((function(t,a){r(e,n,t,a)}))}return o=o?o.then(a,a):a()}})}function j(t,r,n){var a=h;return function(o,i){if(a===m)throw Error("Generator is already running");if(a===d){if("throw"===o)throw i;return{value:e,done:!0}}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var s=P(c,n);if(s){if(s===v)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(a===h)throw a=d,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a=m;var u=p(t,r,n);if("normal"===u.type){if(a=n.done?d:"suspendedYield",u.arg===v)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(a=d,n.method="throw",n.arg=u.arg)}}}function P(t,r){var n=r.method,a=t.iterator[n];if(a===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,P(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=p(a,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function A(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function S(t){if(t||""===t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var a=-1,o=function r(){for(;++a<t.length;)if(n.call(t,a))return r.value=t[a],r.done=!1,r;return r.value=e,r.done=!0,r};return o.next=o}}throw new TypeError(typeof t+" is not iterable")}return g.prototype=x,a(k,"constructor",{value:x,configurable:!0}),a(x,"constructor",{value:g,configurable:!0}),g.displayName=l(x,s,"GeneratorFunction"),t.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===g||"GeneratorFunction"===(t.displayName||t.name))},t.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,x):(e.__proto__=x,l(e,s,"GeneratorFunction")),e.prototype=Object.create(k),e},t.awrap=function(e){return{__await:e}},N(L.prototype),l(L.prototype,c,(function(){return this})),t.AsyncIterator=L,t.async=function(e,r,n,a,o){void 0===o&&(o=Promise);var i=new L(f(e,r,n,a),o);return t.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},N(k),l(k,s,"Generator"),l(k,i,(function(){return this})),l(k,"toString",(function(){return"[object Generator]"})),t.keys=function(e){var t=Object(e),r=[];for(var n in t)r.push(n);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=S,O.prototype={constructor:O,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(A),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function a(n,a){return c.type="throw",c.arg=t,r.next=n,a&&(r.method="next",r.arg=e),!!a}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],c=i.completion;if("root"===i.tryLoc)return a("end");if(i.tryLoc<=this.prev){var s=n.call(i,"catchLoc"),u=n.call(i,"finallyLoc");if(s&&u){if(this.prev<i.catchLoc)return a(i.catchLoc,!0);if(this.prev<i.finallyLoc)return a(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return a(i.catchLoc,!0)}else{if(!u)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return a(i.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var a=this.tryEntries[r];if(a.tryLoc<=this.prev&&n.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var o=a;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=e,i.arg=t,o?(this.method="next",this.next=o.finallyLoc,v):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),v},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),A(r),v}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var a=n.arg;A(r)}return a}}throw Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:S(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}require("react-loading-skeleton/dist/skeleton.css");var l=function(){var e=s(u().mark((function e(o){var i,c,s,l;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=o.className,c=o.body,s=o.remarkPlugins,l=o.rehypePlugins,e.next=3,a.compileMDX({source:c,options:{mdxOptions:{remarkPlugins:[n].concat(s||[]),rehypePlugins:[r].concat(l||[])}}});case 3:return e.abrupt("return",t.createElement("div",{className:i},e.sent.content));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),f=function(){var e=s(u().mark((function e(t,r){var n;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("https://cmsatom.netlify.app/api/posts/get/single?post_id="+r,{headers:{Authorization:"Bearer "+t}});case 2:return n=e.sent,e.next=5,n.json();case 5:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),p=function(){var e=s(u().mark((function e(r){var n,a,o,i,c,s,p;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.projectKey,a=r.postId,o=r.remarkPlugins,i=r.rehypePlugins,e.next=3,f(n,a);case 3:return s=(c=e.sent).response,p=new Date((null==s?void 0:s.createdAt)||""),e.abrupt("return",t.createElement(t.Fragment,null,c.success?t.createElement("main",{className:"flex justify-center"},t.createElement("article",{className:"prose lg:prose-xl w-full"},t.createElement("div",{className:"flex flex-col gap-4 w-full"},t.createElement("section",{className:"space-y-6 w-full"},t.createElement("header",{className:"space-y-4 w-full"},t.createElement("h1",{className:"text-center"},s.title),s.image&&t.createElement("div",{className:"w-full h-auto rounded-xl border",style:{backgroundImage:"url("+s.image+")",width:"100%",height:450,backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center"}}),t.createElement("div",{className:"flex items-center justify-center gap-4"},t.createElement("p",{className:"author"},s.author),"|",t.createElement("time",{dateTime:p.toDateString()},p.toDateString())))),t.createElement("section",{className:"mt-12"},t.createElement(l,{className:"space-y-6",body:s.body,remarkPlugins:o,rehypePlugins:i}))))):c.message));case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),h=function(){var e=s(u().mark((function e(t){var r;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,fetch("https://cmsatom.netlify.app/api/projects/get/single/client",{headers:{Authorization:"Bearer "+t}});case 2:return r=e.sent,e.next=5,r.json();case 5:return e.abrupt("return",e.sent);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),m=function(e){var r=e.post;return t.createElement(o,{href:e.baseRoute+"/"+r.id,className:"w-[350px] h-fit p-4 border rounded-lg hover:bg-slate-50 transition"},r.image&&t.createElement("div",{className:"rounded-md mb-4",style:{backgroundImage:"url("+r.image+")",width:"100%",height:200,backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center",position:"relative"}}),t.createElement("div",{className:"space-y-2"},t.createElement("div",{className:"text-sm text-slate-500 flex gap-1 items-center"},t.createElement("span",null,new Date(r.createdAt).toDateString()),t.createElement("span",{className:"text-[24px]"},"-"),t.createElement("span",null,r.author)),t.createElement("div",{className:"space-y-1"},t.createElement("h2",{className:"font-semibold text-lg"},r.title),t.createElement("p",{className:"text-sm text-slate-500"},r.teaser))))},d=function(){var e=s(u().mark((function e(r){var n,a,o,i,c,s;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.projectKey,a=r.baseRoute,i=void 0===(o=r.title)||o,e.next=3,h(n);case 3:return s=(c=e.sent).response,e.abrupt("return",t.createElement("div",null,c.success?t.createElement(t.Fragment,null,i&&t.createElement("h1",{className:"text-4xl font-semibold"},s.title),t.createElement("div",{className:(i&&"mt-6")+" flex items-start justify-end flex-wrap flex-row-reverse gap-8"},s.posts.map((function(e){return t.createElement(m,{post:e,key:e.id,baseRoute:a})})))):c.message));case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),v=function(){var e=s(u().mark((function e(t,r){var n,a;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,f(t,r);case 2:if(a=(n=e.sent).response,n.success){e.next=6;break}return e.abrupt("return",{title:"Couldn't find post.",authors:{name:"Atom"}});case 6:return e.abrupt("return",{title:a.title||"Couldn't find post.",description:a.teaser,keywords:a.keywords,authors:{name:a.author}});case 7:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),y=function(){var e=s(u().mark((function e(t,r){var n,a,o;return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,h(t);case 2:return o=null!=(n=null==(a=e.sent.response)?void 0:a.posts.map((function(e){return{url:r+"/"+e.id,lastModified:new Date(e.updatedAt),priority:.5}})).concat([{url:r,lastModified:a.updatedAt,priority:.6}]))?n:[],e.abrupt("return",o);case 6:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();exports.Atom=p,exports.AtomArticleSkeleton=function(){return t.createElement("div",{className:"flex justify-center"},t.createElement("article",{className:"prose lg:prose-xl w-full"},t.createElement(i,{count:1,height:450}),t.createElement(i,{count:1,height:30,className:"mt-4"}),t.createElement(i,{count:6,className:"mt-4"})))},exports.AtomBody=l,exports.AtomLoadingSkeleton=function(){return t.createElement("div",{className:"flex gap-8 w-full flex-wrap"},Array(4).fill(0).map((function(e,r){return t.createElement("div",{key:r,className:"w-[350px] h-fit p-6 border rounded-lg"},t.createElement(i,{count:1,height:150}),t.createElement(i,{count:1,height:30,className:"mt-4"}),t.createElement(i,{count:3,className:"mt-4"}))})))},exports.AtomPage=d,exports.AtomPostCard=m,exports.generatePostMetadata=v,exports.generateSitemap=y,exports.getPost=f,exports.getProject=h; //# sourceMappingURL=atom-nextjs.cjs.production.min.js.map