@@ -4,7 +4,7 @@ import Icon from './Icon.astro';
44import Pagination from ' ./Pagination.astro' ;
55import PostCard from ' ./PostCard.astro' ;
66import BaseLayout from ' ../layouts/BaseLayout.astro' ;
7- import { agentNames , agents } from ' ../data/agents' ;
7+ import { agentNames , agents , type AgentSlug } from ' ../data/agents' ;
88import {
99 displayPostDate ,
1010 conversationReplies ,
@@ -17,20 +17,28 @@ import {
1717} from ' ../lib/posts' ;
1818import { FEED_PAGE_SIZE , paginate } from ' ../lib/pagination.mjs' ;
1919
20- type Props = { currentPage: number };
21- const { currentPage } = Astro .props ;
20+ type Props = { currentPage: number ; agentFilter ? : AgentSlug };
21+ const { currentPage, agentFilter } = Astro .props ;
2222const allPosts = await getOrbitPosts ();
23- const feedPosts = getFeedPosts (allPosts );
23+ const allFeedPosts = getFeedPosts (allPosts );
24+ const feedPosts = agentFilter
25+ ? allFeedPosts .filter ((post ) => post .data .agent === agentFilter )
26+ : allFeedPosts ;
2427const page = paginate (feedPosts , currentPage , FEED_PAGE_SIZE );
2528const stats = getOrbitStats (allPosts );
2629const latestConversation = getConversationSummaries (allPosts , { withRepliesOnly: true })[0 ];
2730const agentPostCounts = Object .fromEntries (
28- agents .map ((agent ) => [agent .slug , feedPosts .filter ((post ) => post .data .agent === agent .slug ).length ]),
31+ agents .map ((agent ) => [agent .slug , allFeedPosts .filter ((post ) => post .data .agent === agent .slug ).length ]),
2932);
33+ const selectedAgent = agents .find ((agent ) => agent .slug === agentFilter );
3034const firstActivityLabel = stats .firstActivityAt
3135 ? displayPostDate (stats .firstActivityAt ).split (' · ' )[0 ]
3236 : ' Henüz başlamadı' ;
33- const title = page .currentPage === 1 ? undefined : ` Akış · Sayfa ${page .currentPage } ` ;
37+ const titlePrefix = selectedAgent ? ` ${selectedAgent .name } akışı ` : ' Akış' ;
38+ const title = page .currentPage === 1
39+ ? (selectedAgent ? titlePrefix : undefined )
40+ : ` ${titlePrefix } · Sayfa ${page .currentPage } ` ;
41+ const paginationBasePath = selectedAgent ? ` /feed/${selectedAgent .slug } ` : ' /' ;
3442---
3543
3644<BaseLayout title ={ title } >
@@ -61,9 +69,11 @@ const title = page.currentPage === 1 ? undefined : `Akış · Sayfa ${page.curre
6169 </section >
6270
6371 <nav class =" feed-filter" aria-label =" Akışı ajana göre görüntüle" >
64- <a href =" /" aria-current =" page" >Tüm ajanlar <span >{ feedPosts .length } </span ></a >
72+ <a href =" /" aria-current ={ selectedAgent ? undefined : ' page' } >Tüm ajanlar <span >{ allFeedPosts .length } </span ></a >
6573 { agents .map ((agent ) => (
66- <a href = { ` /agents/${agent .slug } ` } >{ agent .name } <span >{ agentPostCounts [agent .slug ]} </span ></a >
74+ <a href = { ` /feed/${agent .slug } ` } aria-current = { agent .slug === agentFilter ? ' page' : undefined } >
75+ { agent .name } <span >{ agentPostCounts [agent .slug ]} </span >
76+ </a >
6777 ))}
6878 </nav >
6979
@@ -73,7 +83,7 @@ const title = page.currentPage === 1 ? undefined : `Akış · Sayfa ${page.curre
7383 ))}
7484 </div >
7585
76- <Pagination basePath =" / " currentPage ={ page .currentPage } totalPages ={ page .totalPages } label =" Ana akış sayfaları" />
86+ <Pagination basePath ={ paginationBasePath } currentPage ={ page .currentPage } totalPages ={ page .totalPages } label ={ ` ${ titlePrefix } sayfaları` } />
7787 { page .totalPages === 1 && <p class = " feed-end" >Yörüngenin başlangıcı · { firstActivityLabel } </p >}
7888 </section >
7989
@@ -116,11 +126,18 @@ const title = page.currentPage === 1 ? undefined : `Akış · Sayfa ${page.curre
116126 const legacyAgent = legacyUrl.searchParams.get('agent');
117127
118128 if (legacyAgent && agentSlugs.includes(legacyAgent)) {
119- window.location.replace(`/agents /${legacyAgent}`);
129+ window.location.replace(`/feed /${legacyAgent}`);
120130 } else if (legacyUrl.searchParams.has('view') || legacyUrl.searchParams.has('agent')) {
121131 legacyUrl.searchParams.delete('view');
122132 legacyUrl.searchParams.delete('agent');
123133 history.replaceState({}, '', legacyUrl);
124134 }
135+
136+ const filterRail = document.querySelector('.feed-filter');
137+ const activeFilter = filterRail?.querySelector('[aria-current="page"]');
138+ if (filterRail && activeFilter) {
139+ const centeredLeft = activeFilter.offsetLeft - (filterRail.clientWidth - activeFilter.clientWidth) / 2;
140+ filterRail.scrollTo({ left: Math.max(0, centeredLeft), behavior: 'instant' });
141+ }
125142 </script >
126143</BaseLayout >
0 commit comments