Compare commits

..

3 Commits

Author SHA1 Message Date
Tom Alexander
39d838a284 Mark webp and avif files as images.
Some checks failed
rust-test Build rust-test has failed
clippy Build clippy has failed
format Build format has succeeded
build Build build has succeeded
2026-11-01 14:05:13 -05:00
Tom Alexander
1c369e4b25 Merge branch 'fix_nix_build_image_paths'
Some checks failed
clippy Build clippy has failed
format Build format has succeeded
rust-test Build rust-test has failed
build Build build has succeeded
2026-10-21 17:17:58 -04:00
Tom Alexander
694052d33d Images were broken, returning paths to the nix build directory.
Some checks failed
format Build format has succeeded
clippy Build clippy has failed
rust-test Build rust-test has succeeded
2026-10-21 17:16:57 -04:00
3 changed files with 13 additions and 2 deletions

View File

@@ -1,3 +1,4 @@
use std::path::NormalizeError;
use std::str::Utf8Error;
use std::string::FromUtf8Error;
@@ -16,6 +17,7 @@ pub(crate) enum CustomError {
DusterRender(#[allow(dead_code)] duster::renderer::RenderError),
PathStripPrefix(#[allow(dead_code)] std::path::StripPrefixError),
UrlParseError(#[allow(dead_code)] url::ParseError),
NormalizeError(#[allow(dead_code)] NormalizeError),
}
impl From<std::io::Error> for CustomError {
@@ -95,3 +97,9 @@ impl From<url::ParseError> for CustomError {
CustomError::UrlParseError(value)
}
}
impl From<NormalizeError> for CustomError {
fn from(value: NormalizeError) -> Self {
CustomError::NormalizeError(value)
}
}

View File

@@ -74,7 +74,9 @@ impl LinkTarget {
// If link type is file and the path ends in .svg then make it an image target
if let LinkType::File = link_type
&& (input.to_ascii_lowercase().ends_with(".svg")
|| input.to_ascii_lowercase().ends_with(".png"))
|| input.to_ascii_lowercase().ends_with(".png")
|| input.to_ascii_lowercase().ends_with(".avif")
|| input.to_ascii_lowercase().ends_with(".webp"))
{
let src = Self::get_image_src(&input)?;
let alt = Self::get_image_alt(&input)?;
@@ -151,7 +153,7 @@ impl LinkTarget {
.unwrap()
.get_current_folder()?
.join(src)
.canonicalize()?;
.normalize_lexically()?;
let input_root_directory = render_context.config.get_root_directory();
let relative_path_to_file = path_to_file.strip_prefix(input_root_directory)?;
let web_path = get_web_path(

View File

@@ -1,3 +1,4 @@
#![feature(normalize_lexically)]
use std::process::ExitCode;
use clap::Parser;