-
Notifications
You must be signed in to change notification settings - Fork 930
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
Fix cachebust for files in the output path #1586
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should always pass the output_dir so we remove the Option
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a test? It could be added in one of the existing ones
Sure thing. Where should I add it exactly? Do I add a test to I was thinking a test like this: #[test]
fn can_link_to_file_in_output_path() {
let dir = create_temp_dir();
let public = dir.path().join("public");
create_dir(&public).expect("Failed to create output directory");
create_file(&public.join("style.css"), "// Hello world")
.expect("Failed to create file in output directory");
let static_fn = GetUrl::new(dir.path().to_path_buf(), Config::default(), HashMap::new(), public);
let mut args = HashMap::new();
args.insert("path".to_string(), to_value("style.css").unwrap());
assert_eq!(static_fn.call(&args).unwrap(), "http://a-website.com/style.css");
} Sorry for all the questions 😅 |
Just one is fine, the test you wrote seems ok |
Thanks, done. |
The search_for_file helper function now accepts an optional output path. If passed, the file will also be searched there. This is used in the get_url function to search in the Site::output_path. In practice, this means cachebust works for files in the output path.
Thanks! |
The
search_for_file
helper function now accepts anoptionaloutput path. If passed, the file will also be searched there.This is used in the
get_url
Tera function to search in theSite::output_path
.In practice, this means cachebust works again for files in the output path.
I've tested this with one of my sites and it seems to work perfectly.
This should fix the main issue of #1570. That issue's thread also discusses other things related to getting urls of files in the output path though, so you might want to keep it open.
IMPORTANT: Please do not create a Pull Request adding a new feature without discussing it first.
The place to discuss new features is the forum: https://zola.discourse.group/
If you want to add a new feature, please open a thread there first in the feature requests section.
Sanity check:
Code changes
(Delete or ignore this section for documentation changes)
next
branch?If the change is a new feature or adding to/changing an existing one: