* spelling: accidentally * spelling: announce * spelling: assembly * spelling: avoid * spelling: backend * spelling: because * spelling: claimed * spelling: candidate * spelling: certification * spelling: certified * spelling: challenge * spelling: circular * spelling: it isn't * spelling: coins * spelling: combination * spelling: compliant * spelling: containers * spelling: concise * spelling: deprecated * spelling: development * spelling: donor * spelling: error * spelling: everything * spelling: exceed * spelling: exist * spelling: falsy * spelling: faulty * spelling: forward * spelling: handle * spelling: indicates * spelling: initial * spelling: integers * spelling: issealed * spelling: javascript * spelling: length * spelling: maximum * spelling: minimum * spelling: mutable * spelling: notifier * spelling: coordinate * spelling: passport * spelling: perform * spelling: permuter * spelling: placeholder * spelling: progressively * spelling: semantic * spelling: submission * spelling: submit * spelling: translations * spelling: turquoise * spelling: visualization * spelling: without * spelling: registration * spelling: representation
22 lines
633 B
JavaScript
22 lines
633 B
JavaScript
exports.onCreateNode = function remarkNodeIdentityOnCreateNode(
|
|
{ node, reporter, actions },
|
|
{ predicate, identity }
|
|
) {
|
|
if (typeof predicate !== 'function') {
|
|
reporter.panic(
|
|
'Please supply a predicate function to `gatsby-plugin-identity`'
|
|
);
|
|
}
|
|
if (typeof identity !== 'string' || identity.length === 0) {
|
|
reporter.panic(
|
|
'`gatsby-plugin-identity` requires an identify string to add to nodes ' +
|
|
'that match the predicate'
|
|
);
|
|
}
|
|
const { createNodeField } = actions;
|
|
if (predicate(node)) {
|
|
createNodeField({ node, name: 'nodeIdentity', value: identity });
|
|
}
|
|
return node;
|
|
};
|