@@ -28,9 +28,11 @@ type Props = {
2828
2929export default function ReadmeBox ( { packageName, githubUrl, isTemplate, loader = false } : Props ) {
3030 const { data, error, isLoading } = useSWR (
31- isTemplate
32- ? `${ githubUrl ?. replace ( 'github.com/' , 'raw.githubusercontent.com/' ) } /HEAD/README.md`
33- : `https://unpkg.com/${ packageName } /README.md` ,
31+ packageName
32+ ? isTemplate
33+ ? `${ githubUrl ?. replace ( 'github.com/' , 'raw.githubusercontent.com/' ) } /HEAD/README.md`
34+ : `https://unpkg.com/${ packageName } /README.md`
35+ : null ,
3436 ( url : string ) =>
3537 fetch ( url ) . then ( res => {
3638 if ( res . status === 404 ) {
@@ -46,11 +48,7 @@ export default function ReadmeBox({ packageName, githubUrl, isTemplate, loader =
4648 }
4749 ) ;
4850
49- if ( ! githubUrl || ! packageName ) {
50- return null ;
51- }
52-
53- const readmeFallbackContent = getReadmeFallbackContent ( data , isLoading , error ) ;
51+ const readmeFallbackContent = getReadmeFallbackContent ( data , isLoading || loader , error ) ;
5452
5553 return (
5654 < View
@@ -61,7 +59,7 @@ export default function ReadmeBox({ packageName, githubUrl, isTemplate, loader =
6159 < P > Readme</ P >
6260 </ View >
6361 < View style = { tw `p-4 pt-3 font-light` } >
64- { ! data && readmeFallbackContent ? (
62+ { ( ! data && readmeFallbackContent ) || ! githubUrl ? (
6563 < View style = { tw `gap-4 py-6` } >
6664 { isLoading && < ThreeDotsLoader /> }
6765 < P style = { tw `text-center` } > { readmeFallbackContent } </ P >
0 commit comments