This commit is contained in:
2026-11-03 10:00:36 +01:00
parent 6326c2bb26
commit 8c280be7b8
8 changed files with 132 additions and 75 deletions
+31 -1
View File
@@ -4,7 +4,10 @@ import {
} from "@/db/types/db";
import { PagePropsType } from "@/src/types";
import BunMariaDB from "@moduletrace/bun-mariadb";
import { BunextPageServerFn } from "@moduletrace/bunext/types";
import {
BunextPageServerFn,
BunextPageSitemapFn,
} from "@moduletrace/bunext/types";
export const server: BunextPageServerFn<PagePropsType> = async (ctx) => {
const blog_post = await BunMariaDB.select<
@@ -38,3 +41,30 @@ export const server: BunextPageServerFn<PagePropsType> = async (ctx) => {
},
};
};
export const sitemap: BunextPageSitemapFn = async ({ route }) => {
const blog_post = await BunMariaDB.select<
BUN_MARIADB_DATASQUIREL_USER_2_TBENME_BLOG_POSTS,
(typeof BunMariaDBTables)[number]
>({
table: "blog_posts",
query: {
query: {
published: {
value: 1,
},
},
},
});
return (
blog_post.payload?.map((bp) => {
return {
path: `/blog/${bp.slug}`,
lastmod: bp.date_updated_code
? new Date(Number(bp.date_updated_code))
: undefined,
};
}) || []
);
};