File tree Expand file tree Collapse file tree 3 files changed +30
-0
lines changed
plugins/custom-bytes-subscriber-count-plugin Expand file tree Collapse file tree 3 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ module.exports = {
2121 } ,
2222 "gatsby-plugin-styled-components" ,
2323 "gatsby-plugin-react-helmet" ,
24+ "custom-bytes-subscriber-count-plugin" ,
2425 {
2526 resolve : "gatsby-source-filesystem" ,
2627 options : {
Original file line number Diff line number Diff line change 1+ const fetch = require ( "node-fetch" ) ;
2+
3+ exports . sourceNodes = async ( {
4+ actions,
5+ createNodeId,
6+ createContentDigest,
7+ } ) => {
8+ try {
9+ const res = await fetch ( `https://bytes.dev/api/subcount` ) . then ( ( res ) =>
10+ res . json ( )
11+ ) ;
12+
13+ if ( res . error ) {
14+ throw res . error ;
15+ }
16+
17+ actions . createNode ( {
18+ subcount : res . subcount ,
19+ id : createNodeId ( `bytes-subcount` ) ,
20+ internal : {
21+ type : "bytes" ,
22+ contentDigest : createContentDigest ( { subcount : res . subcount } ) ,
23+ } ,
24+ } ) ;
25+ } catch ( e ) {
26+ console . log ( `Error in custom-bytes-subscriber-count-plugin` , e . message ) ;
27+ }
28+ } ;
Original file line number Diff line number Diff line change 1+ {}
You can’t perform that action at this time.
0 commit comments