File tree Expand file tree Collapse file tree 1 file changed +9
-20
lines changed
Expand file tree Collapse file tree 1 file changed +9
-20
lines changed Original file line number Diff line number Diff line change 1- export { default } from '@/components/pages/whats-new/RawRelease'
2- import { fetchWithCache } from '@/utils/fetchData' ;
3-
4- export async function getStaticProps ( { params } ) {
5- const { tag } = params ;
6- const data = await fetchWithCache (
7- 'releases' ,
8- 'https://api.github.com/repos/voxa-org/voxa/releases'
9- ) ;
10-
11- return {
12- props : {
13- release : data . find ( ( release ) => release . tag_name === tag ) || null ,
14- } ,
15- } ;
16- }
17-
181export async function getStaticPaths ( ) {
192 const data = await fetchWithCache (
203 'releases' ,
214 'https://api.github.com/repos/voxa-org/voxa/releases'
225 ) ;
23- const paths = data . map ( ( release ) => ( { params : { tag : release . tag_name } } ) ) ;
24-
6+ let paths = [ ] ;
7+ if ( Array . isArray ( data ) ) {
8+ paths = data . map ( ( release ) => ( { params : { tag : release . tag_name } } ) ) ;
9+ } else {
10+ console . error ( "expected an array of releases, got:" , data ) ;
11+ // optionally, you can throw an error or return empty paths:
12+ // throw new Error("github releases api did not return an array");
13+ }
2514 return {
2615 paths,
2716 fallback : false ,
2817 } ;
29- }
18+ }
You can’t perform that action at this time.
0 commit comments