{"version":3,"file":"DRcC5diV.js","sources":["../../../../composables/storyblok/useRelatedPosts.ts"],"sourcesContent":["import { Post } from \"@/types/Post\";\nimport { Status } from \"~/types/CustomFetch\";\nimport { mapResultToPosts } from \"~/utils/storyblok/mapResultToPosts\";\n\nexport const useRelatedPosts = (\n category: string | number | undefined,\n currentPost?: string\n) => {\n const status: Ref = ref(\"pending\");\n const { storyblokVersion } = useRuntimeConfig().public;\n\n const posts: Ref = ref([]);\n\n useStoryblokApi()\n .getStories(\n (() => {\n const options: any = {\n version: storyblokVersion as \"draft\" | \"published\",\n content_type: \"post\",\n per_page: 3,\n resolve_links: \"url\",\n resolve_relations: [\"post.author\", \"post.specialist\"],\n filter_query: {\n postType: {\n in: \"post\",\n },\n },\n };\n\n if (currentPost) {\n options.excluding_ids = currentPost;\n }\n\n if (category) {\n options.filter_query.category = {\n in: category,\n };\n }\n\n return options;\n })()\n )\n .then((r) => {\n const mappedResult = mapResultToPosts(r);\n\n posts.value = mappedResult.posts;\n\n status.value = \"success\";\n })\n .catch(() => {\n status.value = \"error\";\n });\n\n return {\n status,\n posts,\n };\n};\n"],"names":["useRelatedPosts","category","currentPost","status","ref","storyblokVersion","useRuntimeConfig","posts","useStoryblokApi","options","r","mappedResult","mapResultToPosts"],"mappings":"kFAIa,MAAAA,EAAkB,CAC7BC,EACAC,IACG,CACG,MAAAC,EAAsBC,EAAI,SAAS,EACnC,CAAE,iBAAAC,CAAA,EAAqBC,EAAA,EAAmB,OAE1CC,EAAqBH,EAAI,EAAE,EAEjCI,OAAAA,EACG,EAAA,YACE,IAAM,CACL,MAAMC,EAAe,CACnB,QAASJ,EACT,aAAc,OACd,SAAU,EACV,cAAe,MACf,kBAAmB,CAAC,cAAe,iBAAiB,EACpD,aAAc,CACZ,SAAU,CACR,GAAI,MAAA,CACN,CAEJ,EAEA,OAAIH,IACFO,EAAQ,cAAgBP,GAGtBD,IACFQ,EAAQ,aAAa,SAAW,CAC9B,GAAIR,CACN,GAGKQ,CACN,GAAA,CAAA,EAEJ,KAAMC,GAAM,CACL,MAAAC,EAAeC,EAAiBF,CAAC,EAEvCH,EAAM,MAAQI,EAAa,MAE3BR,EAAO,MAAQ,SAAA,CAChB,EACA,MAAM,IAAM,CACXA,EAAO,MAAQ,OAAA,CAChB,EAEI,CACL,OAAAA,EACA,MAAAI,CACF,CACF"}