MCPcopy Index your code
hub / github.com/Linen-dev/linen.dev / channelGetServerSideProps

Function channelGetServerSideProps

apps/web/services/ssr/channels.ts:23–127  ·  view source on GitHub ↗
(
  context: GetServerSidePropsContext,
  isSubdomainbasedRouting: boolean
)

Source from the content-addressed store, hash-verified

21import { topicGetServerSideProps } from 'services/ssr/topics';
22
23export async function channelGetServerSideProps(
24 context: GetServerSidePropsContext,
25 isSubdomainbasedRouting: boolean
26) {
27 const isCrawler = isBot(context?.req?.headers?.['user-agent'] || '');
28
29 const { props, notFound, ...rest } = await ssr(
30 context,
31 allowAccess,
32 isCrawler
33 );
34
35 if (rest.redirect) {
36 return RedirectTo(rest.location);
37 }
38
39 if (notFound || !props) {
40 return NotFound();
41 }
42
43 const { channels, currentCommunity, settings, dms, publicChannels } = props;
44
45 const communityName = context.params?.communityName as string;
46 const channelName = context.params?.channelName as string;
47 const page = context.params?.page as string | undefined;
48
49 const channel = findChannelOrGetLandingChannel(
50 [...channels, ...dms, ...publicChannels],
51 channelName
52 );
53 if (!channel) return NotFound();
54
55 if (channel.viewType === 'TOPIC') {
56 return topicGetServerSideProps(context, isSubdomainbasedRouting);
57 }
58
59 if (
60 shouldRedirectToDomain({
61 account: currentCommunity,
62 communityName,
63 isSubdomainbasedRouting,
64 })
65 ) {
66 return redirectChannelToDomain({
67 account: currentCommunity,
68 communityName,
69 settings,
70 channelName,
71 channel,
72 });
73 }
74
75 if (isCrawler) {
76 if (!channelName) {
77 // should be redirect to default_channel
78 return resolveCrawlerRedirect({
79 isSubdomainbasedRouting,
80 communityName,

Callers 7

getServerSidePropsFunction · 0.90
getServerSidePropsFunction · 0.90
getServerSidePropsFunction · 0.90
getServerSidePropsFunction · 0.90
getServerSidePropsFunction · 0.90
getServerSidePropsFunction · 0.90
channels.test.tsFile · 0.90

Calls 13

ssrFunction · 0.90
RedirectToFunction · 0.90
NotFoundFunction · 0.90
topicGetServerSidePropsFunction · 0.90
shouldRedirectToDomainFunction · 0.90
redirectChannelToDomainFunction · 0.90
resolveCrawlerRedirectFunction · 0.90
findPinnedThreadsFunction · 0.90
isPageNotValidFunction · 0.85
mapMethod · 0.80
getThreadsFunction · 0.70

Tested by

no test coverage detected