Compare commits
3 Commits
cf28b65d16
...
aa6da0069b
Author | SHA1 | Date |
---|---|---|
Bauke | aa6da0069b | |
Bauke | 4f206aa95e | |
Bauke | ce8be9e120 |
|
@ -26,9 +26,10 @@
|
|||
{% if let Some(mods) = speedrun.mods %}
|
||||
<h2>Mods</h2>
|
||||
<ul>
|
||||
{% for (name, id) in mods %}
|
||||
{% for id in mods %}
|
||||
{% let (mod_link, mod_title) = id|drg_mod %}
|
||||
<li>
|
||||
<a href="https://drg.mod.io/{{ id }}" target="_blank">{{ name }}</a>
|
||||
<a href="{{ mod_link }}" target="_blank">{{ mod_title }}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
|
|
@ -2,6 +2,19 @@
|
|||
Filters for Askama templates.
|
||||
*/
|
||||
|
||||
/**
|
||||
Get the DRG mod link and title from a given ID.
|
||||
*/
|
||||
pub fn drg_mod(mod_id: &str) -> askama::Result<(String, &str)> {
|
||||
let mods = std::collections::HashMap::<_, _>::from_iter([
|
||||
("drglib", "DRGLib"),
|
||||
("simplemissiontimer", "SimpleMissionTimer"),
|
||||
]);
|
||||
|
||||
let mod_title = mods.get(mod_id).unwrap();
|
||||
Ok((format!("https://drg.mod.io/{mod_id}"), mod_title))
|
||||
}
|
||||
|
||||
/**
|
||||
Turn a timestamp with format `mm:ss` into its total seconds.
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ pub struct SpeedrunData {
|
|||
pub chapters: Option<Vec<(String, String)>>,
|
||||
pub entry: String,
|
||||
pub leaderboard: String,
|
||||
pub mods: Option<Vec<(String, String)>>,
|
||||
pub mods: Option<Vec<String>>,
|
||||
}
|
||||
|
||||
pub fn write_all(public_dir: &Path) -> Result<()> {
|
||||
|
@ -39,9 +39,15 @@ pub fn write_all(public_dir: &Path) -> Result<()> {
|
|||
continue;
|
||||
}
|
||||
|
||||
let file_contents = fs::read_to_string(file_path)?;
|
||||
let file_contents = fs::read_to_string(&file_path)?;
|
||||
let (video_data, markdown) =
|
||||
toml_frontmatter::parse::<VideoData>(&file_contents).unwrap();
|
||||
match toml_frontmatter::parse::<VideoData>(&file_contents) {
|
||||
Ok(parsed) => parsed,
|
||||
Err(error) => {
|
||||
println!("{:?} {}", file_path.file_name().unwrap(), error);
|
||||
continue;
|
||||
}
|
||||
};
|
||||
data.push((video_data, markdown.to_string()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue