Giter Site home page Giter Site logo

Comments (5)

williamjulianvicary avatar williamjulianvicary commented on May 31, 2024 1

As a proof of concept, I think this is reasonably trivial, the below added here ContentBlocksResolver.php:56 and the reusable blocks seem to resolve as expected. I've not done extensive testing yet, but the GQL response looks good and replacing a few components in active pages seems to work as anticipated. Given it's just replacing the core/block with the content of the rendered reusable block(s), it should be good to go with something as trivial as this?

Let me know if you'd like a PR and I'll wrap up some tests and get that added

        // Resolve reusable blocks
        $new_parsed_blocks = [];
        foreach ($parsed_blocks as $block) {
            if ($block['blockName'] === 'core/block' && $block['attrs']['ref']) {
                $reusable_blocks = parse_blocks( get_post( $block['attrs']['ref'] )->post_content );
                if (!empty($reusable_blocks)) {
                    array_push($new_parsed_blocks, ...$reusable_blocks);
                }
            } else {
                $new_parsed_blocks[] = $block;
            }
        }

        $parsed_blocks = $new_parsed_blocks;

from wp-graphql-content-blocks.

theodesp avatar theodesp commented on May 31, 2024

@williamjulianvicary Thanks. Sure go ahead. We will review the code with the team.

from wp-graphql-content-blocks.

theodesp avatar theodesp commented on May 31, 2024

@williamjulianvicary

We do require a one time CLA for people adding contributions:

If you could review and fill in this form:

https://docs.google.com/forms/d/1O5bQCRHSSJmrOCAzWYJBIHjBNnVRg2PboSvuB2NfAI4/edit

Then we will send you a DocuSign to complete.

Then we can review your PRs.

Thank you.

from wp-graphql-content-blocks.

williamjulianvicary avatar williamjulianvicary commented on May 31, 2024

That's complete - let me know if you have any questions

from wp-graphql-content-blocks.

theodesp avatar theodesp commented on May 31, 2024

Merged #104

from wp-graphql-content-blocks.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.