Download
We're evolving to serve you better! This current forum has transitioned to read-only mode. For new discussions, support, and engagement, we've moved to GitHub Discussions.

File paths in helpers.js

  • #7471
    Avatar photo[anonymous]

    Hello,

    I am trying to write a custom helper that would work with local files. What is the preferred way to reconstruct a file path from a passed URL? url.fileURLToPath() does the job when the file URI scheme is used, but I need a universal solution. (I see that the {{imageDimensions}} helper solves this issue by referencing rendererInstance.siteConfig.domain and rendererInstance.inputDir, but it doesn’t seem to be possible for custom helpers.)

    Mike

    #7516
    Avatar photo[anonymous]

    It turns out that the last argument passed to a helper contains the base URL under data.website.baseUrl.

    I still don’t know how to get at the input directory without using __dirname.

    Mike

    #7550
    Avatar photo[anonymous]

    Hi,

    Unfortunately helpers.js has no access to such data. Through the last argument you will get only access to data available for handlebars, not the renderer config.