feat(plugin): add hotjar plugin

This commit is contained in:
ppoffice 2018-10-28 01:29:47 -04:00
parent d1bd500a14
commit 17fa6f339f
5 changed files with 30 additions and 3 deletions

View File

@ -1,4 +1,4 @@
Please make sure you took care of the following things before you submit this issue. Thank you! Please make sure you took care of the following things before you submit this issue. Thank you!
- [ ] I have set up and configured my blog according to [Hexo documentation](https://hexo.io/) and [Icarus Documentation](https://github.com/ppoffice/hexo-theme-icarus/wiki); - [ ] I have set up and configured my blog according to the [Hexo docs](https://hexo.io/) and the [Icarus docs](https://ppoffice.github.io/hexo-theme-icarus/);
- [ ] I have looked up the [Github Issues](https://github.com/ppoffice/hexo-theme-icarus/issues) and found no solutions to my problems. - [ ] I have looked up [Github issues](https://github.com/ppoffice/hexo-theme-icarus/issues) and found no solutions to my problems.

View File

@ -125,7 +125,10 @@ Please refer to the documentation for Icarus implementation details.
### :tada: Contribute ### :tada: Contribute
If you feel like to help us build a better Icarus, you can
:electric_plug: Write a plugin | :electric_plug: Write a plugin |
:black_nib: <a href="https://github.com/ppoffice/hexo-theme-icarus/new/site/source/_posts">Submit a tutorial</a> |
:triangular_flag_on_post: <a href="https://github.com/ppoffice/hexo-theme-icarus/issues/new">Report a bug</a> | :triangular_flag_on_post: <a href="https://github.com/ppoffice/hexo-theme-icarus/issues/new">Report a bug</a> |
:earth_asia: <a href="https://github.com/ppoffice/hexo-theme-icarus/tree/master/languages">Add a translation</a> :earth_asia: <a href="https://github.com/ppoffice/hexo-theme-icarus/tree/master/languages">Add a translation</a>

View File

@ -15,6 +15,9 @@ const descriptors = {
}; };
const is = (() => ({ const is = (() => ({
number(value) {
return typeof (value) === 'number';
},
string(value) { string(value) {
return typeof (value) === 'string'; return typeof (value) === 'string';
}, },

View File

@ -1,4 +1,4 @@
const { doc, type, defaultValue, required, requires } = require('../common/utils').descriptors; const { doc, type, defaultValue } = require('../common/utils').descriptors;
module.exports = { module.exports = {
[type]: 'object', [type]: 'object',
@ -45,5 +45,14 @@ module.exports = {
[doc]: 'Baidu Analytics tracking id', [doc]: 'Baidu Analytics tracking id',
[defaultValue]: null [defaultValue]: null
} }
},
hotjar: {
[type]: ['boolean', 'object'],
[doc]: 'Hotjar user feedback plugin (http://ppoffice.github.io/hexo-theme-icarus/2018/01/01/plugin/Analytics/#Hotjar)',
site_id: {
[type]: ['string', 'number'],
[doc]: 'Hotjar site id',
[defaultValue]: null
}
} }
}; };

12
layout/plugin/hotjar.ejs Normal file
View File

@ -0,0 +1,12 @@
<% if (head && get_config_from_obj(plugin, 'site_id')) { %>
<script>
(function(h,o,t,j,a,r){
h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
h._hjSettings={hjid:<%= get_config_from_obj(plugin, 'site_id') %>,hjsv:6};
a=o.getElementsByTagName('head')[0];
r=o.createElement('script');r.async=1;
r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
a.appendChild(r);
})(window,document,'https://static.hotjar.com/c/hotjar-','.js?sv=');
</script>
<% } %>