23 lines
523 B
JavaScript
Raw Normal View History

2019-10-24 14:07:41 +02:00
'use strict';
2019-12-09 14:01:11 +01:00
const { get } = require('lodash');
2019-10-24 14:07:41 +02:00
/**
* 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)
2019-10-24 14:07:41 +02:00
);
}
2019-12-09 14:01:11 +01:00
const isComponent = (def, key) => {
const type = get(def, ['attributes', key, 'type']);
return ['component', 'dynamiczone'].includes(type);
};
2019-10-24 14:07:41 +02:00
module.exports = {
getComponentAttributes,
isComponent,
2019-10-24 14:07:41 +02:00
};