Fix article loading on direct link to wiki
This commit is contained in:
@ -1,11 +1,17 @@
|
||||
module.exports = function(app) {
|
||||
var router = app.loopback.Router();
|
||||
router.get('/wiki/*', showWiki);
|
||||
router.get('/wiki', showWiki);
|
||||
router.get('/wiki', (req, res) => res.redirect(301, '/wiki/en/'));
|
||||
|
||||
app.use(router);
|
||||
|
||||
function showWiki(req, res) {
|
||||
res.render('wiki/show', { title: 'Wiki | Free Code Camp' });
|
||||
res.render(
|
||||
'wiki/show',
|
||||
{
|
||||
title: 'Wiki | Free Code Camp',
|
||||
path: req.path.replace(/^\/wiki/, '')
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -2,6 +2,10 @@ extends ../layout-wide
|
||||
block content
|
||||
iframe#wikiFrame(frameborder='no')
|
||||
script.
|
||||
var lang = window.location.toString().match(/\/\w{2}\//);
|
||||
lang = (lang) ? lang[0] : '/en/';
|
||||
$('#wikiFrame').attr('src','//freecodecamp.github.io/wiki' + lang);
|
||||
var requestedPath = !{JSON.stringify(path) || ''};
|
||||
var lang = window.location.toString().match(/\/\w{2}\//);
|
||||
lang = (lang) ? lang[0] : '/en/';
|
||||
$('#wikiFrame').attr(
|
||||
'src',
|
||||
'//freecodecamp.github.io/wiki' + (requestedPath ? requestedPath : lang)
|
||||
);
|
||||
|
Reference in New Issue
Block a user