-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render EmbedFallback when third-party consent is not given
- Loading branch information
1 parent
06b594b
commit 73c182a
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
components/ContentRenderer/components/EmbedFallback.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.imageFallback { | ||
display: block; | ||
margin: $spacing-4 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/* eslint-disable @next/next/no-img-element */ | ||
|
||
'use client'; | ||
|
||
import type { EmbedNode } from '@prezly/story-content-format'; | ||
import NextLink from 'next/link'; | ||
|
||
import styles from './EmbedFallback.module.scss'; | ||
|
||
interface Props { | ||
node: EmbedNode; | ||
} | ||
|
||
export function EmbedFallback({ node }: Props) { | ||
if (node.oembed.screenshot_url) { | ||
return ( | ||
<NextLink className={styles.imageFallback} href={node.url} target="__blank"> | ||
<img | ||
src={node.oembed.screenshot_url} | ||
alt={node.oembed.title || node.oembed.description || ''} | ||
/> | ||
</NextLink> | ||
); | ||
} | ||
|
||
return null; | ||
} |