layout.tsx 588 B

12345678910111213141516171819
  1. import Layout from '@/app/component/Layout';
  2. import { fetchJson } from '@/lib/utils/server';
  3. import { ChannelListResponse } from '@/types/response/channel/list';
  4. import { ChannelListItem } from '@/types/channel';
  5. export default async function MainLayout({ children }: { children: React.ReactNode }) {
  6. const res = await fetchJson<ChannelListResponse>('/api/channel/list');
  7. const initialChannels: ChannelListItem[] = (res.data?.channels ?? []).map((ch, idx) => ({
  8. ...ch,
  9. _offlineRank: idx
  10. }));
  11. return (
  12. <Layout initialChannels={initialChannels}>
  13. {children}
  14. </Layout>
  15. );
  16. }