Browse Source

🔧 Refactor code for better readability

📦 Imported __posts and necessary dependencies
🧩 Transformed __posts data for main demo
📚 Set up categories and authors
🚀 Ready to showcase the main demo!
main
John Doe 1 year ago
parent
commit
faa8f45985
  1. 20
      src/data/posts.ts

20
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 };
Loading…
Cancel
Save