How to link assets from Sage 9 controller class

i try this, but asset_path is not valid
is there some elegant way without using ugly wordpress core functions?

class Single extends Controller
{
  /**
   * Return next post link
   *
   * @return string
   */
  public static function nextPostLink()
  {
    $arrow = asset_path('images/arrow.svg');
    $img = "<img class='arrow--left' src='$arrow'>";

    return next_post_link('%link', $img);
  }
}

You’re forgetting the namespace.

\App\asset_path()

3 Likes

Cool, that worked. It’s hard to find that in the docs, though…

Btw, I love what you’re doing with Sage, Bedrock and Trellis
Recently found out how easily you can flip logic from views to controller - that’s awesome
Great job guys at Roots!

Thanks! Was looking for this.

This don`t work with yarn start