I have a Jekyll setup that is working out well for me, but I would like to spice up my site by taking YouTube links that are inside their own <p>
and automatically embed and image inside.
I have figured out the format for YouTube links.
https://img.youtube.com/vi/<videoid>/0.jpg
and I have found a regular expression to match the video id inside a YouTube link.
v=(\w+)">
I have figured out also I need a :post-render
hook and I have the plugin set up and running.
I am a bit stuck on what to do next, I am not a ruby expert and I am absolutely terrible at regular expressions.
My algorithm should be something like
- for each YouTube link
- find the video id
- use the video id to make a YouTube thumbnail URL
- insert YouTube thumbnail URL into the link's
<a>
it looks like the regular expression functions in ruby want to do everything in one line, so I am not clear on how to approach a multi-step find and replace.
I would appreciate some direction.