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

Function topicGetServerSideProps

apps/web/services/ssr/topics.ts:18–123  ·  view source on GitHub ↗
(
  context: GetServerSidePropsContext,
  isSubdomainbasedRouting: boolean
)

Source from the content-addressed store, hash-verified

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

Callers 2

topics.test.tsFile · 0.90

Calls 13

ssrFunction · 0.90
RedirectToFunction · 0.90
NotFoundFunction · 0.90
shouldRedirectToDomainFunction · 0.90
redirectChannelToDomainFunction · 0.90
resolveCrawlerRedirectFunction · 0.90
findTopicsFunction · 0.90
findPinnedThreadsFunction · 0.90
decodeCursorFunction · 0.90
buildCursorFunction · 0.90
mapMethod · 0.80

Tested by

no test coverage detected