(req: any, res: any)
| 113 | } |
| 114 | |
| 115 | export const getMainContext = async (req: any, res: any): Promise<MainContextT> => { |
| 116 | // Our current translation process adds 'ms.*' frontmatter properties to files |
| 117 | // it translates including when data/ui.yml is translated. We don't use these |
| 118 | // properties and their syntax (e.g. 'ms.openlocfilehash', |
| 119 | // 'ms.sourcegitcommit', etc.) causes problems so just delete them. |
| 120 | if (req.context.site.data.ui.ms) { |
| 121 | delete req.context.site.data.ui.ms |
| 122 | } |
| 123 | |
| 124 | return { |
| 125 | breadcrumbs: req.context.breadcrumbs || {}, |
| 126 | activeProducts: req.context.activeProducts, |
| 127 | communityRedirect: req.context.page?.communityRedirect || {}, |
| 128 | currentProduct: req.context.productMap[req.context.currentProduct] || null, |
| 129 | currentLayoutName: req.context.currentLayoutName, |
| 130 | isHomepageVersion: req.context.page?.documentType === 'homepage', |
| 131 | isFPT: req.context.currentVersion === 'free-pro-team@latest', |
| 132 | error: req.context.error ? req.context.error.toString() : '', |
| 133 | data: { |
| 134 | ui: req.context.site.data.ui, |
| 135 | |
| 136 | reusables: { |
| 137 | enterprise_deprecation: { |
| 138 | version_was_deprecated: req.context.getDottedData( |
| 139 | 'reusables.enterprise_deprecation.version_was_deprecated' |
| 140 | ), |
| 141 | version_will_be_deprecated: req.context.getDottedData( |
| 142 | 'reusables.enterprise_deprecation.version_will_be_deprecated' |
| 143 | ), |
| 144 | deprecation_details: req.context.getDottedData( |
| 145 | 'reusables.enterprise_deprecation.deprecation_details' |
| 146 | ), |
| 147 | }, |
| 148 | policies: { |
| 149 | translation: req.context.getDottedData('reusables.policies.translation'), |
| 150 | }, |
| 151 | }, |
| 152 | variables: { |
| 153 | release_candidate: { |
| 154 | version: req.context.getDottedData('variables.release_candidate.version') || null, |
| 155 | }, |
| 156 | }, |
| 157 | }, |
| 158 | currentCategory: req.context.currentCategory || '', |
| 159 | currentPathWithoutLanguage: req.context.currentPathWithoutLanguage, |
| 160 | relativePath: req.context.page?.relativePath, |
| 161 | page: { |
| 162 | languageVariants: req.context.page.languageVariants, |
| 163 | documentType: req.context.page.documentType, |
| 164 | type: req.context.page.type || null, |
| 165 | title: req.context.page.title, |
| 166 | fullTitle: req.context.page.fullTitle, |
| 167 | topics: req.context.page.topics || [], |
| 168 | introPlainText: req.context.page?.introPlainText, |
| 169 | permalinks: req.context.page?.permalinks.map((obj: any) => |
| 170 | pick(obj, ['title', 'pageVersion', 'href', 'relativePath', 'languageCode']) |
| 171 | ), |
| 172 | hidden: req.context.page.hidden || false, |
no outgoing calls
no test coverage detected