@@ -69,7 +69,9 @@ const extractFrontNav = (front: DCRFrontType): NavType => {
6969 } ;
7070} ;
7171
72- export const renderFront = ( { front } : Props ) : string => {
72+ export const renderFront = ( {
73+ front,
74+ } : Props ) : { html : string ; clientScripts : string [ ] } => {
7375 const title = front . webTitle ;
7476 const NAV = extractFrontNav ( front ) ;
7577
@@ -93,19 +95,17 @@ export const renderFront = ({ front }: Props): string => {
9395 * Please talk to the dotcom platform team before adding more.
9496 * Scripts will be executed in the order they appear in this array
9597 */
96- const scriptTags = generateScriptTags (
97- [
98- polyfillIO ,
99- getPathFromManifest ( build , 'frameworks.js' ) ,
100- getPathFromManifest ( build , 'index.js' ) ,
101- getPathFromManifest ( 'web.legacy' , 'frameworks.js' ) ,
102- getPathFromManifest ( 'web.legacy' , 'index.js' ) ,
103- process . env . COMMERCIAL_BUNDLE_URL ??
104- front . config . commercialBundleUrl ,
105- ]
106- . filter ( isString )
107- . map ( ( script ) => ( offerHttp3 ? getHttp3Url ( script ) : script ) ) ,
108- ) ;
98+ const clientScripts = [
99+ polyfillIO ,
100+ getPathFromManifest ( build , 'frameworks.js' ) ,
101+ getPathFromManifest ( build , 'index.js' ) ,
102+ getPathFromManifest ( 'web.legacy' , 'frameworks.js' ) ,
103+ getPathFromManifest ( 'web.legacy' , 'index.js' ) ,
104+ process . env . COMMERCIAL_BUNDLE_URL ?? front . config . commercialBundleUrl ,
105+ ]
106+ . filter ( isString )
107+ . map ( ( script ) => ( offerHttp3 ? getHttp3Url ( script ) : script ) ) ;
108+ const scriptTags = generateScriptTags ( clientScripts ) ;
109109
110110 const guardian = createGuardian ( {
111111 editionId : front . editionId ,
@@ -130,7 +130,7 @@ export const renderFront = ({ front }: Props): string => {
130130
131131 const keywords = front . config . keywords ;
132132
133- return htmlPageTemplate ( {
133+ const pageHtml = htmlPageTemplate ( {
134134 scriptTags,
135135 css : extractedCss ,
136136 html,
@@ -143,13 +143,18 @@ export const renderFront = ({ front }: Props): string => {
143143 hasPageSkin : front . config . hasPageSkin ,
144144 weAreHiring : ! ! front . config . switches . weAreHiring ,
145145 } ) ;
146+
147+ return {
148+ html : pageHtml ,
149+ clientScripts,
150+ } ;
146151} ;
147152
148153export const renderTagFront = ( {
149154 tagFront,
150155} : {
151156 tagFront : DCRTagFrontType ;
152- } ) : string => {
157+ } ) : { html : string ; clientScripts : string [ ] } => {
153158 const title = tagFront . webTitle ;
154159 const NAV = extractNAV ( tagFront . nav ) ;
155160
@@ -173,19 +178,18 @@ export const renderTagFront = ({
173178 * Please talk to the dotcom platform team before adding more.
174179 * Scripts will be executed in the order they appear in this array
175180 */
176- const scriptTags = generateScriptTags (
177- [
178- polyfillIO ,
179- getPathFromManifest ( build , 'frameworks.js' ) ,
180- getPathFromManifest ( build , 'index.js' ) ,
181- getPathFromManifest ( 'web.legacy' , 'frameworks.js' ) ,
182- getPathFromManifest ( 'web.legacy' , 'index.js' ) ,
183- process . env . COMMERCIAL_BUNDLE_URL ??
184- tagFront . config . commercialBundleUrl ,
185- ]
186- . filter ( isString )
187- . map ( ( script ) => ( offerHttp3 ? getHttp3Url ( script ) : script ) ) ,
188- ) ;
181+ const clientScripts = [
182+ polyfillIO ,
183+ getPathFromManifest ( build , 'frameworks.js' ) ,
184+ getPathFromManifest ( build , 'index.js' ) ,
185+ getPathFromManifest ( 'web.legacy' , 'frameworks.js' ) ,
186+ getPathFromManifest ( 'web.legacy' , 'index.js' ) ,
187+ process . env . COMMERCIAL_BUNDLE_URL ??
188+ tagFront . config . commercialBundleUrl ,
189+ ]
190+ . filter ( isString )
191+ . map ( ( script ) => ( offerHttp3 ? getHttp3Url ( script ) : script ) ) ;
192+ const scriptTags = generateScriptTags ( clientScripts ) ;
189193
190194 const guardian = createGuardian ( {
191195 editionId : tagFront . editionId ,
@@ -210,7 +214,7 @@ export const renderTagFront = ({
210214
211215 const keywords = tagFront . config . keywords ;
212216
213- return htmlPageTemplate ( {
217+ const pageHtml = htmlPageTemplate ( {
214218 scriptTags,
215219 css : extractedCss ,
216220 html,
@@ -222,4 +226,8 @@ export const renderTagFront = ({
222226 renderingTarget : 'Web' ,
223227 weAreHiring : ! ! tagFront . config . switches . weAreHiring ,
224228 } ) ;
229+ return {
230+ html : pageHtml ,
231+ clientScripts,
232+ } ;
225233} ;
0 commit comments