зеркало из https://github.com/github/docs.git
Default sponsors+discussions pages to nextjs rendering (#19667)
* default to nextjs rendering on sponsors and discussions pages
This commit is contained in:
Родитель
f8f72fc1d8
Коммит
6bdbe209c9
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"FEATURE_TEST_TRUE": true,
|
||||
"FEATURE_TEST_FALSE": false,
|
||||
"FEATURE_NEXTJS": false
|
||||
"FEATURE_NEXTJS": true
|
||||
}
|
||||
|
|
|
@ -10,6 +10,13 @@ const { isConnectionDropped } = require('./halt-on-dropped-connection')
|
|||
const { nextHandleRequest } = require('./next')
|
||||
|
||||
const { HEROKU_RELEASE_VERSION, FEATURE_NEXTJS } = process.env
|
||||
|
||||
const defaultNextJSRoutes = FEATURE_NEXTJS
|
||||
? [
|
||||
'/en/sponsors',
|
||||
'/en/discussions'
|
||||
]
|
||||
: []
|
||||
const pageCacheDatabaseNumber = 1
|
||||
const pageCacheExpiration = 24 * 60 * 60 * 1000 // 24 hours
|
||||
|
||||
|
@ -88,7 +95,7 @@ module.exports = async function renderPage (req, res, next) {
|
|||
const isRequestingJsonForDebugging = 'json' in req.query && process.env.NODE_ENV !== 'production'
|
||||
|
||||
// Should the current path be rendered by NextJS?
|
||||
const renderWithNextjs = 'nextjs' in req.query && FEATURE_NEXTJS
|
||||
const renderWithNextjs = (defaultNextJSRoutes.includes(pathname) || 'nextjs' in req.query) && FEATURE_NEXTJS
|
||||
|
||||
// Is in an airgapped session?
|
||||
const isAirgapped = Boolean(req.cookies.AIRGAP)
|
||||
|
|
|
@ -314,13 +314,13 @@ describe('nextjs query param', () => {
|
|||
|
||||
it('conditionally renders through nextjs pipeline depending on FEATURE_NEXTJS value', async () => {
|
||||
const flagVal = require('../../feature-flags.json').FEATURE_NEXTJS
|
||||
await page.goto('http://localhost:4001/en/sponsors?nextjs=')
|
||||
await page.goto('http://localhost:4001/en/actions?nextjs=')
|
||||
const nextWrapper = await page.$('#__next')
|
||||
flagVal === true ? expect(nextWrapper).toBeDefined() : expect(nextWrapper).toBeNull()
|
||||
})
|
||||
|
||||
it('does not render through nextjs pipeline when nextjs query param is missing', async () => {
|
||||
await page.goto('http://localhost:4001/en/sponsors')
|
||||
await page.goto('http://localhost:4001/en/actions')
|
||||
const nextWrapper = await page.$('#__next')
|
||||
expect(nextWrapper).toBeNull()
|
||||
})
|
||||
|
|
Загрузка…
Ссылка в новой задаче