fix: remove <noscript> when static content is generated and rendered already

This commit is contained in:
Danny Koppenhagen
2023-06-19 14:11:57 +02:00
committed by Stefan Rotsch
parent 3dcb9075b7
commit 8876d3b1c7
4 changed files with 14 additions and 3 deletions

View File

@@ -95,6 +95,11 @@ var createStaticFiles = function () { return __awaiter(void 0, void 0, void 0, f
headlineNode.appendChild(titleText);
rootEl.appendChild(headlineNode);
rootEl.appendChild(textNode);
// remove the <noscript> element as page has already been hydrated with static content
var noscriptEl = document.getElementsByTagName("noscript");
if (noscriptEl[0]) {
noscriptEl[0].remove();
}
}
else {
console.warn('Element with ID "root" not found. Static site content will be empty.');

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "aoe_technology_radar",
"version": "3.5.2",
"version": "3.5.3",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "aoe_technology_radar",
"version": "3.5.2",
"version": "3.5.3",
"license": "Apache-2.0",
"dependencies": {
"@apideck/better-ajv-errors": "0.3.6",

View File

@@ -19,8 +19,8 @@
</head>
<body>
<noscript>You need to enable JavaScript to view the %REACT_APP_RADAR_NAME%.</noscript>
<div id="root"></div>
<noscript>You need to enable JavaScript to view the %REACT_APP_RADAR_NAME%.</noscript>
</body>
</html>

View File

@@ -67,6 +67,12 @@ const createStaticFiles = async () => {
rootEl.appendChild(headlineNode);
rootEl.appendChild(textNode);
// remove the <noscript> element as page has already been hydrated with static content
const noscriptEl = document.getElementsByTagName("noscript");
if (noscriptEl[0]) {
noscriptEl[0].remove();
}
} else {
console.warn(
'Element with ID "root" not found. Static site content will be empty.'