1
0
mirror of synced 2025-12-25 02:17:36 -05:00

break up large rest pages (#23652)

This commit is contained in:
Rachael Sewell
2021-12-14 12:39:25 -08:00
committed by GitHub
parent fe72014657
commit daafb8cb9d
37 changed files with 710 additions and 532 deletions

View File

@@ -1,5 +1,5 @@
import path from 'path'
import getRest from '../../lib/rest/index.js'
import getRest, { restRepoCategoryExceptions } from '../../lib/rest/index.js'
import removeFPTFromPath from '../../lib/remove-fpt-from-path.js'
// Global cache to avoid calling getRest() more than once
@@ -24,11 +24,16 @@ export default async function restContext(req, res, next) {
if (!req.pagePath.includes('rest/reference')) return next()
// e.g. the `activity` from `/en/rest/reference/activity#events`
const category = req.pagePath
let category = req.pagePath
.split('rest/reference')[1]
.replace(/^\//, '') // remove leading slash
.split('/')[0]
// override the category if the category is in the restRepoCategoryExceptions list
if (restRepoCategoryExceptions.includes(category)) {
category = 'repos'
}
// ignore empty strings or bare `/`
if (!category || category.length < 2) return next()