Skip to content

Commit

Permalink
fix(podcast): use html text & only render image if there is one
Browse files Browse the repository at this point in the history
  • Loading branch information
42tte committed Sep 9, 2024
1 parent 28d22f5 commit a4e8276
Show file tree
Hide file tree
Showing 3 changed files with 303 additions and 3 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"embla-carousel-react": "^8.2.0",
"framer-motion": "^10.16.4",
"gray-matter": "^4.0.3",
"isomorphic-dompurify": "^2.15.0",
"markdown-it": "^13.0.2",
"next": "^14.0.2",
"next-images": "^1.8.5",
Expand Down
9 changes: 6 additions & 3 deletions src/rss/feed/Podcast.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import { BaseBlob } from '@variant/components/lib/blob';
import dynamic from 'next/dynamic';
import DOMPurify from 'isomorphic-dompurify';
import { and } from 'src/utils/css';
import { PodcastItem } from '../index';
import style from './feed.module.css';

const Player = dynamic(() => import('./Player'), { ssr: false });

export default function Podcast({ item }: { item: PodcastItem }) {
const cleanDescription = DOMPurify.sanitize(item.description);

return (
<div className={and(style.card, style['card--podcast'])}>
<div className={style.media}>
<BaseBlob
{item.imageCoverUrl && <BaseBlob
height={200}
width={200}
randomness={2}
Expand All @@ -21,7 +24,7 @@ export default function Podcast({ item }: { item: PodcastItem }) {
loading: 'lazy',
decoding: 'async',
}}
/>
/>}
</div>
<div className={style.text}>
<div className={style.podcast__content}>
Expand All @@ -40,7 +43,7 @@ export default function Podcast({ item }: { item: PodcastItem }) {
</div>
</Player>
<div className={style.published}>Publisert {item.publishDate}</div>
<p className={style.summary}>{item.description}</p>
<div dangerouslySetInnerHTML={{ __html: cleanDescription }} />
</div>
</div>
</div>
Expand Down
Loading

0 comments on commit a4e8276

Please sign in to comment.