Created
February 22, 2023 19:03
-
-
Save ttscoff/a8c902d533288a3b3b2e3ca47a75ee52 to your computer and use it in GitHub Desktop.
TextExpander JavaScript for generating Hugo youtube tag with a YouTube url in clipboard
This file contains 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
var url = TextExpander.pasteboardText; | |
var youtubeRx = /(?:youtu\.be\/|youtube\.com\/watch\?v=)([a-z0-9_\-]+)$/i | |
if (youtubeRx.test(url)) { | |
var id = youtubeRx.exec(url)[1]; | |
TextExpander.appendOutput(`{< youtube ${id}>}`); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment