feat(news): Initial SSR implementation

This commit is contained in:
Stuart Taylor
2018-07-31 16:58:04 +01:00
committed by mrugesh mohapatra
parent 8ffd03578a
commit 5cf5979563
2 changed files with 8 additions and 2 deletions

View File

@ -1,8 +1,14 @@
import React from 'react';
import { renderToString } from 'react-dom/server';
import NewsApp from '../../news/NewsApp';
export default function newsBoot(app) {
const router = app.loopback.Router();
router.get('/', (req, res) => {
res.render('layout-news', {title: 'Hello News?'});
const markup = renderToString(<NewsApp />);
return res.render('layout-news', {title: 'Hello News?', markup});
});
app.use('/news', router);

View File

@ -7,5 +7,5 @@ html(lang='en')
title freeCodeCamp
include partials/react-stylesheets
body
#news-app-mount
#news-app-mount!= markup
script(src=cacheBreaker(rev('/js', 'news-app.js')))