1
0
mirror of synced 2025-12-30 03:01:36 -05:00
Files
docs/middleware/dev-toc.js
Kevin Heis 8a56437c93 Pretty format (#20352)
* Update prettier flow to include JS

* Run prettier

* ...run prettier
2021-07-14 14:35:01 -07:00

18 lines
662 B
JavaScript

import { liquid } from '../lib/render-content/index.js'
import layouts from '../lib/layouts.js'
import nonEnterpriseDefaultVersion from '../lib/non-enterprise-default-version.js'
export default async function devToc(req, res, next) {
if (process.env.NODE_ENV !== 'development') return next()
if (!req.path.endsWith('/dev-toc')) return next()
req.context.devTocVersion =
req.path === '/dev-toc' ? nonEnterpriseDefaultVersion : req.context.currentVersion
req.context.devTocTree = req.context.siteTree.en[req.context.devTocVersion]
const body = await liquid.parseAndRender(layouts['dev-toc'], req.context)
return res.status('200').send(body)
}