Skip to content
This repository has been archived by the owner on Mar 27, 2018. It is now read-only.

Commit

Permalink
feat(hn): loads extra json initial state from window
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Wensink committed Aug 14, 2017
1 parent 69a22db commit 8f4e750
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/site.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { Site } from 'hn';
import getNested from 'get-nested';

const site = new Site({url: 'http://localhost:8088'});
const site = new Site({ url: '' });

if(typeof window !== 'undefined') {
if(getNested(() => window.__NEXT_DATA__.HN_DATA)) {
site.data = window.__NEXT_DATA__.HN_DATA;
site.url = window.__NEXT_DATA__.HN_URL || site.url;
site.pagesLoading = {
[window.location.pathname]: Promise.resolve(),
};
}

export default site;

0 comments on commit 8f4e750

Please sign in to comment.