From afd0846ab06446f7fc3890705ac6435000060739 Mon Sep 17 00:00:00 2001 From: "Matt.Wang" Date: Sun, 7 Aug 2022 15:54:17 +0800 Subject: [PATCH 1/2] fix(header/style): update color of menu and icon to pink-700 --- components/core/header/HomeIcon.vue | 2 +- components/core/header/locale-switch/LocaleSwitch.vue | 2 +- components/core/header/nav-bar/NavBar.vue | 4 ++-- static/icon.svg | 10 +++++++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/components/core/header/HomeIcon.vue b/components/core/header/HomeIcon.vue index 9dd9b84181..4e60a885b4 100644 --- a/components/core/header/HomeIcon.vue +++ b/components/core/header/HomeIcon.vue @@ -26,6 +26,6 @@ export default { diff --git a/components/core/header/locale-switch/LocaleSwitch.vue b/components/core/header/locale-switch/LocaleSwitch.vue index 84db5ed9f7..ae0268fa84 100644 --- a/components/core/header/locale-switch/LocaleSwitch.vue +++ b/components/core/header/locale-switch/LocaleSwitch.vue @@ -49,6 +49,6 @@ export default { @apply font-bold; } .core-localeSwitch:hover { - color: #c386ae; + @apply text-pink-700; } diff --git a/components/core/header/nav-bar/NavBar.vue b/components/core/header/nav-bar/NavBar.vue index aa078cef7c..0ac5857617 100644 --- a/components/core/header/nav-bar/NavBar.vue +++ b/components/core/header/nav-bar/NavBar.vue @@ -130,11 +130,11 @@ export default { } .core-navBarItem:hover { - @apply text-pink-500; + @apply text-pink-700; } .core-navBarItem.--active, .core-navBarItem.--active .options-menu { - @apply text-pink-500; + @apply text-pink-700; } diff --git a/static/icon.svg b/static/icon.svg index 035facc5c2..ce74d443ef 100644 --- a/static/icon.svg +++ b/static/icon.svg @@ -1,4 +1,8 @@ - - - + + + \ No newline at end of file From 3fc4a62a71a82e0aac8c5030c8ac521e91d9b187 Mon Sep 17 00:00:00 2001 From: Josix Date: Thu, 11 Aug 2022 12:12:24 +0800 Subject: [PATCH 2/2] build(nuxt-generate): add dynamic routes configuration and update to use asyncData fetching data --- nuxt.config.js | 61 ++++++++++++++++++++++++++- package-lock.json | 28 +++++++++--- package.json | 1 + pages/conference/_eventType/_id.vue | 22 ++++++---- pages/conference/_eventType/index.vue | 21 +++++---- pages/conference/keynotes.vue | 18 +++++--- pages/events/jobs.vue | 17 +++++--- pages/index.vue | 12 +++--- 8 files changed, 136 insertions(+), 44 deletions(-) diff --git a/nuxt.config.js b/nuxt.config.js index 08555506b5..2956ce5489 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 = '/2022/' const DEFAULT_BUILD_TARGET = 'static' @@ -11,7 +13,64 @@ export default { }, // Target (https://go.nuxtjs.dev/config-target) target: process.env.BUILD_TARGET || DEFAULT_BUILD_TARGET, - + generate: { + dir: DEFAULT_ROUTER_BASE.replace(/\/+/g, ''), + 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 + }, + }, // Re-route for GitHub Pages to serve with /assets router: { base: process.env.ROUTER_BASE || DEFAULT_ROUTER_BASE, diff --git a/package-lock.json b/package-lock.json index 71b8c4f46e..c9f9ea47f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4527,8 +4527,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", @@ -4554,6 +4553,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", @@ -5897,7 +5917,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" } @@ -6908,8 +6927,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 3ba5f552da..fcfefea274 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,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", diff --git a/pages/conference/_eventType/_id.vue b/pages/conference/_eventType/_id.vue index 4126e491f2..41de69319b 100644 --- a/pages/conference/_eventType/_id.vue +++ b/pages/conference/_eventType/_id.vue @@ -144,8 +144,6 @@