Skip to content

Commit 1205276

Browse files
committed
Conditionally add data-datocms-content-link-source to VideoPlayer
Only include the data-datocms-content-link-source attribute when the alt field contains stega encoding (decodeStega(alt) !== null). This prevents the attribute from being added when there is no content link metadata present.
1 parent 7f1eade commit 1205276

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/VideoPlayer/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import MuxPlayer from '@mux/mux-player-react/lazy';
2727
// `<MuxPlayer />` component.
2828

2929
import { useVideoPlayer } from '../useVideoPlayer/index.js';
30+
import { decodeStega } from '@datocms/content-link';
3031

3132
type Maybe<T> = T | null;
3233
type Possibly<T> = Maybe<T> | undefined;
@@ -98,6 +99,9 @@ export const VideoPlayer: (
9899
// See: https://github.com/datocms/content-link
99100
const { alt } = data;
100101

102+
// Only include data-datocms-content-link-source if alt contains stega encoding
103+
const contentLinkSource = alt && decodeStega(alt) !== null ? alt : undefined;
104+
101105
// Note: Custom data-* attributes can be passed to the underlying <mux-player> web component
102106
// in two ways:
103107
//
@@ -125,7 +129,7 @@ export const VideoPlayer: (
125129
playbackId={playbackId}
126130
style={style}
127131
placeholder={placeholder}
128-
data-datocms-content-link-source={alt}
132+
data-datocms-content-link-source={contentLinkSource}
129133
{...rest}
130134
/>
131135
);

0 commit comments

Comments
 (0)