(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[88877],{239636:function(e,t,l){(window.__NEXT_P=window.__NEXT_P||[]).push(["/templates/category/[slug]",function(){return l(905827)}])},905827:function(e,t,l){"use strict";l.r(t),l.d(t,{__N_SSP:function(){return y},controlGetServerSideProps:function(){return h}});var a=l(552322),n=l(756662),r=l(282445),o=l(278338),i=l(871725),s=l(92814),u=l(815382),c=l(767760),d=l(154406),_=l(596465),p=l(753147),f=l(289192),g=l(134276);let m={paid:"free_and_paid",madeBy:"notion_and_community",orderBy:"popular",locales:"english_and_user_locale",page:1};var y=!0;async function h(e){var t;(0,p.k4)(e,{sMaxage:(0,s.ZI)("LOW")});let l=(0,d.Gp)(e);if(!l)return{notFound:!0};let{slug:a,type:g}=l.startsWith("free-")&&l.endsWith("-templates")?{slug:l.substring(5,l.length-10),type:"free"}:l.startsWith("best-")&&l.endsWith("-templates")?{slug:l.substring(5,l.length-10),type:"best"}:{slug:l,type:"default"},{category:y,subcategories:h}=await (0,i.pt)("getTemplateCategory",{slug:a,locale:e.locale,includeChildren:!0}).then(e=>"value"in e?e.value:{success:!1}).then(e=>e.success?e:{category:null,subcategories:null}).catch(e=>{throw Error(e)});if(!y)return{notFound:!0};let b=parseInt(null===(t=e.query)||void 0===t?void 0:t.page),v="best"===g?2:!isNaN(b)&&b>=1?b:1,w={...m,...e.query??{}},{validated:C,params:E}=(0,_.h8)(w);if(!C)return{redirect:{destination:`/${e.locale}${(0,_.d)(y.slug,E)}`,permanent:!0}};let{orderBy:N,madeBy:P,paid:q,locales:S}=E,k="free"===g?"free":q,{templates:B,count:I}=await (0,i.pt)("getTemplates",{locale:e.locale,limit:r.O6,excludeDefaultLocale:"user_locale"===S,orderBy:N,includeCount:!0,offset:(v-1)*r.O6,filterBy:{categoryId:y.contentful_id,madeBy:"notion_and_community"===P?void 0:P,paid:"free_and_paid"===k?void 0:k},includeCategories:!0,includeCreator:!0}).then(e=>e.error?{success:!1}:e.value).then(e=>e.success?{templates:(0,d.Ly)(e.templates),count:e.count||0}:{templates:[],count:0}).catch(e=>{throw Error(e)});if(v>1&&0===I)return{redirect:{destination:`/${null==e?void 0:e.locale}${(0,_.d)(y.slug,{orderBy:N,madeBy:P,paid:q,locales:S,page:1})}`,permanent:!1}};let{related_content:L=[],ancestor_contentful_ids:T=[]}=(null==y?void 0:y.attributes)??{},W=L.map(e=>{let{contentful_id:t}=e;return t}),x=(0,u.am)({locale:e.locale}),O=(0,u.ox)(T,e.locale),{contentfulClient:F}=e,G=(0,c.BW)(F,W),$=(0,u.lS)({locale:e.locale,contentfulIds:y.attributes.editorial_contentful_template_ids,includeCreator:!0}),X=Promise.all(v<=2?B.slice(0,3).map(e=>(0,c.n3)(F,e.contentful_id)):[]),[j,D,M,Q,U,Z,z,A,H,J,K]=await Promise.all([x,O,G,(0,u.X5)({contentfulIds:y.attributes.top_creator_contentful_ids??[]}),(0,u.ju)(),(0,u.TN)({locale:e.locale,contentfulIds:y.attributes.related_template_tag_contentful_ids??[]}),F.getEntry(f.Qb.templateCategory,{include:2}),y.attributes.related_blog_post_contentful_ids?await F.getEntries({limit:2,include:1,"sys.id[in]":y.attributes.related_blog_post_contentful_ids}).then(e=>{let{items:t}=e;return t}):[],y.attributes.related_guide_contentful_ids?await F.getEntries({limit:4,include:1,"sys.id[in]":y.attributes.related_guide_contentful_ids}).then(e=>{let{items:t}=e;return t}):[],$,X]),R=[...D,{text:y.name,link:(0,_.d)(y.slug),icon:y.icon}],V=o.mN(K,"sys.id").slice(0,3);return{props:{relatedCategories:Z,relatedBlogPosts:(0,n.q)(A),locale:e.locale,featuredTemplateCategories:j,editorialTemplates:J,category:y,templates:B,subcategories:h,templatesCount:I,templatesCountFormatted:I.toLocaleString(e.locale),relatedContentfulEntries:M,preview:e.preview??!1,crumbs:R,faqGroup:(0,n.q)(z),relatedGuides:(0,n.q)(H),filters:{orderBy:N,madeBy:P,paid:k,page:v,locales:S},categoryType:g,canonicalUrl:(0,_.d)(y.slug,void 0,g),supportedLocales:[],totalCreatorCountFormatted:U.toLocaleString(e.locale),relatedCollections:(0,n.q)(V.flat()),featuredCreators:(0,c.sv)(Q,e.locale)}}}t.default=function(e){return(0,a.jsx)(g.P,{...e})}}},function(e){e.O(0,[86922,68477,86802,96577,59680,88524,24883,63088,35379,23157,81712,22246,89450,2571,26154,45149,31188,40773,68812,67305,67014,68821,29778,35456,91216,46443,2113,68470,47784,70753,46919,65146,92888,49774,40179],function(){return e(e.s=239636)}),_N_E=e.O()}]);