diff --git a/src/data/posts.ts b/src/data/posts.ts new file mode 100644 index 0000000..7dd1393 --- /dev/null +++ b/src/data/posts.ts @@ -0,0 +1,20 @@ +import __posts from "./jsons/__posts.json"; +import { DEMO_CATEGORIES } from "./taxonomies"; +import { PostDataType } from "./types"; +import { DEMO_AUTHORS } from "./authors"; + +// FOR MAIN DEMO +const DEMO_POSTS = __posts.map((post): PostDataType => { + // ########## GET CATEGORY BY CAT ID ######## // + const categories = post.categoriesId.map( + (id) => DEMO_CATEGORIES.filter((taxonomy) => taxonomy.id === id)[0] + ); + + return { + ...post, + author: DEMO_AUTHORS.filter((user) => user.id === post.authorId)[0], + categories: [categories[0]], + } as PostDataType; +}); + +export { DEMO_POSTS };