diff --git a/nuxt.config.js b/nuxt.config.js index 0820875cbb..e5cf6154ca 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -1,3 +1,5 @@ +import axios from 'axios' + const DEFAULT_BASE_URL = 'http://staging.pycon.tw/prs' const DEFAULT_ROUTER_BASE = '/2021/' const DEFAULT_BUILD_TARGET = 'static' @@ -7,6 +9,64 @@ export default { target: process.env.BUILD_TARGET || DEFAULT_BUILD_TARGET, // Re-route for GitHub Pages to serve with /assets + generate: { + async routes() { + const config = { + headers: { + authorization: `Token ${process.env.AUTH_TOKEN}`, + }, + } + const talks = await axios.get( + `${DEFAULT_BASE_URL}/api/events/speeches/?event_types=talk,sponsored`, + config, + ) + const tutorials = await axios.get( + `${DEFAULT_BASE_URL}/api/events/speeches/?event_types=tutorial`, + config, + ) + const getAllDetailTalks = async () => { + const data = await Promise.all( + talks.data.map(async (talk) => { + return await axios + .get( + `${DEFAULT_BASE_URL}/api/events/speeches/${talk.event_type}/${talk.id}/`, + config, + ) + .then((response) => response.data) + }), + ) + return data + } + const getAllDetailTutorials = async () => { + const data = await Promise.all( + tutorials.data.map(async (tutorial) => { + return await axios + .get( + `${DEFAULT_BASE_URL}/api/events/speeches/${tutorial.event_type}/${tutorial.id}/`, + config, + ) + .then((response) => response.data) + }), + ) + return data + } + + const detailTalks = await getAllDetailTalks() + const detailTutorials = await getAllDetailTutorials() + + const routes = [ + ...detailTalks.map((talk) => ({ + route: `/conference/${talk.event_type}/${talk.id}`, + payload: talk, + })), + ...detailTutorials.map((tutorial) => ({ + route: `/conference/${tutorial.event_type}/${tutorial.id}`, + payload: tutorial, + })), + ] + return routes + }, + }, router: { base: process.env.ROUTER_BASE || DEFAULT_ROUTER_BASE, // scroll behavior config for scroll to hash diff --git a/package-lock.json b/package-lock.json index 01f3d57f87..e83c9680fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@nuxt/http": "^0.6.2", "@nuxtjs/markdownit": "^2.0.0", "@tailwindcss/aspect-ratio": "^0.2.1", + "axios": "^0.27.2", "core-js": "^3.6.5", "dayjs": "^1.10.6", "nuxt": "^2.15.3", @@ -2488,6 +2489,7 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/@npmcli/move-file/-/move-file-1.1.2.tgz", "integrity": "sha512-1SUf/Cg2GzGDyaf15aR9St9TWlb+XvbZXWpDx8YKs7MLzMH/BCeopv+y9vzrzgkfykCGuWOlSu3mZhj2+FQcrg==", + "deprecated": "This functionality has been moved to @npmcli/fs", "dependencies": { "mkdirp": "^1.0.4", "rimraf": "^3.0.2" @@ -2534,7 +2536,7 @@ "version": "2.6.12", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", - "deprecated": "core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.", + "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", "hasInstallScript": true }, "node_modules/@nuxt/builder": { @@ -5888,8 +5890,7 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "node_modules/at-least-node": { "version": "1.0.0", @@ -5936,6 +5937,47 @@ "postcss": "^8.1.0" } }, + "node_modules/axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "dependencies": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + } + }, + "node_modules/axios/node_modules/follow-redirects": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz", + "integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/babel-code-frame": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", @@ -6348,7 +6390,7 @@ "version": "2.6.12", "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", - "deprecated": "core-js@<3.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Please, upgrade your dependencies to the actual version of core-js.", + "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", "dev": true, "hasInstallScript": true }, @@ -7644,7 +7686,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -7949,6 +7990,7 @@ "version": "3.16.2", "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.16.2.tgz", "integrity": "sha512-P0KPukO6OjMpjBtHSceAZEWlDD1M2Cpzpg6dBbrjFqFhBHe/BwhxaP820xKOjRn/lZRQirrCusIpLS/n2sgXLQ==", + "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", "hasInstallScript": true, "funding": { "type": "opencollective", @@ -8937,7 +8979,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true, "engines": { "node": ">=0.4.0" } @@ -23105,6 +23146,7 @@ "version": "0.5.3", "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.3.tgz", "integrity": "sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw==", + "deprecated": "See https://github.com/lydell/source-map-resolve#deprecated", "dependencies": { "atob": "^2.1.2", "decode-uri-component": "^0.2.0", @@ -23133,7 +23175,8 @@ "node_modules/source-map-url": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.1.tgz", - "integrity": "sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw==" + "integrity": "sha512-cPiFOTLUKvJFIg4SKVScy4ilPPW6rFgMgfuZJPNoDuMs3nC1HbMUycBoJw77xFIp6z1UJQJOfx6C9GMH80DiTw==", + "deprecated": "See https://github.com/lydell/source-map-url#deprecated" }, "node_modules/spdx-correct": { "version": "3.1.1", @@ -23228,7 +23271,8 @@ "node_modules/stable": { "version": "0.1.8", "resolved": "https://registry.npmjs.org/stable/-/stable-0.1.8.tgz", - "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==" + "integrity": "sha512-ji9qxRnOVfcuLDySj9qzhGSEFVobyt1kIOSkj1qZzYLzq7Tos/oUUWvotUPQLlrsidqsK6tBH89Bc9kL5zHA6w==", + "deprecated": "Modern JS already guarantees Array#sort() is a stable sort, so this library is deprecated. See the compatibility table on MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#browser_compatibility" }, "node_modules/stack-trace": { "version": "0.0.10", @@ -23660,6 +23704,7 @@ "version": "1.3.2", "resolved": "https://registry.npmjs.org/svgo/-/svgo-1.3.2.tgz", "integrity": "sha512-yhy/sQYxR5BkC98CY7o31VGsg014AKLEPxdfhora76l36hD9Rdy5NZA/Ocn6yayNPgSamYdtX2rFJdcv07AYVw==", + "deprecated": "This SVGO version is no longer supported. Upgrade to v2.x.x.", "dependencies": { "chalk": "^2.4.1", "coa": "^2.0.2", @@ -24628,20 +24673,6 @@ "is-typedarray": "^1.0.0" } }, - "node_modules/typescript": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", - "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", - "dev": true, - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "node_modules/ua-parser-js": { "version": "0.7.28", "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.28.tgz", @@ -24668,7 +24699,8 @@ "node_modules/ufo": { "version": "0.7.7", "resolved": "https://registry.npmjs.org/ufo/-/ufo-0.7.7.tgz", - "integrity": "sha512-N25aY3HBkJBnahm+2l4JRBBrX5I+JPakF/tDHYDTjd3wUR7iFLdyiPhj8mBwBz21v728BKwM9L9tgBfCntgdlw==" + "integrity": "sha512-N25aY3HBkJBnahm+2l4JRBBrX5I+JPakF/tDHYDTjd3wUR7iFLdyiPhj8mBwBz21v728BKwM9L9tgBfCntgdlw==", + "deprecated": "security: please use latest version" }, "node_modules/uglify-js": { "version": "3.14.1", @@ -25519,6 +25551,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", "integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==", + "deprecated": "Use your platform's native performance.now() and performance.timeOrigin.", "dev": true, "dependencies": { "browser-process-hrtime": "^1.0.0" @@ -25623,7 +25656,7 @@ "version": "2.1.8", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-2.1.8.tgz", "integrity": "sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg==", - "deprecated": "Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.", + "deprecated": "Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies", "optional": true, "dependencies": { "anymatch": "^2.0.0", @@ -31495,8 +31528,7 @@ "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", - "dev": true + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "at-least-node": { "version": "1.0.0", @@ -31521,6 +31553,32 @@ "postcss-value-parser": "^4.1.0" } }, + "axios": { + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "requires": { + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" + }, + "dependencies": { + "follow-redirects": { + "version": "1.15.1", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.1.tgz", + "integrity": "sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==" + }, + "form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "requires": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + } + } + } + }, "babel-code-frame": { "version": "6.26.0", "resolved": "https://registry.npmjs.org/babel-code-frame/-/babel-code-frame-6.26.0.tgz", @@ -32865,7 +32923,6 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dev": true, "requires": { "delayed-stream": "~1.0.0" } @@ -33875,8 +33932,7 @@ "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", - "dev": true + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" }, "delegates": { "version": "1.0.0", @@ -45846,13 +45902,6 @@ "is-typedarray": "^1.0.0" } }, - "typescript": { - "version": "4.3.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.3.5.tgz", - "integrity": "sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA==", - "dev": true, - "peer": true - }, "ua-parser-js": { "version": "0.7.28", "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.28.tgz", diff --git a/package.json b/package.json index 23e72d05da..817296f15e 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "core-js": "^3.6.5", "dayjs": "^1.10.6", "nuxt": "^2.15.3", + "axios": "^0.27.2", "nuxt-fontawesome": "^0.4.0", "nuxt-i18n": "^6.18.0", "uuid": "^8.3.2", diff --git a/pages/conference/_eventType/_id.vue b/pages/conference/_eventType/_id.vue index 57904f87ff..82eb1fc7b9 100644 --- a/pages/conference/_eventType/_id.vue +++ b/pages/conference/_eventType/_id.vue @@ -185,6 +185,19 @@ export default { Youtube, MarkdownRenderer, }, + async asyncData({ store, params, payload }) { + if (payload && Object.keys(payload).length !== 0) { + return { + speechData: payload, + } + } + await store.dispatch('$getSpeechData', { + eventType: params.eventType, + eventId: params.id, + }) + const speechData = store.state.speechData + return { speechData } + }, data() { return { data: { @@ -215,10 +228,6 @@ export default { ...mapState(['speechData']), }, async created() { - await this.$store.dispatch('$getSpeechData', { - eventType: this.$route.params.eventType, - eventId: this.$route.params.id, - }) await this.processData() this.$root.$emit('initTabs') }, diff --git a/pages/conference/_eventType/index.vue b/pages/conference/_eventType/index.vue index 6e181662c2..d30edb2aa7 100644 --- a/pages/conference/_eventType/index.vue +++ b/pages/conference/_eventType/index.vue @@ -76,16 +76,26 @@ export default { SpeechCard, SpeechCardCollection, }, - asyncData({ redirect, params }) { + async asyncData({ redirect, store, params, payload }) { const eventType = params.eventType if (!['talks', 'tutorials'].includes(eventType)) { redirect('/') } + if (payload && Object.keys(payload).length !== 0) + return { eventType, speechesData: payload } + + await store.dispatch('$getSpeechesData', eventType) + const speechesData = store.state.speechesData.map((speech) => ({ + ...speech, + begin_time: speech.begin_time ? new Date(speech.begin_time) : null, + })) + return { + eventType, + speechesData, + } }, data() { return { - eventType: '', - speechesData: [], checkedCategories: [], } }, @@ -128,11 +138,6 @@ export default { return false }, }, - async mounted() { - this.eventType = this.$route.params.eventType - await this.$store.dispatch('$getSpeechesData', this.eventType) - this.speechesData = this.$store.state.speechesData - }, methods: { metaInfo() { return { diff --git a/pages/conference/keynotes.vue b/pages/conference/keynotes.vue index e057d08328..9080d1fd30 100644 --- a/pages/conference/keynotes.vue +++ b/pages/conference/keynotes.vue @@ -127,9 +127,16 @@ export default { ExtLink, Youtube, }, - data() { + async asyncData({ store, app, payload }) { + if (payload) return { keynotesData: payload } + await store.dispatch('$getKeynotesData') + const keynotesData = store.state.keynotesData.map((keynote) => ({ + ...keynote, + id: app.$makeId(), + })) + return { - keynotesData: [], + keynotesData, } }, computed: { @@ -137,13 +144,6 @@ export default { return { 'en-us': 'en_us', 'zh-hant': 'zh_hant' }[this.$i18n.locale] }, }, - async mounted() { - await this.$store.dispatch('$getKeynotesData') - this.keynotesData = this.$store.state.keynotesData.map((keynote) => ({ - ...keynote, - id: this.$makeId(), - })) - }, methods: { getKeynoteId(keynote) { return keynote.speaker.name_en_us.split(' ').join('_') diff --git a/pages/conference/schedule.vue b/pages/conference/schedule.vue index a71d9f2f4c..1683299e6a 100644 --- a/pages/conference/schedule.vue +++ b/pages/conference/schedule.vue @@ -97,6 +97,13 @@ export default { ScheduleEvent, ScheduleTick, }, + async asyncData({ store, payload }) { + if (payload) return { schedulesData: payload } + + await store.dispatch('$getSchedulesData') + const schedulesData = store.state.schedulesData + return { schedulesData } + }, data() { return { selectedDayIndex: 0, @@ -123,8 +130,7 @@ export default { return this.lists[this.selectedDayIndex] || this.defaultList }, }, - async created() { - await this.$store.dispatch('$getSchedulesData') + created() { this.processData() }, methods: { diff --git a/pages/events/jobs-gather.vue b/pages/events/jobs-gather.vue index 2c31d7816e..60cde12117 100644 --- a/pages/events/jobs-gather.vue +++ b/pages/events/jobs-gather.vue @@ -45,19 +45,22 @@ export default { JobsCardCollection, JobsPanel, }, + async asyncData({ store, app, payload }) { + if (payload) return { jobsData: payload } + await store.dispatch('$getJobsData') + const jobsData = store.state.jobsData.map((sponsor) => ({ + ...sponsor, + id: app.$makeId(), + })) + return { jobsData } + }, data() { return { selectedSponsor: {}, - jobsData: [], pivot: 0, } }, - async mounted() { - await this.$store.dispatch('$getJobsData') - this.jobsData = this.$store.state.jobsData.map((sponsor) => ({ - ...sponsor, - id: this.$makeId(), - })) + mounted() { this.setSelectedSponsor(this.jobsData[0]) this.setPivot() }, diff --git a/pages/events/jobs.vue b/pages/events/jobs.vue index a2fa2e4d21..e2c6b98ea0 100644 --- a/pages/events/jobs.vue +++ b/pages/events/jobs.vue @@ -39,19 +39,22 @@ export default { JobsCardCollection, JobsPanel, }, + async asyncData({ store, app, payload }) { + if (payload) return { jobsData: payload } + await store.dispatch('$getJobsData') + const jobsData = store.state.jobsData.map((sponsor) => ({ + ...sponsor, + id: app.$makeId(), + })) + return { jobsData } + }, data() { return { selectedSponsor: {}, - jobsData: [], pivot: 0, } }, - async mounted() { - await this.$store.dispatch('$getJobsData') - this.jobsData = this.$store.state.jobsData.map((sponsor) => ({ - ...sponsor, - id: this.$makeId(), - })) + mounted() { this.setSelectedSponsor(this.jobsData[0]) this.setPivot() }, diff --git a/pages/index.vue b/pages/index.vue index 760482aef0..b4d0e1d16e 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -125,6 +125,14 @@ export default { BulletinCardCollection, CoreH2, }, + async asyncData({ store, payload }) { + if (payload) return { sponsorsData: payload } + await store.dispatch('$getSponsorsData') + const sponsorsData = store.state.sponsorsData + return { + sponsorsData, + } + }, data() { return { isOpened: false, @@ -135,9 +143,6 @@ export default { computed: { ...mapState(['sponsorsData']), }, - created() { - this.$store.dispatch('$getSponsorsData') - }, methods: { showModal(sponsor) { this.isOpened = true