|
1 |
| -const DEFAULT_BASE_URL = 'http://staging.pycon.tw/prs' |
| 1 | +import axios from 'axios' |
| 2 | +const DEFAULT_BASE_URL = 'https://tw.pycon.org/temp' |
2 | 3 | const DEFAULT_ROUTER_BASE = '/2022/'
|
3 | 4 | const DEFAULT_BUILD_TARGET = 'static'
|
4 | 5 | const DEFAULT_VUE_DEVTOOL = false
|
5 | 6 |
|
6 | 7 | export default {
|
| 8 | + generate: { |
| 9 | + async routes() { |
| 10 | + const config = { |
| 11 | + headers: { |
| 12 | + authorization: `Token ${process.env.AUTH_TOKEN}`, |
| 13 | + }, |
| 14 | + } |
| 15 | + const talks = await axios.get( |
| 16 | + `${DEFAULT_BASE_URL}/api/events/speeches/?event_types=talk,sponsored`, |
| 17 | + config, |
| 18 | + ) |
| 19 | + const tutorials = await axios.get( |
| 20 | + `${DEFAULT_BASE_URL}/api/events/speeches/?event_types=tutorial`, |
| 21 | + config, |
| 22 | + ) |
| 23 | + const getAllDetailTalks = async () => { |
| 24 | + const data = await Promise.all( |
| 25 | + talks.data.map(async (talk) => { |
| 26 | + return await axios |
| 27 | + .get( |
| 28 | + `${DEFAULT_BASE_URL}/api/events/speeches/${talk.event_type}/${talk.id}/`, |
| 29 | + config, |
| 30 | + ) |
| 31 | + .then((response) => response.data) |
| 32 | + }), |
| 33 | + ) |
| 34 | + return data |
| 35 | + } |
| 36 | + const getAllDetailTutorials = async () => { |
| 37 | + const data = await Promise.all( |
| 38 | + tutorials.data.map(async (tutorial) => { |
| 39 | + return await axios |
| 40 | + .get( |
| 41 | + `${DEFAULT_BASE_URL}/api/events/speeches/${tutorial.event_type}/${tutorial.id}/`, |
| 42 | + config, |
| 43 | + ) |
| 44 | + .then((response) => response.data) |
| 45 | + }), |
| 46 | + ) |
| 47 | + return data |
| 48 | + } |
| 49 | + |
| 50 | + const detailTalks = await getAllDetailTalks() |
| 51 | + const detailTutorials = await getAllDetailTutorials() |
| 52 | + |
| 53 | + const routes = [ |
| 54 | + ...detailTalks.map((talk) => ({ |
| 55 | + route: `/conference/${talk.event_type}/${talk.id}`, |
| 56 | + payload: talk, |
| 57 | + })), |
| 58 | + ...detailTutorials.map((tutorial) => ({ |
| 59 | + route: `/conference/${tutorial.event_type}/${tutorial.id}`, |
| 60 | + payload: tutorial, |
| 61 | + })), |
| 62 | + ] |
| 63 | + return routes |
| 64 | + }, |
| 65 | + }, |
7 | 66 | vue: {
|
8 | 67 | config: {
|
9 | 68 | devtools: process.env.VUE_DEVTOOL || DEFAULT_VUE_DEVTOOL,
|
|
0 commit comments