This commit is contained in:
simio 2025-05-08 01:35:16 -03:00
parent 5953a14893
commit 15924a2533
2 changed files with 11 additions and 11 deletions

View File

@ -6,7 +6,6 @@ const { dirname } = require('path');
const thisDirectory = dirname(require.main.filename);
const fs = require('fs');
const makeRss = require('../utils/rss');
const langs = ["es", "en"]
function addPaths(path, renderParams = {}){
let currentDefaultParams = {...renderParams}

View File

@ -3,7 +3,7 @@ const appDir = dirname(require.main.filename);
const fs = require('fs')
const langs = ["es", "en"]
async function createCommonPath(router, path, renderParams = {
function createCommonPath(router, path, renderParams = {
}, cb = () => {}){
const defaultParams = {
view: path,
@ -31,19 +31,20 @@ async function createCommonPath(router, path, renderParams = {
}
renderOptions.lang = "es"
renderOptions.langPath = ""
await createPath('/' + path, cb, renderOptions, router)
// for(let l in langs){
// renderOptions.lang = l
// renderOptions.langPath = l + '/'
// await createPath('/' + renderOptions.langPath + path, cb, renderOptions, router)
// }
createPath('/' + path, cb, renderOptions, router)
for(let l in langs){
const otherLangRender = {...renderOptions}
otherLangRender.lang = langs[l]
otherLangRender.langPath = langs[l] + '/'
createPath('/' + otherLangRender.langPath + path, cb, otherLangRender, router)
}
}
async function createPath(path, cb, renderOptions, router){
function createPath(path, cb, renderOptions, router){
router.get(path, async (req, res) => {
const cb_params = await cb(req, res)
renderOptions = {...renderOptions, ...cb_params}
res.render(renderOptions.view, renderOptions)
const finalOptions = {...renderOptions, ...cb_params}
res.render(finalOptions.view, finalOptions)
})
}