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 = {
21
21
} ,
22
22
"gatsby-plugin-styled-components" ,
23
23
"gatsby-plugin-react-helmet" ,
24
+ "custom-bytes-subscriber-count-plugin" ,
24
25
{
25
26
resolve : "gatsby-source-filesystem" ,
26
27
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