Skip to content

Commit aa65dce

Browse files
committed
work
1 parent 076a2e6 commit aa65dce

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

pages/sparkle/[tag].js

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,18 @@
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-
181
export 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+
}

0 commit comments

Comments
 (0)