i18n: Fix urls while not / exists
This commit is contained in:
parent
d590582a85
commit
0498ea8541
2
app.js
2
app.js
@ -86,6 +86,8 @@ const csrfProtection = csrf({ cookie: true });
|
|||||||
app.use(csrfProtection);
|
app.use(csrfProtection);
|
||||||
app.use(/\/(fr|en)/i, indexRouter);
|
app.use(/\/(fr|en)/i, indexRouter);
|
||||||
app.use(/\/(fr|en)\/auth/i, authRouter);
|
app.use(/\/(fr|en)\/auth/i, authRouter);
|
||||||
|
app.use("/", indexRouter);
|
||||||
|
app.use("/auth", authRouter);
|
||||||
|
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
app.use(function (req, res, next) {
|
app.use(function (req, res, next) {
|
||||||
|
@ -7,7 +7,10 @@ function indexPage(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function loginPage(req, res) {
|
function loginPage(req, res) {
|
||||||
res.render('auth/login');
|
res.render('auth/login', {
|
||||||
|
title: req.i18n.__("SoundBirder - Login"),
|
||||||
|
locale: req.i18n.locale
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function login(req, res) {
|
function login(req, res) {
|
||||||
@ -19,7 +22,10 @@ function logout(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function registerPage(req, res) {
|
function registerPage(req, res) {
|
||||||
res.render('auth/register');
|
res.render('auth/register', {
|
||||||
|
title: req.i18n.__("SoundBirder - Register"),
|
||||||
|
locale: req.i18n.locale
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function register(req, res) {
|
function register(req, res) {
|
||||||
|
@ -2,12 +2,16 @@
|
|||||||
function getIndex(req, res) {
|
function getIndex(req, res) {
|
||||||
res.render('index', {
|
res.render('index', {
|
||||||
title: 'SoundBirder',
|
title: 'SoundBirder',
|
||||||
csrf_token: req.csrfToken()
|
csrf_token: req.csrfToken(),
|
||||||
|
locale: req.i18n.locale
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAbout(req, res) {
|
function getAbout(req, res) {
|
||||||
res.render('about', { title: 'About SoundBirder' });
|
res.render('about', {
|
||||||
|
title: 'About SoundBirder',
|
||||||
|
locale: req.i18n.locale
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
@ -10,11 +10,12 @@ html
|
|||||||
header
|
header
|
||||||
h1= title
|
h1= title
|
||||||
nav
|
nav
|
||||||
|
- var i18n_prefix = locale ? '/' + locale : ''
|
||||||
ul
|
ul
|
||||||
li
|
li
|
||||||
a(href="/") #{ __("Game") }
|
a(href=`${i18n_prefix}/`) #{ __("Game") }
|
||||||
li
|
li
|
||||||
a(href="/about") #{ __("About") }
|
a(href=`${i18n_prefix}/about`) #{ __("About") }
|
||||||
main
|
main
|
||||||
block content
|
block content
|
||||||
footer
|
footer
|
||||||
|
Loading…
x
Reference in New Issue
Block a user