-
-
Notifications
You must be signed in to change notification settings - Fork 103
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Slugification for copied files #447
Comments
Hi. site.use(slugifyUrls({
staticFiles: true,
}); For now, as a workaround, you can use the site.addEventListener("beforeRender", () => {
const files = site.files; // the files to be copied statically
// Change the outputPath property
files.forEach((file) => {
file.outputPath = slugify(file.outputPath);
});
}); |
Thanks for the quick reply!
Seems sensible - in principle, I think it would even make sense to have this option activated by default ... but that would be a breaking change. Thank you for the workaround, that makes things easier for me in the meantime! |
I just made some changes in Lume to slugify static files. If you want to slugify some files copied statically, for example site.use(slugifyUrls({
extensions: [".html", ".pdf"]
}); To slugify all files, use site.use(slugifyUrls({
extensions: "*"
}); This change will be available in Lume v1.18.2. It's not released yet, but you can test it by upgrading Lume to the latest development version with |
Works like a charm! Thank you for making this happen so quickly! A suggestion/question: Wouldn't it make sense to change the default to |
Yes, good idea. I'll change it to |
Enter your suggestions in details:
Thank you for creating lume, I love it so far!
One thing that would be great would be a way to slugify also the names of
copy()
ed files. Because right now, the interaction of copying and slugification seems kind of bad.Unless I am missing something (which might well be!), right now, the behavior is the following (assuming the slugify plugin is loaded):
.src
directory contains a pathwith spaces and Capitals/
, which contains:with spaces and Capitals/more spaces and Capitals.bin
(withsite.copy(['.bin']
)with spaces and Capitals/With Spaces.md
_site
:with spaces and Capitals
, which containsmore spaces and Capitals.bin
with-spaces-and-capitals
, which containswith-spaces.html
with-spaces-and-capitals
, which containsmore-spaces-and-capitals.bin
andwith-spaces.html
copy()
ed files via the second argument tocopy()
, but such a solution would be cumbersome and somewhat brittle (e.g., suppose the slugify options change).I guess one of the reasons for the current behavior is that
copy()
ed files are not processed at all, hence the slugify plugin has no chance to intervene.Maybe it would be an option to provide (in the slugify plugin?) a
copyAndSlugify()
method?Or is my "ideally" above already possible, I just missed how?
If not, I'd be willing to work on a pull request for this.
The text was updated successfully, but these errors were encountered: