Skip to content

Commit c444d95

Browse files
committed
add spotify
1 parent baf0b3b commit c444d95

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<script lang="ts">
2+
export let src: string;
3+
export let title: string;
4+
5+
const spotifyParser = (url: string) => {
6+
return new URL(url).pathname.split('/').at(-1);
7+
};
8+
$: finalSrc = `https://open.spotify.com/embed/episode/${spotifyParser(
9+
src
10+
)}?utm_source=generator&theme=0`;
11+
</script>
12+
13+
<iframe
14+
frameborder="0"
15+
{title}
16+
allowfullscreen
17+
allow="autoplay; clipboard-write; encrypted-media; fullscreen; picture-in-picture"
18+
loading="lazy"
19+
width="100%"
20+
height="160"
21+
src={finalSrc}
22+
/>

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
import { ArrowTopRightOnSquare } from '@steeze-ui/heroicons';
55
66
import Video from '$lib/components/content/Video.svelte';
7-
import type { Author, Content, ContentType, Podcast, Sponsor } from '$lib/types';
7+
import type { Author, Content, Podcast, Sponsor } from '$lib/types';
8+
import { ContentType } from '$lib/types';
89
import { pluralize } from '$lib/utils';
910
import Image from '$lib/components/content/Image.svelte';
1011
import CopyCodeInjector from '$lib/components/content/CopyCodeInjector.svelte';
12+
import PodcastComponent from '$lib/components/content/Podcast.svelte';
1113
export let data: {
1214
content: Content & Podcast;
1315
guests?: Author[];
@@ -34,6 +36,10 @@
3436
<Image src={data.content.cover} alt={data.content.title} />
3537
{/if}
3638

39+
{#if data.content.type === ContentType.podcast && data.content?.spotify}
40+
<PodcastComponent src={data.content.spotify} title={`${data.content.title}`} />
41+
{/if}
42+
3743
<div class="flex gap-2 md:gap-8 overflow-x-auto">
3844
<!-- Guests -->
3945
{#if data?.guests && data?.guests?.length}

0 commit comments

Comments
 (0)