Merge pull request #18996 from overleaf/td-bs5-nav-react

Main navigation React component

GitOrigin-RevId: c99a4b4a2f6fd02618689f829681118b2b64aa8d
This commit is contained in:
Tim Down
2024-08-22 08:05:03 +00:00
committed by Copybot
parent 2296287e61
commit d5643d53b3
33 changed files with 669 additions and 15 deletions
@@ -227,6 +227,26 @@ module.exports = function (webRouter, privateApiRouter, publicApiRouter) {
webRouter.use(function (req, res, next) {
res.locals.translate = req.i18n.translate
const addTranslatedTextDeep = obj => {
if (_.isObject(obj)) {
if (_.has(obj, 'text')) {
obj.translatedText = req.i18n.translate(obj.text)
}
_.forOwn(obj, value => {
addTranslatedTextDeep(value)
})
}
}
// This function is used to add translations from the server for main
// navigation items because it's tricky to get them in the front end
// otherwise.
res.locals.cloneAndTranslateText = obj => {
const clone = _.cloneDeep(obj)
addTranslatedTextDeep(clone)
return clone
}
// Don't include the query string parameters, otherwise Google
// treats ?nocdn=true as the canonical version
try {