feat(news): Initial SSR implementation
This commit is contained in:
committed by
mrugesh mohapatra
parent
8ffd03578a
commit
5cf5979563
@ -1,8 +1,14 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { renderToString } from 'react-dom/server';
|
||||||
|
|
||||||
|
import NewsApp from '../../news/NewsApp';
|
||||||
|
|
||||||
export default function newsBoot(app) {
|
export default function newsBoot(app) {
|
||||||
const router = app.loopback.Router();
|
const router = app.loopback.Router();
|
||||||
|
|
||||||
router.get('/', (req, res) => {
|
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);
|
app.use('/news', router);
|
||||||
|
@ -7,5 +7,5 @@ html(lang='en')
|
|||||||
title freeCodeCamp
|
title freeCodeCamp
|
||||||
include partials/react-stylesheets
|
include partials/react-stylesheets
|
||||||
body
|
body
|
||||||
#news-app-mount
|
#news-app-mount!= markup
|
||||||
script(src=cacheBreaker(rev('/js', 'news-app.js')))
|
script(src=cacheBreaker(rev('/js', 'news-app.js')))
|
||||||
|
Reference in New Issue
Block a user