Process filename on render? #509
-
Hi Lume, Thank you for beautiful software. Really liking it so far. So, I'm looking for a way to adjust filenames on render. I'd like to programmatically include a version number, ideally from my site's To explain, I am using a somewhat strange piece of software that allows me to host individual static assets, but they're not versioned. I'd like to know at a glance whether the assets I've uploaded are up to date. Hence the manual versioning. Any suggestion how this might be accomplished? For example, something like this might work (but doesn't because it's meant for extensions): site.preprocess(
["*mah_folder_name*"],
(page) => page.data.filename = page.src.path + "v1.2.3" + page.src.ext,
); No worries if not, I'll write my own external postprocessor. But it would be cool to manage it all in one place. Thanks. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
To include the version in the url, you can use the // my-files/_data.js
const version = "v1.2.3";
export function url(page) {
return `./${page.src.slug}${version}${page.src.ext}`
} |
Beta Was this translation helpful? Give feedback.
-
Whoa, that's perfect. Simpler than expected by far. Thank you! |
Beta Was this translation helpful? Give feedback.
To include the version in the url, you can use the
url
function. For example, create_data.js
file in the folder containing the files do you want to rewrite: