first
This commit is contained in:
commit
8538ab969a
434 changed files with 44051 additions and 0 deletions
25
apps/web/modules/marketing/blog/utils/lib/posts.ts
Normal file
25
apps/web/modules/marketing/blog/utils/lib/posts.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import type { Post } from "@marketing/blog/types";
|
||||
import { allPosts } from "content-collections";
|
||||
|
||||
export async function getAllPosts(): Promise<Post[]> {
|
||||
// ... add a custom loader here for your posts and map it to the post schema
|
||||
|
||||
return Promise.resolve(allPosts);
|
||||
}
|
||||
|
||||
export async function getPostBySlug(
|
||||
slug: string,
|
||||
options?: {
|
||||
locale?: string;
|
||||
},
|
||||
): Promise<Post | null> {
|
||||
// ... add a custom loader here for your posts and map it to the post schema
|
||||
|
||||
return Promise.resolve(
|
||||
allPosts.find(
|
||||
(post) =>
|
||||
post.path === slug &&
|
||||
(!options?.locale || post.locale === options.locale),
|
||||
) ?? null,
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue