new-personal-site/pages/blog/index.tsx
2026-02-13 19:04:07 +01:00

42 lines
1.1 KiB
TypeScript

import Layout from "@/layouts/main";
import Main from "@/components/pages/blog";
import { GetStaticProps } from "next";
import datasquirel from "@moduletrace/datasquirel";
import { PagePropsType } from "@/types";
import { APIResponseObject } from "@moduletrace/datasquirel/dist/package-shared/types";
import { DSQL_TBEN_ME_BLOG_POSTS } from "@/types/dsql";
export default function BlogPage() {
return (
<Layout>
<Main />
</Layout>
);
}
export const getStaticProps: GetStaticProps<PagePropsType> = async (ctx) => {
const blogPosts: APIResponseObject<DSQL_TBEN_ME_BLOG_POSTS> =
await datasquirel.crud<DSQL_TBEN_ME_BLOG_POSTS>({
action: "get",
table: "blog_posts",
query: {
order: {
field: "id",
strategy: "DESC",
},
query: {
published: {
value: "1",
},
},
},
});
return {
props: {
blogPosts: blogPosts.payload || null,
},
revalidate: 3600,
};
};