htmlburger / carbon-fields-yoast

Helper library that allows developers to choose which fields from Carbon Fields to include in the Yoast readability score meter
9 stars 6 forks source link

Does not work with new Carbon-Guttenberg blocks #5

Open Boryenko opened 4 years ago

Boryenko commented 4 years ago

image image No errors in console connected with it

marktiddy commented 1 month ago

I've just discovered this issue this morning and from the Yoast documentation have put this together which I've put in admin.js instead of the content recommend by this plugin. You can actually just enqueue some admin Javascript yourself and remove the plugin completely with this solution.

This code is my fix. Please note that I give every Carbon Field Gutenberg block wrapper a class of .cf-blocks which is what I've used to grab all the content and feed it into Yoast.

`/ global YoastSEO /

class MyCustomDataPlugin { constructor() { // Ensure YoastSEO.js is present and can access the necessary features. if ( typeof YoastSEO === "undefined" || typeof YoastSEO.analysis === "undefined" || typeof YoastSEO.analysis.worker === "undefined" ) { return; }

YoastSEO.app.registerPlugin("MyCustomDataPlugin", { status: "ready" });

this.registerModifications();

}

/**

/**

Developer documentation from Yoast this was based on: https://developer.yoast.com/customization/yoast-seo/adding-custom-data-analysis/