crear todos los paths dinamicamente para cada idioma
This commit is contained in:
parent
65c1fa23ee
commit
42e1a65b43
@ -6,6 +6,7 @@ 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}
|
||||||
@ -42,7 +43,6 @@ function addPaths(path, renderParams = {}){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
if (file === 'partials' || file === 'layouts') return
|
if (file === 'partials' || file === 'layouts') return
|
||||||
|
|
||||||
addPaths(path + file + '/', currentDefaultParams)
|
addPaths(path + file + '/', currentDefaultParams)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,7 +85,7 @@ router.get('/update_log/rss', async (_req, res) => {
|
|||||||
rss.item({
|
rss.item({
|
||||||
title: "Update #" + i,
|
title: "Update #" + i,
|
||||||
description: `${u.link && `<a href="${u.link}">`}${u.description}${u.link && `</a>`}`,
|
description: `${u.link && `<a href="${u.link}">`}${u.description}${u.link && `</a>`}`,
|
||||||
author: "Gor Down",
|
author: "Lyrical Tokarev",
|
||||||
date: u.date
|
date: u.date
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
const { dirname } = require('path');
|
const { dirname } = require('path');
|
||||||
const appDir = dirname(require.main.filename);
|
const appDir = dirname(require.main.filename);
|
||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
|
const langs = ["es", "en"]
|
||||||
|
|
||||||
function createCommonPath(router, path, renderParams = {
|
function createCommonPath(router, path, renderParams = {
|
||||||
}, cb = () => {}){
|
}, cb = () => {}){
|
||||||
@ -28,7 +29,16 @@ function createCommonPath(router, path, renderParams = {
|
|||||||
...fileGeneralParams
|
...fileGeneralParams
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
router.get('/' + path, async (req, res) => {
|
renderOptions.lang = "es"
|
||||||
|
createPath('/' + path, cb, renderOptions, router)
|
||||||
|
langs.forEach(l => {
|
||||||
|
renderOptions.lang = l
|
||||||
|
createPath('/' + l + "/" + path, cb, renderOptions, router)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createPath(path, cb, renderOptions, router){
|
||||||
|
router.get(path, async (req, res) => {
|
||||||
const cb_params = await cb(req, res)
|
const cb_params = await cb(req, res)
|
||||||
renderOptions = {...renderOptions, ...cb_params}
|
renderOptions = {...renderOptions, ...cb_params}
|
||||||
res.render(renderOptions.view, renderOptions)
|
res.render(renderOptions.view, renderOptions)
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<p>Blasonador: <a id="cidoku" href="http://cidoku.net">Cidoku</a></p>
|
<p>Blasonador: <a id="cidoku" href="http://cidoku.net">Cidoku</a></p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<p>Armígero: <a href="http://lyricaltokarev.com"><span id="celeste">Gor Down</span></a></p>
|
<p>Armígero: <a href="http://lyricaltokarev.com"><span id="celeste">Lyrical Tokarev</span></a></p>
|
||||||
</td>
|
</td>
|
||||||
<td valign="top">
|
<td valign="top">
|
||||||
<p>Otorgado el: 9 de marzo, 2025</p>
|
<p>Otorgado el: 9 de marzo, 2025</p>
|
||||||
|
Loading…
Reference in New Issue
Block a user