* homepage: reduce padding below search area
Bring as much useful content up "above the fold".
* homepage: add groups for the front page sections
Group the homepage links into sections that map to the GitHub features
page (`/features`) plus two groups that are bespoke to the docs ("Get
started" and "Developers").
* homepage: update group design
Group the feature list area using the design exploration work by
@arisacoba. Remove the description.
* homepage: remove ungrouped items from main area
Remove ungrouped items (like the external links) from the main feature
area. Users can still navigate to ungrouped items in the sidebar.
* fix tsc error, use Link component
* homepage: support empty icon in group
Don't assume that we have icons everywhere on the landing page groups.
* homepage: drop octocat/invertocat
Looks weird with the modern icons, looks bad in dark mode. Drop them
for now.
* homepage: document the childGroups frontmatter property
* homepage: don't test that sidebar == main content
We're reducing the links on the homepage in the main content area, but
the sidebar should be the complete list of products. Remove the tests
that ensure that the main content area has all the sidebar content. But
keep the tests that ensure that the sidebar content has all the links in
the main content area.
* homepage: remove "GitHub" doc set
The "GitHub" doc set "will be removed soon as we keep moving more content
out of it, so let's not include it here to keep the page more
evergreen."
* homepage: don't test that `/github` is linked on the main page
We're removing the `/github` doc set, and it's now not in the main page
grouped links. Remove the test that `/github` exists, now look for
`/get-started`.
* homepage: use octicons instead of images
The images from https://github.com/features will be updated 🔜 - in
the meantime, let's use octicons which are consistent and give visual
interest.
* homepage: use octicons from @primer/octicons-react
Using the react components adds `<svg>` elements instead of `<img>`
elements, which lets the element use the current fill color, supporting
both light and dark themes.
Co-authored-by: Mike Surowiec <mikesurowiec@users.noreply.github.com>
Co-authored-by: Emily Gould <4822039+emilyistoofunky@users.noreply.github.com>
78 lines
3.2 KiB
JavaScript
78 lines
3.2 KiB
JavaScript
import languages from '../lib/languages.js'
|
|
import enterpriseServerReleases from '../lib/enterprise-server-releases.js'
|
|
import { allVersions } from '../lib/all-versions.js'
|
|
import { productMap, productGroups } from '../lib/all-products.js'
|
|
import pathUtils from '../lib/path-utils.js'
|
|
import productNames from '../lib/product-names.js'
|
|
import warmServer from '../lib/warm-server.js'
|
|
import readJsonFile from '../lib/read-json-file.js'
|
|
import searchVersions from '../lib/search/versions.js'
|
|
import nonEnterpriseDefaultVersion from '../lib/non-enterprise-default-version.js'
|
|
const activeProducts = Object.values(productMap).filter(
|
|
(product) => !product.wip && !product.hidden
|
|
)
|
|
const {
|
|
getVersionStringFromPath,
|
|
getProductStringFromPath,
|
|
getCategoryStringFromPath,
|
|
getPathWithoutLanguage,
|
|
} = pathUtils
|
|
const featureFlags = Object.keys(readJsonFile('./feature-flags.json'))
|
|
|
|
// Supply all route handlers with a baseline `req.context` object
|
|
// Note that additional middleware in middleware/index.js adds to this context object
|
|
export default async function contextualize(req, res, next) {
|
|
// Ensure that we load some data only once on first request
|
|
const { site, redirects, siteTree, pages: pageMap } = await warmServer()
|
|
|
|
req.context = {}
|
|
|
|
// make feature flag environment variables accessible in layouts
|
|
req.context.process = { env: {} }
|
|
featureFlags.forEach((featureFlagName) => {
|
|
req.context[featureFlagName] = process.env[featureFlagName]
|
|
})
|
|
|
|
// define each context property explicitly for code-search friendliness
|
|
// e.g. searches for "req.context.page" will include results from this file
|
|
req.context.currentLanguage = req.language
|
|
req.context.userLanguage = req.userLanguage
|
|
req.context.currentVersion = getVersionStringFromPath(req.pagePath)
|
|
req.context.currentProduct = getProductStringFromPath(req.pagePath)
|
|
req.context.currentCategory = getCategoryStringFromPath(req.pagePath)
|
|
req.context.productMap = productMap
|
|
req.context.productGroups = productGroups
|
|
req.context.activeProducts = activeProducts
|
|
req.context.allVersions = allVersions
|
|
req.context.currentPathWithoutLanguage = getPathWithoutLanguage(req.pagePath)
|
|
req.context.currentPath = req.pagePath
|
|
req.context.query = req.query
|
|
req.context.languages = languages
|
|
req.context.productNames = productNames
|
|
req.context.enterpriseServerReleases = enterpriseServerReleases
|
|
req.context.enterpriseServerVersions = Object.keys(allVersions).filter((version) =>
|
|
version.startsWith('enterprise-server@')
|
|
)
|
|
req.context.redirects = redirects
|
|
req.context.site = site[req.language].site
|
|
req.context.siteTree = siteTree
|
|
req.context.pages = pageMap
|
|
|
|
// Object exposing selected variables to client
|
|
req.context.expose = JSON.stringify({
|
|
// Languages and versions for search
|
|
searchOptions: {
|
|
languages: Object.keys(languages),
|
|
versions: searchVersions,
|
|
nonEnterpriseDefaultVersion,
|
|
},
|
|
// `|| undefined` won't show at all for production
|
|
airgap: Boolean(process.env.AIRGAP || req.cookies.AIRGAP) || undefined,
|
|
})
|
|
if (process.env.AIRGAP || req.cookies.AIRGAP) req.context.AIRGAP = true
|
|
req.context.searchVersions = searchVersions
|
|
req.context.nonEnterpriseDefaultVersion = nonEnterpriseDefaultVersion
|
|
|
|
return next()
|
|
}
|