Skip to content

Commit eca6844

Browse files
committed
Add content link support to VideoPlayer
- Add `alt` field to Video type for DatoCMS Content Link integration - Pass `alt` as `data-datocms-content-link-source` attribute to enable click-to-edit overlays
1 parent 57a01ad commit eca6844

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/components/VideoPlayer/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ type Possibly<T> = Maybe<T> | undefined;
2323
export type Video = {
2424
/** Title attribute (`title`) for the video */
2525
title?: Possibly<string>;
26+
/** Alt attribute used for content link integration (passed as data-datocms-content-link-source) */
27+
alt?: Possibly<string>;
2628
/** The height of the video */
2729
height?: Possibly<number>;
2830
/** The width of the video */
@@ -386,6 +388,10 @@ export const VideoPlayer = defineComponent({
386388

387389
const muxPlayerRef = ref<MuxPlayerElement>();
388390

391+
// Extract alt for DatoCMS Content Link integration
392+
// See: https://github.com/datocms/content-link
393+
const { alt } = data;
394+
389395
const computedProps = {
390396
...useVideoPlayer({ data }),
391397
disableCookies,
@@ -397,6 +403,7 @@ export const VideoPlayer = defineComponent({
397403
muxPlayerRef,
398404
computedProps,
399405
otherProps,
406+
alt,
400407
};
401408
},
402409
mounted() {
@@ -482,6 +489,7 @@ export const VideoPlayer = defineComponent({
482489
return h('mux-player', {
483490
ref: 'muxPlayerRef',
484491
'stream-type': 'on-demand',
492+
'data-datocms-content-link-source': this.alt,
485493
...toHTMLAttrs(this.computedProps),
486494
...toHTMLAttrs(this.otherProps),
487495
});

0 commit comments

Comments
 (0)