Skip to content

Commit c18928b

Browse files
committed
fix issue with end date logic
1 parent a1ee39d commit c18928b

File tree

2 files changed

+171
-174
lines changed

2 files changed

+171
-174
lines changed

apps/codingcatdev/src/lib/server/content.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -207,9 +207,8 @@ export const getContentBySlug = async ({
207207
:
208208
(c) =>
209209
c.slug == slug &&
210-
new Date(c.start) <= new Date() &&
211-
c.published === ContentPublished.published &&
212-
c.end ? new Date(c.end) > new Date() : true
210+
new Date(c.start) <= new Date() &&
211+
c.published === ContentPublished.published
213212
)
214213
.sort((a, b) => new Date(b.start).valueOf() - new Date(a.start).valueOf())
215214
.slice(0, 1)

apps/codingcatdev/src/routes/(content-single)/(non-course)/Content.svelte

Lines changed: 169 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -20,191 +20,189 @@
2020
</script>
2121

2222
{#if data?.content}
23-
{#key data.content.slug}
24-
<div class="flex justify-center">
25-
<section class="flex flex-col justify-center w-full gap-8 p-2 xl:flex-row xl:p-8">
26-
<div class="flex flex-col w-full gap-2 md:gap-8 max-w-7xl">
27-
<ol class="bcu-breadcrumb">
28-
<li class="capitalize bcu-crumb"><a href={`/${title}`}>{title}</a></li>
29-
<li class="bcu-crumb-separator" aria-hidden>&rsaquo;</li>
30-
<li>{data.content.title}</li>
31-
</ol>
32-
{#if data?.content?.youtube}
33-
<Video src={data.content.youtube} title={`${data.content.title}`} />
34-
{:else if data?.content?.cover}
35-
<Image src={data.content.cover} alt={data.content.title} />
36-
{/if}
37-
38-
<div class="flex gap-2 md:gap-8">
39-
<!-- Guests -->
40-
{#if data?.guests}
41-
<section class="flex gap-2 md:gap-8">
42-
{#each data?.guests as guest (guest.slug)}
43-
<a
44-
class="flex items-center gap-2 p-2 rounded-md bcu-button variant-ghost"
45-
href={`/guest/${guest.slug}`}
46-
>
47-
{#if guest?.cover}
48-
<div class="w-8 md:w-12">
49-
{#key guest.slug}
50-
<Image
51-
src={guest.cover}
52-
alt={guest.name}
53-
classes="object-cover w-full bg-cover rounded bg-black/50 aspect-square"
54-
/>
55-
{/key}
56-
</div>
57-
{/if}
58-
<div>{guest?.name}</div>
59-
</a>
60-
{/each}
61-
</section>
62-
{/if}
63-
64-
<!-- Authors -->
65-
{#if data?.authors}
66-
<section class="flex gap-2 md:gap-8">
67-
{#each data?.authors as author (author.slug)}
68-
<a
69-
class="flex items-center gap-2 p-2 rounded-md bcu-button variant-ghost"
70-
href={`/author/${author.slug}`}
71-
>
72-
{#if author?.cover}
73-
<div class="w-8 md:w-12">
74-
{#key author.slug}
75-
<Image
76-
src={author.cover}
77-
alt={author?.name}
78-
classes="object-cover w-full bg-cover rounded bg-black/50 aspect-square"
79-
/>
80-
{/key}
81-
</div>
82-
{/if}
83-
<div>{author?.name}</div>
84-
</a>
85-
{/each}
86-
</section>
87-
{/if}
88-
</div>
23+
<div class="flex justify-center">
24+
<section class="flex flex-col justify-center w-full gap-8 p-2 xl:flex-row xl:p-8">
25+
<div class="flex flex-col w-full gap-2 md:gap-8 max-w-7xl">
26+
<ol class="bcu-breadcrumb">
27+
<li class="capitalize bcu-crumb"><a href={`/${title}`}>{title}</a></li>
28+
<li class="bcu-crumb-separator" aria-hidden>&rsaquo;</li>
29+
<li>{data.content.title}</li>
30+
</ol>
31+
{#if data?.content?.youtube}
32+
<Video src={data.content.youtube} title={`${data.content.title}`} />
33+
{:else if data?.content?.cover}
34+
<Image src={data.content.cover} alt={data.content.title} />
35+
{/if}
8936

90-
<!-- Sponsors -->
91-
{#if data?.sponsors}
92-
<hr />
37+
<div class="flex gap-2 md:gap-8">
38+
<!-- Guests -->
39+
{#if data?.guests}
40+
<section class="flex gap-2 md:gap-8">
41+
{#each data?.guests as guest (guest.slug)}
42+
<a
43+
class="flex items-center gap-2 p-2 rounded-md bcu-button variant-ghost"
44+
href={`/guest/${guest.slug}`}
45+
>
46+
{#if guest?.cover}
47+
<div class="w-8 md:w-12">
48+
{#key guest.slug}
49+
<Image
50+
src={guest.cover}
51+
alt={guest.name}
52+
classes="object-cover w-full bg-cover rounded bg-black/50 aspect-square"
53+
/>
54+
{/key}
55+
</div>
56+
{/if}
57+
<div>{guest?.name}</div>
58+
</a>
59+
{/each}
60+
</section>
61+
{/if}
9362

94-
<h2>Sponsors</h2>
95-
<section class="flex flex-col gap-2 md:flex-row md:gap-8">
96-
{#each data?.sponsors as sponsor (sponsor.slug)}
63+
<!-- Authors -->
64+
{#if data?.authors}
65+
<section class="flex gap-2 md:gap-8">
66+
{#each data?.authors as author (author.slug)}
9767
<a
98-
class="max-w-sm overflow-hidden bcu-card bg-initial card-hover"
99-
href={`${sponsor.url}`}
100-
target="_blank"
101-
rel="noopener noreferrer"
68+
class="flex items-center gap-2 p-2 rounded-md bcu-button variant-ghost"
69+
href={`/author/${author.slug}`}
10270
>
103-
<header>
104-
{#if sponsor?.cover}
105-
<Image
106-
src={sponsor.cover}
107-
alt={sponsor.name}
108-
classes="object-cover w-full bg-cover rounded bg-black/50 aspect-video"
109-
/>
110-
{/if}
111-
</header>
112-
<div class="p-4 space-y-4">
113-
<h3 data-toc-ignore="">{sponsor?.name}</h3>
114-
<article>
115-
<p>
116-
{sponsor?.description}
117-
</p>
118-
</article>
119-
</div>
71+
{#if author?.cover}
72+
<div class="w-8 md:w-12">
73+
{#key author.slug}
74+
<Image
75+
src={author.cover}
76+
alt={author?.name}
77+
classes="object-cover w-full bg-cover rounded bg-black/50 aspect-square"
78+
/>
79+
{/key}
80+
</div>
81+
{/if}
82+
<div>{author?.name}</div>
12083
</a>
12184
{/each}
12285
</section>
12386
{/if}
87+
</div>
88+
89+
<!-- Sponsors -->
90+
{#if data?.sponsors}
91+
<hr />
12492

125-
<!-- Main Content -->
126-
<section class="flex flex-col flex-grow w-full gap-2 markdown md:gap-8">
127-
<CopyCodeInjector>
128-
{@html data.content.html}
129-
</CopyCodeInjector>
93+
<h2>Sponsors</h2>
94+
<section class="flex flex-col gap-2 md:flex-row md:gap-8">
95+
{#each data?.sponsors as sponsor (sponsor.slug)}
96+
<a
97+
class="max-w-sm overflow-hidden bcu-card bg-initial card-hover"
98+
href={`${sponsor.url}`}
99+
target="_blank"
100+
rel="noopener noreferrer"
101+
>
102+
<header>
103+
{#if sponsor?.cover}
104+
<Image
105+
src={sponsor.cover}
106+
alt={sponsor.name}
107+
classes="object-cover w-full bg-cover rounded bg-black/50 aspect-video"
108+
/>
109+
{/if}
110+
</header>
111+
<div class="p-4 space-y-4">
112+
<h3 data-toc-ignore="">{sponsor?.name}</h3>
113+
<article>
114+
<p>
115+
{sponsor?.description}
116+
</p>
117+
</article>
118+
</div>
119+
</a>
120+
{/each}
130121
</section>
122+
{/if}
131123

132-
<!-- Podcast Picks -->
133-
{#if picks?.length}
134-
<div class="flex flex-col gap-2 md:gap-8">
135-
{#if data?.guests}
136-
<h2>Guest Picks</h2>
124+
<!-- Main Content -->
125+
<section class="flex flex-col flex-grow w-full gap-2 markdown md:gap-8">
126+
<CopyCodeInjector>
127+
{@html data.content.html}
128+
</CopyCodeInjector>
129+
</section>
137130

138-
<section class="flex flex-col gap-2 md:gap-8">
139-
{#each data?.guests as guest (guest.slug)}
140-
<div class="bcu-card">
141-
<header class="flex items-center gap-2 bcu-card-header md:gap-8">
142-
{#if guest?.cover}
143-
<div class="w-8 md:w-12">
144-
{#key guest.slug}
145-
<Image src={guest.cover} alt={guest?.name} />
146-
{/key}
147-
</div>
148-
{/if}
149-
<h3>{guest?.name}</h3>
150-
</header>
151-
<section class="flex flex-wrap gap-2 p-4 md:gap-8">
152-
{#each picks.filter((p) => p?.author === guest?.slug) as pick (pick.name)}
153-
<a
154-
class="flex gap-2 bcu-button variant-soft-primary"
155-
href={pick.site}
156-
target="_blank"
157-
rel="noopener noreferrer"
158-
>
159-
{pick.name}
160-
<Icon src={ArrowTopRightOnSquare} theme="solid" class="w-6" />
161-
</a>
162-
{/each}
163-
</section>
164-
</div>
165-
{/each}
166-
</section>
167-
{/if}
131+
<!-- Podcast Picks -->
132+
{#if picks?.length}
133+
<div class="flex flex-col gap-2 md:gap-8">
134+
{#if data?.guests}
135+
<h2>Guest Picks</h2>
168136

169-
{#if data?.authors}
170-
<h2>Host Picks</h2>
137+
<section class="flex flex-col gap-2 md:gap-8">
138+
{#each data?.guests as guest (guest.slug)}
139+
<div class="bcu-card">
140+
<header class="flex items-center gap-2 bcu-card-header md:gap-8">
141+
{#if guest?.cover}
142+
<div class="w-8 md:w-12">
143+
{#key guest.slug}
144+
<Image src={guest.cover} alt={guest?.name} />
145+
{/key}
146+
</div>
147+
{/if}
148+
<h3>{guest?.name}</h3>
149+
</header>
150+
<section class="flex flex-wrap gap-2 p-4 md:gap-8">
151+
{#each picks.filter((p) => p?.author === guest?.slug) as pick (pick.name)}
152+
<a
153+
class="flex gap-2 bcu-button variant-soft-primary"
154+
href={pick.site}
155+
target="_blank"
156+
rel="noopener noreferrer"
157+
>
158+
{pick.name}
159+
<Icon src={ArrowTopRightOnSquare} theme="solid" class="w-6" />
160+
</a>
161+
{/each}
162+
</section>
163+
</div>
164+
{/each}
165+
</section>
166+
{/if}
171167

172-
<section class="flex flex-col gap-2 md:gap-8">
173-
{#each data?.authors as author (author.slug)}
174-
<div class="bcu-card">
175-
<header class="flex items-center gap-2 bcu-card-header md:gap-8">
176-
{#if author?.cover}
177-
<div class="w-8 md:w-12">
178-
{#key author.slug}
179-
<Image src={author.cover} alt={author?.name} />
180-
{/key}
181-
</div>
182-
{/if}
183-
<h3>{author?.name}</h3>
184-
</header>
185-
<section class="flex flex-wrap gap-2 p-4 md:gap-8">
186-
{#each picks.filter((p) => p?.author === author?.slug) as pick (pick.name)}
187-
<a
188-
class="flex gap-2 bcu-button variant-soft-primary"
189-
href={pick.site}
190-
target="_blank"
191-
rel="noopener noreferrer"
192-
>
193-
{pick.name}
194-
<Icon src={ArrowTopRightOnSquare} theme="solid" class="w-6" />
195-
</a>
196-
{/each}
197-
</section>
198-
</div>
199-
{/each}
200-
</section>
201-
{/if}
202-
</div>
203-
{/if}
204-
</div>
205-
</section>
206-
</div>
207-
{/key}
168+
{#if data?.authors}
169+
<h2>Host Picks</h2>
170+
171+
<section class="flex flex-col gap-2 md:gap-8">
172+
{#each data?.authors as author (author.slug)}
173+
<div class="bcu-card">
174+
<header class="flex items-center gap-2 bcu-card-header md:gap-8">
175+
{#if author?.cover}
176+
<div class="w-8 md:w-12">
177+
{#key author.slug}
178+
<Image src={author.cover} alt={author?.name} />
179+
{/key}
180+
</div>
181+
{/if}
182+
<h3>{author?.name}</h3>
183+
</header>
184+
<section class="flex flex-wrap gap-2 p-4 md:gap-8">
185+
{#each picks.filter((p) => p?.author === author?.slug) as pick (pick.name)}
186+
<a
187+
class="flex gap-2 bcu-button variant-soft-primary"
188+
href={pick.site}
189+
target="_blank"
190+
rel="noopener noreferrer"
191+
>
192+
{pick.name}
193+
<Icon src={ArrowTopRightOnSquare} theme="solid" class="w-6" />
194+
</a>
195+
{/each}
196+
</section>
197+
</div>
198+
{/each}
199+
</section>
200+
{/if}
201+
</div>
202+
{/if}
203+
</div>
204+
</section>
205+
</div>
208206
{:else}
209207
<p>No data found yet</p>
210208
{/if}

0 commit comments

Comments
 (0)