You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for server-side rendering Top Stories & Comments (#47)
* index.ejs: set base href to fix asset paths for SSR views
* package.json: add object-assign shim
* App.js: support prebooted HTML / hydration of content
* Adds hn-server-fetch using unofficial Firebase API
The official Firebase API (https://github.com/HackerNews/API) requires
multiple network
connections to be made in order to fetch the list of Top Stories
(indices) and then the
summary content of these stories. Directly requesting these resources
makes server-side
rendering cumbersome as it is slow and ultimately requires that you
maintain your own
cache to ensure full server renders are efficient.
To work around this problem, we can use one of the unofficial Hacker
News APIs, specifically
https://github.com/cheeaun/node-hnapi which directly returns the Top
Stories and can cache
responses for 10 minutes. In ReactHN, we can use the unofficial API for
a static server-side
render and then 'hydrate' this once our components have mounted to
display the real-time
experience.
The benefit of this is clients loading up the app that are on flakey
networks (or lie-fi)
can still get a fast render of content before the rest of our
JavaScript bundle is loaded.
* server.js: add support for SSR render of top stories and comments
* hn-server-fetch: add support for SSR nested comments
* hn-server-fetch: remove duplicate time indication
* Stories.js: display spinner for pages > 0
0 commit comments