(req: any)
| 51 | } |
| 52 | |
| 53 | export 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 | } |
no outgoing calls
no test coverage detected