MCPcopy
hub / github.com/github/docs / getServerSideProps

Function getServerSideProps

pages/[versionId]/graphql/overview/breaking-changes.tsx:38–61  ·  view source on GitHub ↗
(context)

Source from the content-addressed store, hash-verified

36}
37
38export const getServerSideProps: GetServerSideProps<Props> = async (context) => {
39 const req = context.req as any
40 const res = context.res as any
41 const currentVersion = context.query.versionId as string
42 const schema = getGraphqlBreakingChanges(currentVersion)
43 if (!schema) throw new Error(`No graphql breaking changes schema found for ${currentVersion}`)
44
45 // Gets the miniTocItems in the article context. At this point it will only
46 // include miniTocItems that exist in Markdown pages in
47 // content/graphql/reference/*
48 const automatedPageContext = getAutomatedPageContextFromRequest(req)
49 const titles = Object.keys(schema).map((item) => `Changes scheduled for ${item}`)
50 const changelogMiniTocItems = await getAutomatedPageMiniTocItems(titles, req.context.context, 2)
51 // Update the existing context to include the miniTocItems from GraphQL
52 automatedPageContext.miniTocItems.push(...changelogMiniTocItems)
53
54 return {
55 props: {
56 mainContext: await getMainContext(req, res),
57 automatedPageContext,
58 schema,
59 },
60 }
61}

Callers

nothing calls this directly

Calls 4

getMainContextFunction · 0.90

Tested by

no test coverage detected