JavaScript-optional public web frontend for Bluesky anartia.kelinci.net
sveltekit atcute bluesky typescript svelte

refactor: deduplicate associated render

mary.my.id 9d6f1940 4e751dad

verified
Changed files
+10 -12
src
routes
(app)
(profile)
[actor=didOrHandle]
+10 -12
src/routes/(app)/(profile)/[actor=didOrHandle]/+layout.svelte
··· 50 50 {#if profile.associated?.feedgens} 51 51 {@const count = profile.associated.feedgens} 52 52 53 - <a class="association" href="{base}/{did}/feeds"> 54 - <span class="association-count">{formatCompactNumber(count)}</span> 55 - {count === 1 ? `feed` : `feeds`} 56 - </a> 53 + {@render Associated(`${base}/${did}/feeds`, count, `feed`, `feeds`)} 57 54 {/if} 58 55 {#if profile.associated?.lists} 59 56 {@const count = profile.associated.lists} 60 57 61 - <a class="association" href="{base}/{did}/lists"> 62 - <span class="association-count">{formatCompactNumber(count)}</span> 63 - {count === 1 ? `list` : `lists`} 64 - </a> 58 + {@render Associated(`${base}/${did}/lists`, count, `list`, `lists`)} 65 59 {/if} 66 60 {#if profile.associated?.starterPacks} 67 61 {@const count = profile.associated.starterPacks} 68 62 69 - <a class="association" href="{base}/{did}/packs"> 70 - <span class="association-count">{formatCompactNumber(count)}</span> 71 - {count === 1 ? `starter pack` : `starter packs`} 72 - </a> 63 + {@render Associated(`${base}/${did}/packs`, count, `starter pack`, `starter packs`)} 73 64 {/if} 74 65 </div> 75 66 </div> ··· 79 70 </div> 80 71 </div> 81 72 {/key} 73 + 74 + {#snippet Associated(href: string, count: number, one: string, many: string)} 75 + <a class="association" {href}> 76 + <span class="association-count">{formatCompactNumber(count)}</span> 77 + {count === 1 ? one : many} 78 + </a> 79 + {/snippet} 82 80 83 81 <style> 84 82 .profile-layout {