41 lines
1.1 KiB
TypeScript
41 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 { DSQL_TBENME_BLOG_POSTS, PagePropsType } from "@/types";
|
|
import { APIResponseObject } from "@moduletrace/datasquirel/dist/package-shared/types";
|
|
|
|
export default function BlogPage() {
|
|
return (
|
|
<Layout>
|
|
<Main />
|
|
</Layout>
|
|
);
|
|
}
|
|
|
|
export const getStaticProps: GetStaticProps<PagePropsType> = async (ctx) => {
|
|
const blogPosts: APIResponseObject<DSQL_TBENME_BLOG_POSTS[]> =
|
|
await datasquirel.crud<DSQL_TBENME_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,
|
|
};
|
|
};
|