(context)
| 31 | } |
| 32 | |
| 33 | export const getServerSideProps: GetServerSideProps<Props> = async (context) => { |
| 34 | const req = context.req as any |
| 35 | const res = context.res as any |
| 36 | const schema = getGraphqlChangelog() as ChangelogItemT[] |
| 37 | if (!schema) throw new Error('No graphql free-pro-team changelog schema found.') |
| 38 | // Gets the miniTocItems in the article context. At this point it will only |
| 39 | // include miniTocItems that exist in Markdown pages in |
| 40 | // content/graphql/reference/* |
| 41 | const automatedPageContext = getAutomatedPageContextFromRequest(req) |
| 42 | const titles = schema.map((item) => `Schema changes for ${item.date}`) |
| 43 | const changelogMiniTocItems = await getAutomatedPageMiniTocItems(titles, req.context.context, 2) |
| 44 | // Update the existing context to include the miniTocItems from GraphQL |
| 45 | automatedPageContext.miniTocItems.push(...changelogMiniTocItems) |
| 46 | |
| 47 | // All groups in the schema have a change.changes array of strings that are |
| 48 | // all the HTML output from a Markdown conversion. E.g. |
| 49 | // `<p>Field filename was added to object type <code>IssueTemplate</code></p>` |
| 50 | // Change these to just be the inside of the <p> tag. |
| 51 | // `Field filename was added to object type <code>IssueTemplate</code>` |
| 52 | // This makes the serialized state data smaller and it makes it possible |
| 53 | // to render it as... |
| 54 | // |
| 55 | // <li>Field filename was added to object type <code>IssueTemplate</code></li> |
| 56 | // |
| 57 | // ...without the additional <p>. |
| 58 | schema.forEach((item) => { |
| 59 | for (const group of [item.schemaChanges, item.previewChanges, item.upcomingChanges]) { |
| 60 | group.forEach((change) => { |
| 61 | change.changes = change.changes.map((html) => { |
| 62 | if (html.startsWith('<p>') && html.endsWith('</p>')) return html.slice(3, -4) |
| 63 | return html |
| 64 | }) |
| 65 | }) |
| 66 | } |
| 67 | }) |
| 68 | |
| 69 | return { |
| 70 | props: { |
| 71 | mainContext: await getMainContext(req, res), |
| 72 | automatedPageContext, |
| 73 | schema, |
| 74 | }, |
| 75 | } |
| 76 | } |
nothing calls this directly
no test coverage detected