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 thisDirectory = dirname(require.main.filename);
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const makeRss = require('../utils/rss');
|
const makeRss = require('../utils/rss');
|
||||||
const langs = ["es", "en"]
|
|
||||||
|
|
||||||
function addPaths(path, renderParams = {}){
|
function addPaths(path, renderParams = {}){
|
||||||
let currentDefaultParams = {...renderParams}
|
let currentDefaultParams = {...renderParams}
|
||||||
|
@ -3,7 +3,7 @@ const appDir = dirname(require.main.filename);
|
|||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const langs = ["es", "en"]
|
const langs = ["es", "en"]
|
||||||
|
|
||||||
async function createCommonPath(router, path, renderParams = {
|
function createCommonPath(router, path, renderParams = {
|
||||||
}, cb = () => {}){
|
}, cb = () => {}){
|
||||||
const defaultParams = {
|
const defaultParams = {
|
||||||
view: path,
|
view: path,
|
||||||
@ -31,19 +31,20 @@ async function createCommonPath(router, path, renderParams = {
|
|||||||
}
|
}
|
||||||
renderOptions.lang = "es"
|
renderOptions.lang = "es"
|
||||||
renderOptions.langPath = ""
|
renderOptions.langPath = ""
|
||||||
await createPath('/' + path, cb, renderOptions, router)
|
createPath('/' + path, cb, renderOptions, router)
|
||||||
// for(let l in langs){
|
for(let l in langs){
|
||||||
// renderOptions.lang = l
|
const otherLangRender = {...renderOptions}
|
||||||
// renderOptions.langPath = l + '/'
|
otherLangRender.lang = langs[l]
|
||||||
// await createPath('/' + renderOptions.langPath + path, cb, renderOptions, router)
|
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) => {
|
router.get(path, async (req, res) => {
|
||||||
const cb_params = await cb(req, res)
|
const cb_params = await cb(req, res)
|
||||||
renderOptions = {...renderOptions, ...cb_params}
|
const finalOptions = {...renderOptions, ...cb_params}
|
||||||
res.render(renderOptions.view, renderOptions)
|
res.render(finalOptions.view, finalOptions)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user