updated page routes to server side render

This commit is contained in:
bill bittner 2018-02-21 13:58:25 -08:00
parent 224d057b9a
commit 73326a96d3
2 changed files with 15 additions and 6 deletions

View file

@ -1,9 +1,18 @@
const { site } = require('../config/speechConfig.js');
module.exports = (html, preloadedState) => { module.exports = (html, preloadedState) => {
// take the html and preloadedState and return the full page // take the html and preloadedState and return the full page
return ` return `
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#"> <html lang="en" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">
<head> <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1, user-scalable=no">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>${site.title}</title>
<link rel="stylesheet" href="/assets/css/reset.css" type="text/css">
<link rel="stylesheet" href="/assets/css/general.css" type="text/css">
<link rel="stylesheet" href="/assets/css/mediaQueries.css" type="text/css">
<!--google font--> <!--google font-->
<link href="https://fonts.googleapis.com/css?family=Roboto:300" rel="stylesheet"> <link href="https://fonts.googleapis.com/css?family=Roboto:300" rel="stylesheet">
</head> </head>

View file

@ -8,22 +8,22 @@ module.exports = (app) => {
}); });
// route to display login page // route to display login page
app.get('/login', (req, res) => { app.get('/login', (req, res) => {
res.status(200).render('index'); handleRender(req, res);
}); });
// route to show 'about' page // route to show 'about' page
app.get('/about', (req, res) => { app.get('/about', (req, res) => {
res.status(200).render('index'); handleRender(req, res);
}); });
// route to display a list of the trending images // route to display a list of the trending images
app.get('/trending', (req, res) => { app.get('/trending', (req, res) => {
res.status(301).redirect('/popular'); res.status(301).redirect('/popular');
}); });
app.get('/popular', ({ ip, originalUrl }, res) => { app.get('/popular', (req, res) => {
res.status(200).render('index'); handleRender(req, res);
}); });
// route to display a list of the trending images // route to display a list of the trending images
app.get('/new', ({ ip, originalUrl }, res) => { app.get('/new', (req, res) => {
res.status(200).render('index'); handleRender(req, res);
}); });
// route to send embedable video player (for twitter) // route to send embedable video player (for twitter)
app.get('/embed/:claimId/:name', ({ params }, res) => { app.get('/embed/:claimId/:name', ({ params }, res) => {