fix(viewer): yt directive
This commit is contained in:
parent
0760a3e81e
commit
a6ed390fad
@ -6,7 +6,7 @@ export const youtubeDirective: DirectiveConfig = {
|
||||
marker: '::',
|
||||
renderer(token) {
|
||||
//https://www.youtube.com/embed/<VIDEO_ID>
|
||||
//{#<VIDEO_ID>}
|
||||
//::youtube{#<VIDEO_ID>}
|
||||
let vid: string = ''
|
||||
if (token.attrs && token.meta.name === 'youtube') {
|
||||
for (const attr in token.attrs) {
|
||||
@ -15,15 +15,12 @@ export const youtubeDirective: DirectiveConfig = {
|
||||
attr.startsWith('#')
|
||||
) {
|
||||
vid = attr.replace('#', '')
|
||||
console.log(vid)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vid) {
|
||||
return `<iframe width="560" height="315" src="https://www.youtube.com/embed/${vid}" title="${
|
||||
token.text || ''
|
||||
}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>`
|
||||
return `<iframe width="560" height="315" src="https://www.youtube.com/embed/${vid}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" allowfullscreen></iframe>`
|
||||
}
|
||||
|
||||
return false
|
||||
|
Loading…
x
Reference in New Issue
Block a user