From 805fca4f63280d67f4b8565fd578afe066eaf336 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Wed, 7 Dec 2022 20:51:17 +0100 Subject: [PATCH] MINIMAL_RENDER should be on default for npm run sync-search-server (#33294) --- .github/workflows/sync-search-elasticsearch.yml | 3 --- .github/workflows/sync-search-pr.yml | 3 --- components/DefaultLayout.tsx | 4 +++- package.json | 2 +- 4 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/sync-search-elasticsearch.yml b/.github/workflows/sync-search-elasticsearch.yml index 7980a2a35c..e3cabfd835 100644 --- a/.github/workflows/sync-search-elasticsearch.yml +++ b/.github/workflows/sync-search-elasticsearch.yml @@ -139,9 +139,6 @@ jobs: - name: Start the server in the background env: ENABLE_DEV_LOGGING: false - # Makes it so that the React rendering of pages just does the - # minimal needed to be able to extract the page text for search. - MINIMAL_RENDER: true run: | npm run sync-search-server > /tmp/stdout.log 2> /tmp/stderr.log & diff --git a/.github/workflows/sync-search-pr.yml b/.github/workflows/sync-search-pr.yml index a0b2c924f6..69007df49e 100644 --- a/.github/workflows/sync-search-pr.yml +++ b/.github/workflows/sync-search-pr.yml @@ -67,9 +67,6 @@ jobs: - name: Start the server in the background env: ENABLE_DEV_LOGGING: false - # Makes it so that the React rendering of pages just does the - # minimal needed to be able to extract the page text for search. - MINIMAL_RENDER: true run: | npm run sync-search-server > /tmp/stdout.log 2> /tmp/stderr.log & diff --git a/components/DefaultLayout.tsx b/components/DefaultLayout.tsx index 6220d3e0f9..781e9b586b 100644 --- a/components/DefaultLayout.tsx +++ b/components/DefaultLayout.tsx @@ -11,6 +11,8 @@ import { useMainContext } from 'components/context/MainContext' import { useTranslation } from 'components/hooks/useTranslation' import { useRouter } from 'next/router' +const MINIMAL_RENDER = Boolean(JSON.parse(process.env.MINIMAL_RENDER || 'false')) + type Props = { children?: React.ReactNode } export const DefaultLayout = (props: Props) => { const { @@ -31,7 +33,7 @@ export const DefaultLayout = (props: Props) => { // This is only true when we do search indexing which renders every page // just to be able to `cheerio` load the main body (and the meta // keywords tag). - if (process.env.MINIMAL_RENDER) { + if (MINIMAL_RENDER) { return (
diff --git a/package.json b/package.json index d2453d83f7..e271b7bd42 100644 --- a/package.json +++ b/package.json @@ -196,7 +196,7 @@ "sync-search": "cross-env NODE_OPTIONS='--max_old_space_size=8192' start-server-and-test sync-search-server 4002 sync-search-indices", "sync-search-ghes-release": "cross-env GHES_RELEASE=1 start-server-and-test sync-search-server 4002 sync-search-indices", "sync-search-indices": "script/search/sync-search-indices.js", - "sync-search-server": "cross-env NODE_ENV=production PORT=4002 CHANGELOG_DISABLED=true node server.js", + "sync-search-server": "cross-env NODE_ENV=production PORT=4002 MINIMAL_RENDER=true CHANGELOG_DISABLED=true node server.js", "translation-check": "start-server-and-test translation-check-server 4002 translation-check-test", "translation-check-server": "cross-env NODE_ENV=test PORT=4002 node server.js", "translation-check-test": "script/i18n/test-html-pages.js",