Sign in

File paths in helpers.js

  • This topic has 2 replies, 2 voices, and was last updated 6 months ago by .
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #7471
    Avatar photoMike

    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 photoMike

    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 photoTomasz Dziuda

    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.

    --
    Do you appreciate the support you've received today? If so, consider donating to the Publii team by clicking here; we'll be sure to use your donation to make Publii even better!

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.