import fetchPublicData from "./fetchPublicData"; import singlePosts from "./transformers/singlePosts"; import categories from "./transformers/categories"; import archives from "./transformers/archives"; import homes from "./transformers/homes"; import notFound from "./transformers/notFound"; import LoggerService from "./helpers/LoggerService"; import hasTemplate, { Templates } from "./helpers/hasTemplate"; const getPagePlugins = async () => { LoggerService.warning("Fetching data from rest api...\n"); const responses = await fetchPublicData(); LoggerService.success("Successfully fetched data from rest api!\n"); const singlePostPagePlugins = hasTemplate(Templates.SINGLE_POST) ? singlePosts(responses) : []; const categoryPagePlugins = hasTemplate(Templates.CATEGORY) ? categories(responses) : []; const archivePagePlugins = hasTemplate(Templates.ARCHIVE) ? archives(responses) : []; const homePagePlugins = hasTemplate(Templates.HOME) ? homes(responses) : []; const notFoundPlugins = hasTemplate(Templates.NOT_FOUND) ? notFound(responses) : []; return [ ...singlePostPagePlugins, ...categoryPagePlugins, ...archivePagePlugins, ...homePagePlugins, ...notFoundPlugins ]; }; export default getPagePlugins;