Skip to content

Commit 9134360

Browse files
committed
feat: handle EventCard rendering in document
1 parent 71440e9 commit 9134360

File tree

7 files changed

+79
-23
lines changed

7 files changed

+79
-23
lines changed

components.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ declare module 'vue' {
1515
ChevronIcon: typeof import('./src/components/icons/ChevronIcon.vue')['default']
1616
ComingSoonBanner: typeof import('./src/components/banners/ComingSoonBanner.vue')['default']
1717
copy: typeof import('./src/components/cards/EventCards copy.vue')['default']
18+
EventCard: typeof import('./src/components/cards/EventCard.vue')['default']
1819
EventCards: typeof import('./src/components/cards/EventCards.vue')['default']
1920
GlobeIcon: typeof import('./src/components/icons/GlobeIcon.vue')['default']
2021
GlobeRBCN: typeof import('./src/components/icons/GlobeRBCN.vue')['default']

src/components/cards/EventCard.vue

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<script setup lang="ts">
2+
import { PropType } from 'vue';
3+
4+
type Styling = 'primary' | 'secondary'
5+
defineProps({
6+
title: String,
7+
description: String,
8+
styling: String as PropType<Styling>
9+
})
10+
11+
</script>
12+
13+
<template>
14+
<v-col cols="12" sm="4">
15+
<v-card elevation="2" rounded="md">
16+
17+
<div style="height: 240px; width: 240px;"></div>
18+
19+
<v-card-item class="pt-0">
20+
<h4 class="text-h5" v-text="title" :class="styling === 'secondary' ? 'text-white' : 'text-primary'"></h4>
21+
<div class="d-flex align-center justify-space-between mt-1">
22+
<div>
23+
<span :class="[
24+
styling === 'secondary' ? 'text-white' : 'text-black', 'text-body-1 text-medium-emphasis']"
25+
v-text="description"></span>
26+
</div>
27+
<div class="d-flex justify-end">
28+
<v-btn size="xs" variant="text" :color="styling === 'secondary' ? 'white' : 'secondary'" class="d-flex">
29+
more
30+
</v-btn>
31+
</div>
32+
</div>
33+
</v-card-item>
34+
</v-card>
35+
</v-col>
36+
</template>

src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export { default as NotFoundBanner } from './banners/NotFoundBanner.vue'
55
export { default as ComingSoonBanner } from './banners/ComingSoonBanner.vue'
66

77
export { default as EventCards } from './cards/EventCards.vue'
8+
export { default as EventCard } from './cards/EventCard.vue'
89
export { default as SpeakerCards } from './cards/SpeakerCards.vue'
910

1011
export { default as PageFooter } from './footer/PageFooter.vue'

src/components/sections/PageSection.vue

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
<template>
2-
<v-row :class="bg ? `bg-${bg}` : ''">
3-
<v-responsive class="mx-auto py-10" max-width="960">
4-
<h2>{{ props.title }}</h2>
5-
<slot></slot>
6-
</v-responsive>
7-
</v-row>
2+
<div>
3+
<v-container>
4+
<v-row>
5+
<h2>{{ props.title }}</h2>
6+
</v-row>
7+
<v-row>
8+
<slot></slot>
9+
</v-row>
10+
</v-container>
11+
</div>
812
</template>
913

1014

src/content/contentful.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { createClient } from 'contentful'
22

33
const client = createClient({
44
space: '0375ld2k0qal',
5-
environment: 'master',
6-
accessToken: '0JsLjZA5NNToRRuCN_8kQDlK1AiOI3ExSRNlaNM1sec'
5+
environment: 'dev',
6+
accessToken: 'QODt2cpA7LqQsSoqZd1oQ38yKLR7qQjh_UDHpOZYWOs'
77
})
88

99
const getPages = () => client
@@ -17,4 +17,4 @@ const getEntries = () => client
1717
export {
1818
getPages,
1919
getEntries
20-
}
20+
}

src/views/Sponsor.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@
4545
</template>
4646

