-
Notifications
You must be signed in to change notification settings - Fork 67
/
Copy path[id].js
42 lines (35 loc) · 818 Bytes
/
[id].js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { supabase } from "../utils/supabase";
const LessonDetails = ({ lesson }) => {
console.log({ lesson });
return (
<div className="w-full max-w-3xl mx-auto py-16 px-8">
<h1 className="text-3xl mb-6">{lesson.title}</h1>
<p>{lesson.description}</p>
</div>
);
};
export const getStaticPaths = async () => {
const { data: lessons } = await supabase.from("lesson").select("id");
const paths = lessons.map(({ id }) => ({
params: {
id: id.toString(),
},
}));
return {
paths,
fallback: false,
};
};
export const getStaticProps = async ({ params: { id } }) => {
const { data: lesson } = await supabase
.from("lesson")
.select("*")
.eq("id", id)
.single();
return {
props: {
lesson,
},
};
};
export default LessonDetails;