tighten / jigsaw

Simple static sites with Laravel’s Blade.
https://jigsaw.tighten.com
MIT License
2.13k stars 182 forks source link

Adding Elixir functionality to markdown files #168

Closed dgursh closed 6 years ago

dgursh commented 6 years ago

My jigsaw site heavily uses images and the following markdown syntax

![Image](../../../img/ex-image.png)

I need a way to version my images and reference them in the markdown files like so:

![Image]({{ elixir('img/ex-image.png') }})

But this is failing since the markdown parser has no idea what this means. How would I implement this feature? Again my goal is to use gulp and elixir to version my images because I have thousands of them and need a way to cache bust.

Thanks!

dgursh commented 6 years ago

Solved. In case anyone ever runs into this issue in the future, I had to dive into the src and use a function named elixir in helpers.php in the support folder. I extended Parsedown like so

class Extension extends Parsedown
{

    protected function inlineImage($excerpt)
    {
        $image = parent::inlineImage($excerpt);

        $image['element']['attributes']['src'] = elixir($Link['element']['attributes']['href']);

        return $image;
    }

}