4747
<script>
48-
import { Banner } from 'Components'
4948
import { marked } from 'marked'
5049
5150
export default {
5251
name: 'Sponsor',
5352
components: {
54-
Banner
5553
},
5654
methods: {
5755
parseMarkdown(text) {

src/views/main/Home.vue

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,18 @@
1414

1515
</div>
1616

17-
<v-container fluid class="pa-0">
18-
1917
<news-banner v-if="$t('newsBanner') !== ''">
2018
<div v-html="$t('newsBanner')" />
2119
</news-banner>
2220

23-
<page-section v-for="(section, index) in sections" :key="section.data.target.fields.title"
24-
:titleId="section.data.target.fields.title" :title="section.data.target.fields.title"
25-
:bg="index % 2 === 1 ? 'surface-bright' : undefined">
26-
<RichTextRenderer :document="section.data.target.fields.body" :nodeRenderers="renderNodes()" />
21+
<page-section
22+
v-for="(section, index) in sections"
23+
:key="section.data.target.fields.title"
24+
:title="section.data.target.fields.shownTitle"
25+
:class="index % 2 && 'bg-surface-bright'">
26+
<RichTextRenderer
27+
:document="section.data.target.fields.body"
28+
:nodeRenderers="renderNodes()" />
2729
</page-section>
2830

2931
<div class="bg-surface-bright">
@@ -36,9 +38,6 @@
3638
<SpeakerCards />
3739
</v-responsive>
3840

39-
40-
</v-container>
41-
4241
</template>
4342

4443
<script>
@@ -47,11 +46,13 @@ import {
4746
PageSection,
4847
NewsBanner,
4948
EventCards,
49+
EventCard,
5050
SpeakerCards,
5151
TicketItem,
5252
SponsorItem
5353
} from '@/components'
5454
import RichTextRenderer from 'contentful-rich-text-vue-renderer'
55+
import { BLOCKS } from '@contentful/rich-text-types';
5556
import { h } from 'vue'
5657
import { useGlobalStore } from '@/store';
5758
import { mapState } from 'pinia';
@@ -70,7 +71,8 @@ export default {
7071
RichTextRenderer,
7172
TicketItem,
7273
SponsorItem,
73-
EventCards
74+
EventCards,
75+
EventCard,
7476
},
7577
computed: {
7678
currentYear() {
@@ -79,6 +81,7 @@ export default {
7981
...mapState(useGlobalStore, ['pages']),
8082
sections() {
8183
const page = this.pages.find((p) => p.fields.pageName === '2025') ?? this.pages[0]
84+
console.log(page)
8285
return page.fields.pageBody.content
8386
.filter((c) => c.nodeType === 'embedded-entry-block')
8487
.map((c) => c)
@@ -108,15 +111,17 @@ export default {
108111
},
109112
renderNodes() {
110113
return {
114+
[BLOCKS.PARAGRAPH]: (node, key, next) => h('p', { class: 'w-100' }, next(node.content, key, next)),
115+
[BLOCKS.HEADING_2]: (node, key, next) => h('h2', { class: 'w-100' }, next(node.content, key, next)),
116+
[BLOCKS.HEADING_3]: (node, key, next) => h('h3', { class: 'w-100' }, next(node.content, key, next)),
117+
[BLOCKS.HEADING_4]: (node, key, next) => h('h4', { class: 'w-100' }, next(node.content, key, next)),
111118
'embedded-entry-inline': (node) => {
112119
const target = node.data.target
113120
const type = target.sys.contentType.sys.id
114121
115122
if (type === 'ticket') {
116123
const { ticketName, href, price, discountedPrice, validFrom, validUntil, highlighted } = target.fields
117124
118-
119-
console.log("type >>>>>", ticketName, price, validUntil)
120125
const isValid =
121126
(!validFrom || (new Date() > new Date(validFrom))) &&
122127
(!validUntil || (new Date() < new Date(validUntil)))
@@ -136,6 +141,17 @@ export default {
136141
137142
return ''
138143
},
144+
'embedded-entry-block': (node) => {
145+
const target = node.data.target
146+
const type = target.sys.contentType.sys.id
147+
148+
if (type === 'card') {
149+
const {cardTitle, description} = target.fields
150+
return h(EventCard, {title: cardTitle, description})
151+
}
152+
153+
return ''
154+
},
139155
'embedded-asset-block': (node) => {
140156
const target = node.data.target
141157
const file = target.fields.file

0 commit comments

Comments
 (0)