зеркало из https://github.com/github/docs.git
Enable set `AIRGAP` cookie to view Lunr search results (#18648)
* Enable set `lunr` cookie to view Lunr search results * Use AIRGAP instead of lunr for cookie name
This commit is contained in:
Родитель
059aea29d3
Коммит
f160594a09
|
@ -1,7 +1,7 @@
|
|||
{% include breadcrumbs %}
|
||||
|
||||
<div class="graphql-container">
|
||||
{% if process.env.AIRGAP %}
|
||||
{% if AIRGAP %}
|
||||
<p>GraphQL explorer is not available on this environment.</p>
|
||||
{% else %}
|
||||
<iframe id="graphiql" class="graphql-explorer" scrolling="no" src="{{ graphql.explorerUrl }}" allowfullscreen>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
<div class="mt-2">
|
||||
<div>
|
||||
{% if process.env.AIRGAP %}
|
||||
{% if AIRGAP %}
|
||||
<p>GraphQL explorer is not available on this environment.</p>
|
||||
{% else %}
|
||||
<iframe id="graphiql" class="graphql-explorer" scrolling="no" src="{{ graphql.explorerUrl }}">
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
{% if page.product_video and page.product_video != '' %}
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="position-relative" style="padding-bottom:56.25%;">
|
||||
{% unless process.env.AIRGAP %}
|
||||
{% unless AIRGAP %}
|
||||
<iframe
|
||||
title="{{ page.shortTitle }} Video"
|
||||
class="top-0 left-0 position-absolute box-shadow-large rounded-1 width-full height-full"
|
||||
|
|
|
@ -29,7 +29,6 @@ module.exports = async function contextualize (req, res, next) {
|
|||
featureFlags.forEach(featureFlagName => {
|
||||
req.context.process.env[featureFlagName] = process.env[featureFlagName]
|
||||
})
|
||||
if (process.env.AIRGAP) req.context.process.env.AIRGAP = true
|
||||
|
||||
// define each context property explicitly for code-search friendliness
|
||||
// e.g. searches for "req.context.page" will include results from this file
|
||||
|
@ -64,8 +63,9 @@ module.exports = async function contextualize (req, res, next) {
|
|||
nonEnterpriseDefaultVersion
|
||||
},
|
||||
// `|| undefined` won't show at all for production
|
||||
airgap: Boolean(process.env.AIRGAP) || undefined
|
||||
airgap: Boolean(process.env.AIRGAP || req.cookies.AIRGAP) || undefined
|
||||
})
|
||||
if (process.env.AIRGAP || req.cookies.AIRGAP) req.context.AIRGAP = true
|
||||
|
||||
return next()
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ router.get('/', async function postSearch (req, res, next) {
|
|||
}
|
||||
|
||||
try {
|
||||
const results = process.env.AIRGAP
|
||||
const results = process.env.AIRGAP || req.cookies.AIRGAP
|
||||
? await loadLunrResults({ version, language, query: `${query} ${filters || ''}`, limit })
|
||||
: await loadAlgoliaResults({ version, language, query, filters, limit })
|
||||
return res.status(200).json(results)
|
||||
|
|
Загрузка…
Ссылка в новой задаче