diff --git a/pages/venue/venueMap.vue b/components/venue/VenueMap.vue similarity index 100% rename from pages/venue/venueMap.vue rename to components/venue/VenueMap.vue diff --git a/nuxt.config.js b/nuxt.config.js index 12f13734e6..c9bf93493c 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -1,9 +1,68 @@ +import axios from 'axios' const DEFAULT_BASE_URL = 'https://tw.pycon.org/prs' const DEFAULT_ROUTER_BASE = '/2023/' const DEFAULT_BUILD_TARGET = 'static' const DEFAULT_VUE_DEVTOOL = false export default { + 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 + }, + }, vue: { config: { devtools: process.env.VUE_DEVTOOL || DEFAULT_VUE_DEVTOOL, diff --git a/package-lock.json b/package-lock.json index 8e5ce9bba4..5b6eb2ba80 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4789,8 +4789,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", @@ -4816,6 +4815,27 @@ "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": { + "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", @@ -6167,7 +6187,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" } @@ -7178,8 +7197,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", diff --git a/package.json b/package.json index f15674cf77..1117faab77 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "dev": "nuxt", "build": "nuxt build", "start": "nuxt start", - "generate": "nuxt generate", + "preview": "nuxt preview", "serve": "npm run build && npm run start", "lint:js": "eslint --ext .js,.vue --ignore-path .gitignore .", "lint": "npm run lint:js", @@ -23,6 +23,7 @@ "@nuxtjs/markdownit": "^2.0.0", "@nuxtjs/sitemap": "^2.4.0", "@tailwindcss/aspect-ratio": "^0.2.1", + "axios": "^0.27.2", "core-js": "^3.6.5", "dayjs": "^1.10.6", "leaflet": "^1.9.4", diff --git a/pages/about/sponsor.vue b/pages/about/sponsor.vue index 24f071d369..7b45ab1311 100644 --- a/pages/about/sponsor.vue +++ b/pages/about/sponsor.vue @@ -37,7 +37,6 @@