File size: 3,747 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import { isLocaleRtl } from '@automattic/i18n-utils';
import clsx from 'clsx';
import Head from 'calypso/components/head';
import { jsonStringifyForHtml } from 'calypso/server/sanitize';
import { chunkCssLinks } from './utils';

function DomainsLanding( {
	branchName,
	clientData,
	domainsLandingData,
	inlineScriptNonce,
	env,
	entrypoint,
	head,
	i18nLocaleScript,
	lang,
	manifests,
} ) {
	const isRTL = isLocaleRtl( lang );
	return (
		<html lang={ lang } dir={ isRTL ? 'rtl' : 'ltr' }>
			<Head title={ head.title } branchName={ branchName } inlineScriptNonce={ inlineScriptNonce }>
				{ head.metas.map( ( props, index ) => (
					<meta { ...props } key={ index } />
				) ) }
				{ head.links.map( ( props, index ) => (
					<link { ...props } key={ index } />
				) ) }
				{ chunkCssLinks( entrypoint, isRTL ) }
			</Head>
			<body
				className={ clsx( {
					rtl: isRTL,
				} ) }
			>
				{ /* eslint-disable wpcalypso/jsx-classname-namespace, react/no-danger */ }
				<div id="wpcom" className="wpcom-site">
					<div className="wp has-no-sidebar">
						<div className="domains-landing layout__content" id="content">
							<div className="layout__primary" id="primary" />
						</div>
					</div>
				</div>
				{ domainsLandingData && (
					<script
						type="text/javascript"
						dangerouslySetInnerHTML={ {
							__html: `var domainsLandingData = ${ jsonStringifyForHtml( domainsLandingData ) };`,
						} }
					/>
				) }
				{ clientData && (
					<script
						type="text/javascript"
						dangerouslySetInnerHTML={ {
							__html: `var configData = ${ jsonStringifyForHtml( clientData ) };`,
						} }
					/>
				) }
				{ i18nLocaleScript && <script src={ i18nLocaleScript } /> }
				{ /*
				 * inline manifest in production, but reference by url for development.
				 * this lets us have the performance benefit in prod, without breaking HMR in dev
				 * since the manifest needs to be updated on each save
				 */ }
				{ env === 'development' && <script src="/calypso/evergreen/runtime.js" /> }
				{ env !== 'development' &&
					manifests.map( ( manifest ) => (
						<script
							nonce={ inlineScriptNonce }
							dangerouslySetInnerHTML={ {
								__html: manifest,
							} }
						/>
					) ) }
				{ entrypoint.js.map( ( asset ) => (
					<script key={ asset } src={ asset } />
				) ) }
				<script
					nonce={ inlineScriptNonce }
					dangerouslySetInnerHTML={ {
						__html: `
						 (function() {
							if ( window.console && window.configData && 'development' !== window.configData.env ) {
								console.log( "%cSTOP!", "color:#f00;font-size:xx-large" );
								console.log(
									"%cWait! This browser feature runs code that can alter your website or its security, " +
									"and is intended for developers. If you've been told to copy and paste something here " +
									"to enable a feature, someone may be trying to compromise your account. Please make " +
									"sure you understand the code and trust the source before adding anything here.",
									"font-size:large;"
								);
							}
						})();
						 `,
					} }
				/>
				<script
					nonce={ inlineScriptNonce }
					dangerouslySetInnerHTML={ {
						__html: `
							if ('serviceWorker' in navigator) {
								window.addEventListener('load', function() {
									navigator.serviceWorker.register('/service-worker.js');
								});
							}
						 `,
					} }
				/>
				<noscript className="wpcom-site__global-noscript">
					Please enable JavaScript in your browser to enjoy WordPress.com.
				</noscript>
				{ /* eslint-enable wpcalypso/jsx-classname-namespace, react/no-danger */ }
				{ /* eslint-enable wpcalypso/jsx-classname-namespace*/ }
			</body>
		</html>
	);
}

export default DomainsLanding;