File tree Expand file tree Collapse file tree 1 file changed +29
-29
lines changed Expand file tree Collapse file tree 1 file changed +29
-29
lines changed Original file line number Diff line number Diff line change @@ -326,35 +326,7 @@ function SingleBlog({ singleBlog }) {
326
326
327
327
// get the blog from database using server side rendering
328
328
329
- export async function getServerSideProps ( { params } ) {
330
- const res = await axios ( `${ baserUrl } /api/blogs/${ params . slug } ` ) ;
331
- const singleBlog = res . data ;
332
-
333
- return {
334
- props : {
335
- singleBlog,
336
- } ,
337
- revalidate : 10 ,
338
- } ;
339
- }
340
-
341
- // export async function getStaticPaths() {
342
- // const res = await axios(`${baserUrl}/api/blogs/allblogs`);
343
- // const data = res.data.blogs;
344
-
345
- // const paths = data.map((blog) => ({
346
- // params: {
347
- // slug: blog?.slug,
348
- // },
349
- // }));
350
-
351
- // return {
352
- // paths,
353
- // fallback: false,
354
- // };
355
- // }
356
-
357
- // export async function getStaticProps({ params }) {
329
+ // export async function getServerSideProps({ params }) {
358
330
// const res = await axios(`${baserUrl}/api/blogs/${params.slug}`);
359
331
// const singleBlog = res.data;
360
332
@@ -366,4 +338,32 @@ export async function getServerSideProps({ params }) {
366
338
// };
367
339
// }
368
340
341
+ export async function getStaticPaths ( ) {
342
+ const res = await axios ( `${ baserUrl } /api/blogs/allblogs` ) ;
343
+ const data = res . data . blogs ;
344
+
345
+ const paths = data . map ( ( blog ) => ( {
346
+ params : {
347
+ slug : blog ?. slug ,
348
+ } ,
349
+ } ) ) ;
350
+
351
+ return {
352
+ paths,
353
+ fallback : false ,
354
+ } ;
355
+ }
356
+
357
+ export async function getStaticProps ( { params } ) {
358
+ const res = await axios ( `${ baserUrl } /api/blogs/${ params . slug } ` ) ;
359
+ const singleBlog = res . data ;
360
+
361
+ return {
362
+ props : {
363
+ singleBlog,
364
+ } ,
365
+ revalidate : 10 ,
366
+ } ;
367
+ }
368
+
369
369
export default SingleBlog ;
You can’t perform that action at this time.
0 commit comments