Skip to content

Subscribe to Gutenberg's data API#9080

Merged
danielFangstrom merged 25 commits intotrunkfrom
stories/9019-gutenberg-data-api-subscription
Mar 16, 2018
Merged

Subscribe to Gutenberg's data API#9080
danielFangstrom merged 25 commits intotrunkfrom
stories/9019-gutenberg-data-api-subscription

Conversation

@IreneStr
Copy link
Copy Markdown
Contributor

@IreneStr IreneStr commented Mar 1, 2018

Summary

This PR can be summarized in the following changelog entry:

  • Makes it possible to use the content, slug, title and excerpt from Gutenberg posts in the SEO and readability analysis.

Relevant technical choices:

  • This is a prototype. Architecture and naming might change in the future.

Test instructions

This PR can be tested by following these steps:

  • Create a post in Gutenberg.
  • Make sure all SEO and readability assessments that use the content, slug and/or title work correctly.
  • Also make sure all assessments still work correctly in the classic editor.
  • Write an excerpt in the document sidebar. Use the %%excerpt%% and %%title%% replace var in the snippet preview.

Important: Currently, Gutenberg only saves a slug after publishing the post.

Quality assurance

  • I have tested this code to the best of my abilities
  • I have added unittests to verify the code works as intended

Fixes #9019

if( ! isEmpty( getData() ) ) {
gutenbergData = getData();
}
let text = this.getText();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency: do not put this in a variable either.

}
}
}
for( let dataPoint in gutenbergData ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the other way comparison needed? They always include the same keys, right?
So if you check a.data !== b.data then you no longer need to check b.data !== a.data.

*/
const refreshYoastSEO = () => {
let gutenbergData = collectGutenbergData();
data = updateData( data, gutenbergData );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to me that you could do the isDirty check here and then you could overwrite data only if needed. That way you do not need a separate updateDate function.

@danielFangstrom
Copy link
Copy Markdown
Contributor

CR 👍

@danielFangstrom
Copy link
Copy Markdown
Contributor

ACC 👍

@danielFangstrom danielFangstrom merged commit c74ff63 into trunk Mar 16, 2018
@danielFangstrom danielFangstrom deleted the stories/9019-gutenberg-data-api-subscription branch March 16, 2018 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants