'use strict';

/**
 * page controller
 */

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::page.page', ({ strapi }) => ({
    async find(ctx) {
        const { data, meta } = await super.find(ctx);
        const modifiedData = data.map(entry => {
            const components = Array.isArray(entry === null || entry === void 0 ? void 0 : entry.components)
                ? entry.components.map(component => {
                    var _a;
                    const { __component, ...rest } = component;
                    const componentName = (_a = __component === null || __component === void 0 ? void 0 : __component.split) === null || _a === void 0 ? void 0 : _a.call(__component, '.')[1];
                    return {
                        component: componentName,
                        ...rest,
                    };
                })
                : [];
            return {
                ...entry,
                components
            };
        });
        return { data: modifiedData, meta };
    }
}));

