diff --git a/src/lib/components/LazyCategory.svelte b/src/lib/components/LazyCategory.svelte new file mode 100644 index 0000000..507ce77 --- /dev/null +++ b/src/lib/components/LazyCategory.svelte @@ -0,0 +1,65 @@ + + +{#if isVisible} + +
+ {@render children()} +
+{:else} + +
+ +
+{/if} diff --git a/src/routes/[recipeLang=recipeLang]/+page.svelte b/src/routes/[recipeLang=recipeLang]/+page.svelte index 182886d..b907155 100644 --- a/src/routes/[recipeLang=recipeLang]/+page.svelte +++ b/src/routes/[recipeLang=recipeLang]/+page.svelte @@ -4,6 +4,7 @@ import AddButton from '$lib/components/AddButton.svelte'; import Card from '$lib/components/Card.svelte'; import Search from '$lib/components/Search.svelte'; + import LazyCategory from '$lib/components/LazyCategory.svelte'; let { data }: { data: PageData } = $props(); let current_month = new Date().getMonth() + 1; @@ -68,25 +69,38 @@ h1{ !hasActiveSearch || matchedRecipeIds.has(recipe._id) )} {#if seasonRecipes.length > 0} - - {#each seasonRecipes as recipe} - - {/each} - + + {#snippet children()} + + {#each seasonRecipes as recipe} + + {/each} + + {/snippet} + {/if} {/if} -{#each categories as category} +{#each categories as category, index} {@const categoryRecipes = data.all_brief.filter(recipe => recipe.category === category && (!hasActiveSearch || matchedRecipeIds.has(recipe._id)) )} {#if categoryRecipes.length > 0} - - {#each categoryRecipes as recipe} - - {/each} - + + {#snippet children()} + + {#each categoryRecipes as recipe} + + {/each} + + {/snippet} + {/if} {/each} {#if !isEnglish}