-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ppoffice
committed
Mar 8, 2020
1 parent
2a78c04
commit 826bb98
Showing
2 changed files
with
71 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": "/plugin/cnzz.json", | ||
"description": "CNZZ statistics\nhttps://www.umeng.com/web", | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": [ | ||
"string", | ||
"number" | ||
], | ||
"description": "CNZZ tracker id", | ||
"nullable": true | ||
}, | ||
"web_id": { | ||
"type": [ | ||
"string", | ||
"number" | ||
], | ||
"description": "CNZZ website id", | ||
"nullable": true | ||
} | ||
}, | ||
"required": [ | ||
"id", | ||
"web_id" | ||
] | ||
} |
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,43 @@ | ||
/** | ||
* CNZZ statistics plugin JSX component. | ||
* @module view/plugin/cnzz | ||
*/ | ||
const { Component } = require('inferno'); | ||
const { cacheComponent } = require('../../util/cache'); | ||
|
||
/** | ||
* CNZZ statistics plugin JSX component. | ||
* | ||
* @see https://developer.umeng.com/docs/67963/detail/68609 | ||
* @example | ||
* <Cnzz id="******" webId="******" /> | ||
*/ | ||
class Cnzz extends Component { | ||
render() { | ||
const { id, webId } = this.props; | ||
return <script src={`https://s9.cnzz.com/z_stat.php?id=${id}&web_id=${webId}`} async={true}></script>; | ||
} | ||
} | ||
|
||
/** | ||
* Cacheable CNZZ statistics plugin JSX component. | ||
* <p> | ||
* This class is supposed to be used in combination with the <code>locals</code> hexo filter | ||
* ({@link module:hexo/filter/locals}). | ||
* | ||
* @see module:util/cache.cacheComponent | ||
* @example | ||
* <Cnzz.Cacheable | ||
* head={false} | ||
* plugin={{ id: '******', web_id: '******' }} /> | ||
*/ | ||
module.exports = cacheComponent(Cnzz, 'plugin.cnzz', props => { | ||
const { head, plugin } = props; | ||
if (head || !plugin.id || !plugin.web_id) { | ||
return null; | ||
} | ||
return { | ||
id: plugin.id, | ||
webId: plugin.web_id | ||
}; | ||
}); |
826bb98
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ppoffice/hexo-theme-icarus#584