Bugfix
This commit is contained in:
parent
a6a3b8056d
commit
a3732103bf
@ -1,5 +1,5 @@
|
|||||||
# Set Node.js version
|
# Set Node.js version
|
||||||
FROM node:bookworm
|
FROM node:alpine
|
||||||
|
|
||||||
RUN mkdir /app
|
RUN mkdir /app
|
||||||
|
|
||||||
@ -8,8 +8,8 @@ WORKDIR /app
|
|||||||
|
|
||||||
# Copy package.json and package-lock.json
|
# Copy package.json and package-lock.json
|
||||||
|
|
||||||
RUN apt update
|
RUN apk update
|
||||||
RUN apt install nano -y
|
RUN apk add nano
|
||||||
|
|
||||||
RUN touch /root/.bashrc
|
RUN touch /root/.bashrc
|
||||||
RUN echo 'alias ll="ls -laF"' > /root/.bashrc
|
RUN echo 'alias ll="ls -laF"' > /root/.bashrc
|
||||||
|
@ -56,20 +56,24 @@ export default async function BlogIndex({
|
|||||||
}: {
|
}: {
|
||||||
params: any;
|
params: any;
|
||||||
}) {
|
}) {
|
||||||
//* Data fetching
|
try {
|
||||||
const post = await getPost({ single: single });
|
//* Data fetching
|
||||||
|
const post = await getPost({ single: single });
|
||||||
|
|
||||||
if (!post) {
|
if (!post) {
|
||||||
|
return redirect("/blog");
|
||||||
|
}
|
||||||
|
|
||||||
|
//* Main Function Return
|
||||||
|
/////////////////////////////////////////////
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Main post={post} />
|
||||||
|
</React.Fragment>
|
||||||
|
);
|
||||||
|
|
||||||
|
/** ********************************************** */
|
||||||
|
} catch (error) {
|
||||||
return redirect("/blog");
|
return redirect("/blog");
|
||||||
}
|
}
|
||||||
|
|
||||||
//* Main Function Return
|
|
||||||
/////////////////////////////////////////////
|
|
||||||
return (
|
|
||||||
<React.Fragment>
|
|
||||||
<Main post={post} />
|
|
||||||
</React.Fragment>
|
|
||||||
);
|
|
||||||
|
|
||||||
/** ********************************************** */
|
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Metadata } from "next";
|
import { Metadata } from "next";
|
||||||
const datasquirel = require("datasquirel");
|
const datasquirel = require("datasquirel");
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
import { headers, cookies } from "next/headers";
|
|
||||||
|
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
//* Metadata
|
//* Metadata
|
||||||
@ -26,52 +25,56 @@ export const revalidate = 3600;
|
|||||||
* ==============================================================================
|
* ==============================================================================
|
||||||
*/
|
*/
|
||||||
export default async function BlogIndex() {
|
export default async function BlogIndex() {
|
||||||
//* Data fetching
|
try {
|
||||||
/////////////////////////////////////////////
|
//* Data fetching
|
||||||
const postsResponse = await datasquirel.get({
|
/////////////////////////////////////////////
|
||||||
key: process.env.DATASQUIREL_API_KEY,
|
const postsResponse = await datasquirel.get({
|
||||||
db: process.env.DB_NAME,
|
key: process.env.DATASQUIREL_API_KEY,
|
||||||
query: "select title,slug,excerpt,date_created from blog_posts limit 10",
|
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
|
//* Main Function Return
|
||||||
/////////////////////////////////////////////
|
/////////////////////////////////////////////
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<div className="flex flex-col items-start max-w-6xl w-full">
|
<div className="flex flex-col items-start max-w-6xl w-full">
|
||||||
<h1 className="mb-8">My Blog</h1>
|
<h1 className="mb-8">My Blog</h1>
|
||||||
<div className="flex flex-col items-start w-full gap-4">
|
<div className="flex flex-col items-start w-full gap-4">
|
||||||
{posts.map(
|
{posts.map(
|
||||||
(
|
(
|
||||||
post: {
|
post: {
|
||||||
slug: string;
|
slug: string;
|
||||||
title: string;
|
title: string;
|
||||||
excerpt: string;
|
excerpt: string;
|
||||||
date_created: string;
|
date_created: string;
|
||||||
},
|
},
|
||||||
index: number
|
index: number
|
||||||
) => (
|
) => (
|
||||||
<a
|
<a
|
||||||
key={index}
|
key={index}
|
||||||
href={`/blog/${post.slug}`}
|
href={`/blog/${post.slug}`}
|
||||||
className="flex flex-col items-start gap-2 w-full hover:bg-blue-600 border border-solid border-white/20 p-8 transition-all bg-primary/10"
|
className="flex flex-col items-start gap-2 w-full hover:bg-blue-600 border border-solid border-white/20 p-8 transition-all bg-primary/10"
|
||||||
>
|
>
|
||||||
<h2 className="m-0">{post.title}</h2>
|
<h2 className="m-0">{post.title}</h2>
|
||||||
<span className="opacity-80">
|
<span className="opacity-80">
|
||||||
{post.excerpt}
|
{post.excerpt}
|
||||||
</span>
|
</span>
|
||||||
<span className="text-sm opacity-50">
|
<span className="text-sm opacity-50">
|
||||||
{post.date_created.substring(0, 24)}
|
{post.date_created.substring(0, 24)}
|
||||||
</span>
|
</span>
|
||||||
</a>
|
</a>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</React.Fragment>
|
||||||
</React.Fragment>
|
);
|
||||||
);
|
|
||||||
|
|
||||||
/** ********************************************** */
|
/** ********************************************** */
|
||||||
|
} catch (error) {
|
||||||
|
return redirect("/");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user