From 49c515aedc9dd52dccd7f85251b5de5877e5cc9b Mon Sep 17 00:00:00 2001 From: Sandro Ducceschi Date: Wed, 27 Sep 2023 20:51:10 +0200 Subject: [PATCH] ADDED: new podcast detail page --- src/components/blocks/PodcastList.vue | 41 +++-- src/router/index.js | 7 + src/views/PodcastDetail.vue | 244 ++++++++++++++++++++++++++ 3 files changed, 278 insertions(+), 14 deletions(-) create mode 100644 src/views/PodcastDetail.vue diff --git a/src/components/blocks/PodcastList.vue b/src/components/blocks/PodcastList.vue index 8b8f1fb..a901d6b 100644 --- a/src/components/blocks/PodcastList.vue +++ b/src/components/blocks/PodcastList.vue @@ -27,17 +27,17 @@ -
+

{{ pod.title }}

- -
+
{{ pod.release_date | date }} @@ -145,16 +145,23 @@ export default { window.h1Set = true; } - const locale = Intl.getCanonicalLocales(this.$i18n.locale); - const { data } = await this.$d.api.get(`/podcasts?fields[]=url&fields[]=image&fields[]=release_date&fields[]=content.title,content.description&fields[]=status&filter[status][_eq]=published&filter[content][languages_code][_eq]=${locale}&limit=-1`); - const podcasts = (data || []).map((o) => ({ - image: `${API_URL}/assets/${o.image}`, - release_date: o.release_date, - url: o.url, - title: (o.content[0] || {}).title, - description: (o.content[0] || {}).description, - readmore: false, - })); + const siteLocale = this.$i18n.locale; + const locale = Intl.getCanonicalLocales(siteLocale); + const { data } = await this.$d.api.get(`/podcasts?fields[]=url&fields[]=image&fields[]=release_date&fields[]=content.title,content.description,content.episode&fields[]=status&filter[status][_eq]=published&filter[content][languages_code][_eq]=${locale}&limit=-1`); + const podcasts = (data || []).map((o) => { + const episode = (o.content[0] || {}).episode ?? null; + const hasEpisode = episode !== null; + const siteUrl = `/${siteLocale}/lp/podcast`; + return { + image: `${API_URL}/assets/${o.image}`, + release_date: o.release_date, + url: o.url, + detail_url: hasEpisode ? `${siteUrl}/episode/${episode}` : siteUrl, + title: (o.content[0] || {}).title, + description: (o.content[0] || {}).description, + readmore: false, + }; + }); this.podcasts = podcasts.sort((a, b) => new Date(b.release_date) - new Date(a.release_date)); }, // beforeUpdate() {}, @@ -308,9 +315,15 @@ export default { } } - & > div.content { + & > a.content { + display: block; + text-decoration: none !important; + line-height: normal; + color: inherit; + h4 { margin-bottom: 10px; + line-height: 1.1; } .description { display: -webkit-box; diff --git a/src/router/index.js b/src/router/index.js index f2feba1..1f635ae 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -21,6 +21,7 @@ import SingleJob from '@/views/SingleJob.vue'; import NewsIndex from '@/views/news/index.vue'; import EcoSystemFiltered from '@/views/ecosystem/filtered.vue'; import NewsFiltered from '@/views/news/filtered.vue'; +import PodcastDetail from '@/views/PodcastDetail.vue'; const { api } = directus; const { LANGUAGES, API_URL } = config; @@ -64,6 +65,12 @@ export function getRouter() { ...r, component: VIEW_MAPPING[r.meta.page || r.meta.details || r.meta.filtered], })); + routes = routes.concat([{ + name: 'podcast-detail', + path: '/:lang/lp/podcast/episode/:slug', + component: PodcastDetail, + props: route => ({ episode: route.params.slug }), + }]); Vue.use(Router); const router = new Router({ mode: 'history', diff --git a/src/views/PodcastDetail.vue b/src/views/PodcastDetail.vue new file mode 100644 index 0000000..b029704 --- /dev/null +++ b/src/views/PodcastDetail.vue @@ -0,0 +1,244 @@ + + + + +