From 86f81ccc35ddb47ea59ad0012b3807914021052b Mon Sep 17 00:00:00 2001 From: ElnuDev Date: Sat, 1 Jul 2023 12:40:13 -0700 Subject: [PATCH] Properly handle songs with only English title --- src/utils/furigana.rs | 3 +++ templates/index.html.tera | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/furigana.rs b/src/utils/furigana.rs index 1bc4bec..749ca08 100644 --- a/src/utils/furigana.rs +++ b/src/utils/furigana.rs @@ -16,6 +16,9 @@ pub fn furigana_to_html(text: &str) -> String { } pub fn furigana_filter(value: &Value, _args: &HashMap) -> tera::Result { + if value.is_null() { + return Ok(Value::String("".to_string())); + } Ok(Value::String(furigana_to_html(value.as_str().expect("The furigana input must be a string")))) } diff --git a/templates/index.html.tera b/templates/index.html.tera index 790e832..e620d99 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -19,7 +19,7 @@ {% if content.song %}
- {{ content.song.japanese }} + {% if content.song.japanese %}{{ content.song.japanese | furigana | safe }}{% else %}{{ content.song.english }}{% endif %}
{% endif %} {% if user %}