mirror of
https://github.com/strapi/strapi.git
synced 2025-08-02 13:58:18 +00:00
23 lines
523 B
JavaScript
23 lines
523 B
JavaScript
'use strict';
|
|
|
|
const { get } = require('lodash');
|
|
|
|
/**
|
|
* Returns the attribute keys of the component related attributes
|
|
*/
|
|
function getComponentAttributes(definition) {
|
|
return Object.keys(definition.attributes).filter(key =>
|
|
['component', 'dynamiczone'].includes(definition.attributes[key].type)
|
|
);
|
|
}
|
|
|
|
const isComponent = (def, key) => {
|
|
const type = get(def, ['attributes', key, 'type']);
|
|
return ['component', 'dynamiczone'].includes(type);
|
|
};
|
|
|
|
module.exports = {
|
|
getComponentAttributes,
|
|
isComponent,
|
|
};
|