Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/server/templates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub struct RecipesTemplate {
pub breadcrumbs: Vec<Breadcrumb>,
pub items: Vec<RecipeItem>,
pub todays_menu: Option<TodaysMenu>,
pub new_recipe_url: String,
pub tr: Tr,
pub prefix: String,
}
Expand Down
10 changes: 10 additions & 0 deletions src/server/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,22 @@ async fn recipes_handler(
crate::server::i18n::LOCALES.lookup(&lang, "recipes-title")
};

let new_recipe_url = match &path {
Some(p) => format!(
"{}/new?filename={}%2F",
state.url_prefix,
urlencoding::encode(p)
),
None => format!("{}/new", state.url_prefix),
};

let template = RecipesTemplate {
active: "recipes".to_string(),
current_name,
breadcrumbs,
items,
todays_menu,
new_recipe_url,
tr: Tr::new(lang),
prefix: state.url_prefix.clone(),
};
Expand Down
2 changes: 1 addition & 1 deletion templates/recipes.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<h1 class="text-3xl font-bold bg-gradient-to-r from-orange-600 to-yellow-600 bg-clip-text text-transparent">
{{ current_name }}
</h1>
<a href="{{ prefix }}/new" class="px-4 py-2 bg-gradient-to-r from-orange-500 to-red-500 text-white rounded-lg hover:from-orange-600 hover:to-red-600 transition-all shadow-md flex items-center gap-2">
<a href="{{ new_recipe_url }}" class="px-4 py-2 bg-gradient-to-r from-orange-500 to-red-500 text-white rounded-lg hover:from-orange-600 hover:to-red-600 transition-all shadow-md flex items-center gap-2">
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
</svg>
Expand Down
Loading