{"version":3,"file":"NewsSection-CXBerRED.js","sources":["../../src/queries/GetNewsSection.js","../../src/components/news/NewsSection.vue"],"sourcesContent":["import gql from 'graphql-tag';\nimport { paginationQuery } from '@/queries/PaginationQuery';\n\nexport const newsSectionQuery = gql`\n query getNewsSection(\n $filter: String,\n $limit: Int,\n $paged: Int,\n $subType: String,\n $subTypeValue: String,\n $type: String\n ) {\n newsS(first: $limit, where: { paged: $paged }) {\n nodes {\n date\n excerpt\n featuredImage {\n node {\n altText\n sourceUrl\n }\n }\n imageSrcset\n slug\n title\n }\n }\n ${paginationQuery}\n }\n`;\n","<template>\n <div :class=\"[$style.container, 'container']\">\n <header>\n <h1 class=\"no-border-above space-0-above\">News</h1>\n </header>\n <SectionArticleList\n v-if=\"news.newsSection.nodes.length\"\n :limit=\"limit\"\n :page=\"page\"\n :post-data=\"news.newsSection.nodes\"\n :total-page-count=\"pageCount\"\n type=\"news\"\n ></SectionArticleList>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { computed, ref } from 'vue';\nimport { dataLoaded, useHandleError, useMetaData } from '@/composables/Common.js';\nimport { newsSectionQuery } from '@/queries/GetNewsSection';\nimport SectionArticleList from '@/components/common/SectionArticleList.vue';\nimport { useQuery } from 'villus';\n\nconst props = withDefaults(\n defineProps<{\n page: number;\n }>(),\n {\n page: 1,\n },\n);\n\nconst { handleError } = useHandleError();\nconst { setMetaDescription, setMetaTitle } = useMetaData();\n\nconst limit = 8;\nconst news = ref({\n newsSection: {\n nodes: [],\n },\n totalCount: 0,\n});\n\nconst pageCount = computed(() => Math.ceil(news.value.totalCount / limit));\n\nconst { data } = useQuery({\n onData: (data) => {\n if (Object.keys(data).length) {\n if (data.newsS.nodes.length) {\n news.value.newsSection = data.newsS;\n news.value.totalCount = data.totalCount;\n setMetaTitle('News');\n setMetaDescription();\n dataLoaded();\n }\n\n if (data.newsS.nodes.length === 0) {\n handleError('NewsSection', `Page ${props.page}, limit ${limit}`);\n }\n }\n },\n query: newsSectionQuery,\n skip: ({ paged }) => isNaN(paged),\n variables: {\n limit: limit,\n paged: +props.page,\n type: 'news',\n },\n});\n\nif (isNaN(props.page)) {\n handleError('NewsSection', `Page ${props.page}, limit ${limit}`);\n}\n</script>\n\n<script lang=\"ts\">\nexport default {\n beforeRoute(params, villusClient) {\n return new Promise<void>((resolve, reject) => {\n villusClient\n .executeQuery({\n query: newsSectionQuery,\n variables: {\n limit: 8,\n paged: params.page ? +params.page : 1,\n type: 'news',\n },\n })\n .then(() => resolve())\n .catch((err) => reject(err));\n });\n },\n};\n</script>\n\n<style lang=\"scss\" module>\n@media (min-width: $break-point) {\n .container {\n @include grid;\n\n > header {\n grid-column: 1 / span 6;\n }\n\n > section {\n grid-column: span 12;\n }\n }\n}\n</style>\n"],"names":["newsSectionQuery","gql","paginationQuery","__default__","params","villusClient","resolve","reject","err","props","__props","handleError","useHandleError","setMetaDescription","setMetaTitle","useMetaData","limit","news","ref","pageCount","computed","useQuery","data","dataLoaded","paged"],"mappings":"yTAGO,MAAMA,EAAmBC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAwB1BC,CAAe;AAAA;AAAA,ECiDNC,EAAA,CACb,YAAYC,EAAQC,EAAc,CAChC,OAAO,IAAI,QAAc,CAACC,EAASC,IAAW,CAC5CF,EACG,aAAa,CACZ,MAAOL,EACP,UAAW,CACT,MAAO,EACP,MAAOI,EAAO,KAAO,CAACA,EAAO,KAAO,EACpC,KAAM,MAAA,CACR,CACD,EACA,KAAK,IAAME,GAAS,EACpB,MAAOE,GAAQD,EAAOC,CAAG,CAAC,CAAA,CAC9B,CAAA,CAEL,mEArEA,MAAMC,EAAQC,EASR,CAAE,YAAAC,CAAY,EAAIC,EAAe,EACjC,CAAE,mBAAAC,EAAoB,aAAAC,CAAa,EAAIC,EAAY,EAEnDC,EAAQ,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