зеркало из https://github.com/github/docs.git
remove spotContentFlaws middleware (#28068)
This commit is contained in:
Родитель
83b3470f0a
Коммит
0340760554
|
@ -29,7 +29,6 @@ import redirectsExternal from './redirects/external.js'
|
|||
import languageCodeRedirects from './redirects/language-code-redirects.js'
|
||||
import handleRedirects from './redirects/handle-redirects.js'
|
||||
import findPage from './find-page.js'
|
||||
import spotContentFlaws from './spot-content-flaws.js'
|
||||
import blockRobots from './block-robots.js'
|
||||
import archivedEnterpriseVersionsAssets from './archived-enterprise-versions-assets.js'
|
||||
import events from './events.js'
|
||||
|
@ -270,7 +269,6 @@ export default function (app) {
|
|||
|
||||
// *** Config and context for rendering ***
|
||||
app.use(asyncMiddleware(instrument(findPage, './find-page'))) // Must come before archived-enterprise-versions, breadcrumbs, featured-links, products, render-page
|
||||
app.use(asyncMiddleware(instrument(spotContentFlaws, './spot-content-flaws'))) // Must come after findPage
|
||||
app.use(instrument(blockRobots, './block-robots'))
|
||||
|
||||
// Check for a dropped connection before proceeding
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
// This middleware, exclusively in 'development' tries to spot flaws in
|
||||
// the content you're actively viewing.
|
||||
// The hopeful assumption is that if you're actively viewing this
|
||||
// page on localhost, you're actively working on its content.
|
||||
|
||||
import path from 'path'
|
||||
|
||||
import kleur from 'kleur'
|
||||
|
||||
export default async function spotContentFlaws(req, res, next) {
|
||||
const { page } = req.context
|
||||
if (process.env.NODE_ENV === 'development' && page) {
|
||||
const trailingSlashRedirects = (page.redirect_from || []).filter(
|
||||
(uri) => uri.endsWith('/') && uri.startsWith('/')
|
||||
)
|
||||
if (trailingSlashRedirects.length > 0) {
|
||||
console.warn(
|
||||
`The page ${kleur.bold(path.relative(process.cwd(), page.fullPath))} has ${
|
||||
trailingSlashRedirects.length
|
||||
} redirect_from entries that have a trailing slash\n ${kleur.yellow(
|
||||
trailingSlashRedirects.join('\n ')
|
||||
)}`
|
||||
)
|
||||
console.log(
|
||||
"If you're actively working on this page, consider",
|
||||
kleur.bold('deleting all trailing slashes in redirect_from.\n')
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return next()
|
||||
}
|
|
@ -45,7 +45,6 @@
|
|||
"javascript-stringify": "^2.1.0",
|
||||
"js-cookie": "^3.0.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"kleur": "4.1.4",
|
||||
"liquidjs": "^9.22.1",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
|
|
|
@ -47,7 +47,6 @@
|
|||
"javascript-stringify": "^2.1.0",
|
||||
"js-cookie": "^3.0.1",
|
||||
"js-yaml": "^4.1.0",
|
||||
"kleur": "4.1.4",
|
||||
"liquidjs": "^9.22.1",
|
||||
"lodash": "^4.17.21",
|
||||
"lodash-es": "^4.17.21",
|
||||
|
|
Загрузка…
Ссылка в новой задаче