-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The html-tag for loading bootstrap-icons is now generated and always contains the correct path.
- Loading branch information
Showing
3 changed files
with
38 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
use std::path::PathBuf; | ||
use yew_bootstrap::icons::BIFiles; | ||
|
||
fn main() -> Result<(), std::io::Error> { | ||
for l in 0..5 { | ||
let mut path_base = PathBuf::from( | ||
std::env::var("TRUNK_SOURCE_DIR").expect("Environment variable TRUNK_SOURCE_DIR"), | ||
); | ||
for _ in 0..l { | ||
path_base = path_base.join(".."); | ||
} | ||
let path_target = path_base.join("target"); | ||
|
||
if !path_target.is_dir() || !path_base.join("Cargo.lock").is_file() { | ||
continue; | ||
} | ||
|
||
let path_generated = path_target.join("generated"); | ||
if !path_generated.is_dir() { | ||
std::fs::create_dir(&path_generated)?; | ||
} | ||
let contents = format!( | ||
"<link rel=\"stylesheet\" href=\"bootstrap-icons-{}/bootstrap-icons.css\" />", | ||
BIFiles::VERSION | ||
); | ||
std::fs::write(path_generated.join("link-bootstrap-icons.html"), contents)?; | ||
|
||
return Ok(()); | ||
} | ||
panic!("Couldn't find the target directory"); | ||
} |