layout.tsx 780 B

123456789101112131415161718192021222324
  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. import { FEATURE_CHANNEL } from '@/constants/features';
  6. export default async function MainLayout({ children }: { children: React.ReactNode }) {
  7. // 채널 기능 OFF: 사이드바 미노출이므로 채널 목록 조회 생략
  8. let initialChannels: ChannelListItem[] = [];
  9. if (FEATURE_CHANNEL) {
  10. const res = await fetchJson<ChannelListResponse>('/api/channel/list');
  11. initialChannels = (res.data?.channels ?? []).map((ch, idx) => ({
  12. ...ch,
  13. _offlineRank: idx
  14. }));
  15. }
  16. return (
  17. <Layout initialChannels={initialChannels}>
  18. {children}
  19. </Layout>
  20. );
  21. }