-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- See veliovgroup/spiderable-middleware#4 , thanks to @nicooprat
- Loading branch information
1 parent
bf7b73d
commit 742b783
Showing
4 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
Detect request from Prerendering engine in Meteor.js | ||
====== | ||
|
||
Prerendering engine will set `window.IS_PRERENDERING` global variable to `true`. As in Meteor everything should be reactive, let's bound it with `ReactiveVar`: | ||
|
||
```js | ||
const IS_PRERENDERING = new ReactiveVar(false); | ||
Object.defineProperty(window, 'IS_PRERENDERING', { | ||
set(val) { | ||
IS_PRERENDERING.set(val); | ||
}, | ||
get() { | ||
return IS_PRERENDERING.get(); | ||
} | ||
}); | ||
|
||
// Make globally available Blaze helper, | ||
// Feel free to omit this line in case if you're not using Blaze | ||
// or going to handle logic in JavaScript part | ||
Template.registerHelper('IS_PRERENDERING', () => IS_PRERENDERING.get()); | ||
``` | ||
|
||
__Note__: `window.IS_PRERENDERING` might be `undefined` on initial page load, and may change during runtime. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
Detect request from Prerendering engine during runtime | ||
====== | ||
|
||
Prerendering engine will set `window.IS_PRERENDERING` global variable to `true`. Detecting request from prerendering engine might be as easy as: | ||
```js | ||
if (window.IS_PRERENDERING) { | ||
// This request is coming from Prerendering engine | ||
} | ||
``` | ||
|
||
__Note__: `window.IS_PRERENDERING` might be `undefined` on initial page load, and may change during runtime. That's why we recommend to pre-define a setter for `IS_PRERENDERING`: | ||
```js | ||
let _is_prerendering = false; | ||
Object.defineProperty(window, 'IS_PRERENDERING', { | ||
set(val) { | ||
_is_prerendering = val; | ||
if (_is_prerendering === true) { | ||
// This request is coming from Prerendering engine | ||
} | ||
}, | ||
get() { | ||
return _is_prerendering; | ||
} | ||
}); | ||
``` |