File tree 1 file changed +16
-5
lines changed
packages/gatsby-recipes/src/providers/gatsby
1 file changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -102,16 +102,27 @@ const getNameForPlugin = node => {
102
102
const getDescriptionForPlugin = async name => {
103
103
const pkg = await readPackageJSON ( { } , name )
104
104
105
- return pkg ? pkg . description : null
105
+ return pkg ? .description || ``
106
106
}
107
107
108
+ const readmeCache = new Map ( )
109
+
108
110
const getReadmeForPlugin = async name => {
111
+ if ( readmeCache . has ( name ) ) {
112
+ return readmeCache . get ( name )
113
+ }
114
+
109
115
try {
110
- return fetch ( `https://unpkg.com/${ name } /README.md` )
116
+ const readme = await fetch ( `https://unpkg.com/${ name } /README.md` )
111
117
. then ( res => res . text ( ) )
112
118
. catch ( ( ) => null )
119
+
120
+ if ( readme ) {
121
+ readmeCache . set ( name , readme )
122
+ }
123
+ return readme || ``
113
124
} catch ( err ) {
114
- return null
125
+ return ``
115
126
}
116
127
}
117
128
@@ -244,8 +255,8 @@ const read = async ({ root }, id) => {
244
255
245
256
return {
246
257
id,
247
- description : description || null ,
248
- readme : readme ,
258
+ description,
259
+ readme,
249
260
...plugin ,
250
261
shadowedFiles,
251
262
shadowableFiles,
You can’t perform that action at this time.
0 commit comments