Last active
March 4, 2022 05:41
-
-
Save RoyalIcing/5cabb793e7e4ba961c00a807323e0afe to your computer and use it in GitHub Desktop.
YouTube URL YieldParser
This file contains hidden or 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
function* VideoID() { | |
const [videoID] = yield /^[a-zA-Z0-9_]+$/; | |
return videoID; | |
} | |
function* Long() { | |
yield "https://www.youtube.com/watch?v="; | |
const videoID = yield VideoID; | |
return videoID; | |
} | |
function* Embed() { | |
yield "https://www.youtube.com/embed/"; | |
const videoID = yield VideoID; | |
return videoID; | |
} | |
function* Short() { | |
yield "https://youtu.be/"; | |
const videoID = yield VideoID; | |
return videoID; | |
} | |
export function* YouTubeURL() { | |
const videoID = yield [Long, Embed, Short]; | |
yield mustEnd; | |
return videoID; | |
} | |
// export function* YouTubeEmbed() { | |
// const videoID = yield YouTubeURL; | |
// yield importModule("https://cdn.jsdelivr.net/npm/lite-youtube-embed"); | |
// return `<lite-youtube videoid="${videoID}"></lite-youtube>`; | |
// } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment