diff --git a/Dockerfile b/Dockerfile index cf6a07a..3d9a436 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # Set Node.js version -FROM node:bookworm +FROM node:alpine RUN mkdir /app @@ -8,8 +8,8 @@ WORKDIR /app # Copy package.json and package-lock.json -RUN apt update -RUN apt install nano -y +RUN apk update +RUN apk add nano RUN touch /root/.bashrc RUN echo 'alias ll="ls -laF"' > /root/.bashrc diff --git a/app/blog/[single]/page.tsx b/app/blog/[single]/page.tsx index f5c8d14..de6455e 100644 --- a/app/blog/[single]/page.tsx +++ b/app/blog/[single]/page.tsx @@ -56,20 +56,24 @@ export default async function BlogIndex({ }: { params: any; }) { - //* Data fetching - const post = await getPost({ single: single }); + try { + //* Data fetching + const post = await getPost({ single: single }); - if (!post) { + if (!post) { + return redirect("/blog"); + } + + //* Main Function Return + ///////////////////////////////////////////// + return ( + +
+ + ); + + /** ********************************************** */ + } catch (error) { return redirect("/blog"); } - - //* Main Function Return - ///////////////////////////////////////////// - return ( - -
- - ); - - /** ********************************************** */ } diff --git a/app/blog/page.tsx b/app/blog/page.tsx index 32b848e..f2a1a5a 100644 --- a/app/blog/page.tsx +++ b/app/blog/page.tsx @@ -4,8 +4,7 @@ import React from "react"; import { Metadata } from "next"; const datasquirel = require("datasquirel"); - -import { headers, cookies } from "next/headers"; +import { redirect } from "next/navigation"; ///////////////////////////////////////////// //* Metadata @@ -26,52 +25,56 @@ export const revalidate = 3600; * ============================================================================== */ export default async function BlogIndex() { - //* Data fetching - ///////////////////////////////////////////// - const postsResponse = await datasquirel.get({ - key: process.env.DATASQUIREL_API_KEY, - db: process.env.DB_NAME, - query: "select title,slug,excerpt,date_created from blog_posts limit 10", - }); + try { + //* Data fetching + ///////////////////////////////////////////// + const postsResponse = await datasquirel.get({ + key: process.env.DATASQUIREL_API_KEY, + db: process.env.DB_NAME, + query: "select title,slug,excerpt,date_created from blog_posts limit 10", + }); - const posts = postsResponse?.success ? postsResponse.payload : []; + const posts = postsResponse?.success ? postsResponse.payload : []; - //* Main Function Return - ///////////////////////////////////////////// - return ( - -
-

My Blog

-
- {posts.map( - ( - post: { - slug: string; - title: string; - excerpt: string; - date_created: string; - }, - index: number - ) => ( - -

{post.title}

- - {post.excerpt} - - - {post.date_created.substring(0, 24)} - -
- ) - )} + //* Main Function Return + ///////////////////////////////////////////// + return ( + +
+

My Blog

+
+ {posts.map( + ( + post: { + slug: string; + title: string; + excerpt: string; + date_created: string; + }, + index: number + ) => ( + +

{post.title}

+ + {post.excerpt} + + + {post.date_created.substring(0, 24)} + +
+ ) + )} +
-
- - ); + + ); - /** ********************************************** */ + /** ********************************************** */ + } catch (error) { + return redirect("/"); + } }