MCPcopy Create free account
hub / github.com/github/docs / getArticleContextFromRequest

Function getArticleContextFromRequest

components/context/ArticleContext.tsx:53–82  ·  view source on GitHub ↗
(req: any)

Source from the content-addressed store, hash-verified

51}
52
53export const getArticleContextFromRequest = (req: any): ArticleContextT => {
54 const page = req.context.page
55
56 if (page.effectiveDate) {
57 if (isNaN(Date.parse(page.effectiveDate))) {
58 throw new Error(
59 'The "effectiveDate" frontmatter property is not valid. Please make sure it is YEAR-MONTH-DAY'
60 )
61 }
62 }
63
64 return {
65 title: page.title,
66 intro: page.intro,
67 effectiveDate: page.effectiveDate || '',
68 renderedPage: req.context.renderedPage || '',
69 miniTocItems: req.context.miniTocItems || [],
70 permissions: page.permissions || '',
71 includesPlatformSpecificContent: page.includesPlatformSpecificContent || false,
72 includesToolSpecificContent: page.includesToolSpecificContent || false,
73 defaultPlatform: page.defaultPlatform || '',
74 defaultTool: page.defaultTool || '',
75 product: page.product || '',
76 productVideoUrl: page.product_video || '',
77 currentLearningTrack: req.context.currentLearningTrack,
78 detectedPlatforms: page.detectedPlatforms || [],
79 detectedTools: page.detectedTools || [],
80 allTools: page.allToolsParsed || [], // this is set at the page level, see lib/page.js
81 }
82}

Callers 1

getServerSidePropsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected