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