|
| 1 | +<script setup> |
| 2 | +// COMPONENT RE-IMPORTS |
| 3 | +// TODO: remove when we have implemented component library as a module |
| 4 | +// https://nuxt.com/docs/guide/directory-structure/components#library-authors |
| 5 | +import { BlockTag, ButtonDropdown, CardMeta, DividerWayFinder, FlexibleMediaGalleryNewLightbox, NavBreadcrumb, ResponsiveImage, RichText, SectionScreeningDetails, SectionTeaserCard, SectionStaffSubjectLibrarian, SectionWrapper, TwoColLayoutWStickySideBar } from 'ucla-library-website-components' |
| 6 | +
|
| 7 | +// HELPERS |
| 8 | +import _get from 'lodash/get' |
| 9 | +import removeTags from '../utils/removeTags' |
| 10 | +
|
| 11 | +// GQL |
| 12 | +import FTVALARebellionFilmmakersDetail from '~/gql/queries/FTVALARebellionFilmmakersDetail.gql' |
| 13 | +
|
| 14 | +// COMPOSABLE |
| 15 | +import { useContentIndexer } from '~/composables/useContentIndexer' |
| 16 | +
|
| 17 | +const { $graphql } = useNuxtApp() |
| 18 | +
|
| 19 | +const route = useRoute() |
| 20 | +
|
| 21 | +// DATA |
| 22 | +const { data, error } = await useAsyncData(`events-detail-${route.params.slug}`, async () => { |
| 23 | + const data = await $graphql.default.request(FTVALARebellionFilmmakersDetail, { slug: route.params.slug }) |
| 24 | + return data |
| 25 | +}) |
| 26 | +
|
| 27 | +if (error.value) { |
| 28 | + throw createError({ |
| 29 | + ...error.value, statusMessage: 'Page not found.' + error.value, fatal: true |
| 30 | + }) |
| 31 | +} |
| 32 | +
|
| 33 | +if (!data.value.ftvaLARebellionIndividual) { |
| 34 | + throw createError({ |
| 35 | + statusCode: 404, |
| 36 | + statusMessage: 'Page Not Found', |
| 37 | + fatal: true |
| 38 | + }) |
| 39 | +} |
| 40 | +
|
| 41 | +// This is creating an index of the content for ES search |
| 42 | +if (data.value.ftvaEvent && import.meta.prerender) { |
| 43 | + try { |
| 44 | + // Call the composable to use the indexing function |
| 45 | + const { indexContent } = useContentIndexer() |
| 46 | + // Index the event data using the composable during static build |
| 47 | + await indexContent(data.value.ftvaLARebellionIndividual, route.params.slug) |
| 48 | + // console.log('Event indexed successfully during static build') |
| 49 | + } catch (error) { |
| 50 | + console.error('FAILED TO INDEX EVENT during static build:', error) |
| 51 | + } |
| 52 | +} |
| 53 | +
|
| 54 | +const page = ref(_get(data.value, 'ftvaLARebellionIndividual', {})) |
| 55 | +// TODO refactor for filmography data ? Delete if not needed |
| 56 | +// const series = ref(_get(data.value, 'ftvaEventSeries', {})) |
| 57 | +
|
| 58 | +watch(data, (newVal, oldVal) => { |
| 59 | + // console.log('In watch preview enabled, newVal, oldVal', newVal, oldVal) |
| 60 | + page.value = _get(newVal, 'ftvaLARebellionIndividual', {}) |
| 61 | + // series.value = _get(newVal, 'ftvaEventSeries', {}) |
| 62 | +}) |
| 63 | +
|
| 64 | +// Get data for Image or Carousel at top of page |
| 65 | +const parsedImage = computed(() => { |
| 66 | + return page.value.imageCarousel |
| 67 | +}) |
| 68 | +
|
| 69 | +// Transform data for Carousel |
| 70 | +const parsedCarouselData = computed(() => { |
| 71 | + // map image to item, map creditText to credit |
| 72 | + return parsedImage.value.map((rawItem, index) => { |
| 73 | + return { |
| 74 | + item: [{ ...rawItem.image[0], kind: 'image' }], // Carousels on this page are always images, no videos |
| 75 | + credit: rawItem?.creditText, |
| 76 | + } |
| 77 | + }) |
| 78 | +}) |
| 79 | +
|
| 80 | +useHead({ |
| 81 | + title: page.value ? page.value.title : '... loading', |
| 82 | + meta: [ |
| 83 | + { |
| 84 | + hid: 'description', |
| 85 | + name: 'description', |
| 86 | + content: removeTags(page.value.text) |
| 87 | + } |
| 88 | + ] |
| 89 | +}) |
| 90 | +</script> |
| 91 | +
|
| 92 | +<template> |
| 93 | + <main |
| 94 | + id="main" |
| 95 | + class="page page-detail page-event-detail" |
| 96 | + > |
| 97 | + <div class="one-column"> |
| 98 | + <NavBreadcrumb |
| 99 | + class="breadcrumb" |
| 100 | + data-test="breadcrumb" |
| 101 | + :title="page?.title" |
| 102 | + /> |
| 103 | +
|
| 104 | + <ResponsiveImage |
| 105 | + v-if="parsedImage && parsedImage.length === 1 && parsedImage[0]?.image && parsedImage[0]?.image?.length === 1" |
| 106 | + data-test="single-image" |
| 107 | + :media="parsedImage[0]?.image[0]" |
| 108 | + :aspect-ratio="43.103" |
| 109 | + > |
| 110 | + <template |
| 111 | + v-if="parsedImage[0]?.creditText" |
| 112 | + #credit |
| 113 | + > |
| 114 | + {{ parsedImage[0]?.creditText }} |
| 115 | + </template> |
| 116 | + </ResponsiveImage> |
| 117 | + <div |
| 118 | + v-else |
| 119 | + class="lightbox-container" |
| 120 | + > |
| 121 | + <FlexibleMediaGalleryNewLightbox |
| 122 | + data-test="image-carousel" |
| 123 | + :items="parsedCarouselData" |
| 124 | + inline="true" |
| 125 | + > |
| 126 | + <template #default="slotProps"> |
| 127 | + <BlockTag |
| 128 | + data-test="credit-text" |
| 129 | + :label="parsedCarouselData[slotProps.selectionIndex]?.creditText" |
| 130 | + /> |
| 131 | + </template> |
| 132 | + </FlexibleMediaGalleryNewLightbox> |
| 133 | + </div> |
| 134 | + </div> |
| 135 | +
|
| 136 | + <TwoColLayoutWStickySideBar |
| 137 | + data-test="second-column" |
| 138 | + class="two-column" |
| 139 | + > |
| 140 | + <template #primaryTop> |
| 141 | + <!-- <CardMeta |
| 142 | + data-test="text-block" |
| 143 | + :title="page?.title" |
| 144 | + > --> |
| 145 | + {{ page }} |
| 146 | + </template> |
| 147 | + </TwoColLayoutWStickySideBar> |
| 148 | +
|
| 149 | + <!-- TODO: add conditional render once vars exist |
| 150 | + v-if="parsedFilmography && parsedFilmography.length > 0" --> |
| 151 | + <SectionWrapper |
| 152 | + section-title="Filmography" |
| 153 | + theme="paleblue" |
| 154 | + class="series-section-wrapper" |
| 155 | + > |
| 156 | + <!-- <SectionStaffSubjectLibrarian /> --> |
| 157 | + </SectionWrapper> |
| 158 | + </main> |
| 159 | +</template> |
| 160 | +
|
| 161 | +<style lang="scss" scoped> |
| 162 | +// PAGE STYLES - USE OLD STYLES |
| 163 | +// .page-event-detail { |
| 164 | +// position: relative; |
| 165 | +
|
| 166 | +// .two-column { |
| 167 | +
|
| 168 | +// .ftva.button-dropdown { |
| 169 | +// margin-top: 30px; |
| 170 | +// } |
| 171 | +
|
| 172 | +// .ftva.block-info { |
| 173 | +// margin-top: 48px; |
| 174 | +// } |
| 175 | +
|
| 176 | +// // SECTION SCREENING DETAILS |
| 177 | +// // TODO when component is patched, remove styles? |
| 178 | +// :deep(figure.responsive-video:not(:has(.video-embed))) { |
| 179 | +// display: none; |
| 180 | +// } |
| 181 | +// } |
| 182 | +
|
| 183 | +// /* makes all EventSeries same height */ |
| 184 | +// :deep(.card) { |
| 185 | +// min-height: 350px; |
| 186 | +// } |
| 187 | +
|
| 188 | +// @media (max-width: 1200px) { |
| 189 | +// :deep(.primary-column) { |
| 190 | +// width: 65%; |
| 191 | +// } |
| 192 | +// } |
| 193 | +
|
| 194 | +// @media (max-width: 899px) { |
| 195 | +// :deep(.primary-column) { |
| 196 | +// width: inherit; |
| 197 | +// } |
| 198 | +
|
| 199 | +// :deep(.block-tags) { |
| 200 | +// padding-top: 30px; |
| 201 | +// } |
| 202 | +// } |
| 203 | +// } |
| 204 | +
|
| 205 | +@import 'assets/styles/slug-pages.scss'; |
| 206 | +</style> |
0 commit comments