algo
This commit is contained in:
parent
5953a14893
commit
15924a2533
@ -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}
|
||||
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user