zola icon indicating copy to clipboard operation
zola copied to clipboard

`get_url` inside SASS/CSS

Open antonok-edm opened this issue 2 years ago • 0 comments

I realize this could be technically challenging to implement, but it'd be great to have a way to call get_url (or some other similar URL-processing step) from inside SASS/CSS files. The primary use-case I have in mind is as follows:

  • style.sass references font or image resources required for the page in a url(...)
  • cachebust=true is passed to get_url, since the server uses aggressive caching headers and the fonts or images could be modified in the future
  • there is a link rel="preload" element in the HTML pointing to the font or image resources, such that these resources can start being fetched without waiting for style.css to arrive first

In this scenario, the preload URL and the one in the CSS must match exactly including query arguments, or else the resource will be fetched twice and the preloaded resource will be unused.

Right now, get_url already works very well in the preload link, but all of the query arguments have to be appended manually to URLs in stylesheets.

antonok-edm avatar Jan 12 '22 23:01 antonok-edm