Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make "10-dynamic-block" more dynamic #203

Closed
salcode opened this issue Mar 28, 2022 · 1 comment · Fixed by #216
Closed

Make "10-dynamic-block" more dynamic #203

salcode opened this issue Mar 28, 2022 · 1 comment · Fixed by #216

Comments

@salcode
Copy link
Contributor

salcode commented Mar 28, 2022

While 10-dynamic-block does use a dynamic block currently, it behaves in the same manner as a non-dynamic block.

It would be helpful to see the value provided by a block being dynamic (e.g. output a value that could be modified after the post was published).

salcode added a commit to salcode/gutenberg-examples that referenced this issue Mar 28, 2022
Add post count to dynamic block output to demonstrate how values can be
included in the block output that are updated without updating the post
itself.

Resolves WordPress#203
@ryanwelcher
Copy link
Contributor

Just to clarify, the current example doesn't behave in the same manner as a static block as its markup is never saved to the database. However, I completely understand what you're intending with this issue :)

I like the idea of adding a more fleshed-out example that demonstrates the benefits of a dynamic block:

  1. Being able to update the markup that is displayed without needing to add a deprecation and re-saving all instances of the block to see the updates.
  2. Querying the database for information that should not be saved as part of the block - such as latest tags, etc

From an examples point of view, the second point is much easier to demonstrate with working code as it doesn't require the same block with multiple sets of markup.

salcode added a commit to salcode/gutenberg-examples that referenced this issue Apr 29, 2022
Since this is a dynamic block, we can modify the markup at run time
(instead of saving the markup in the database to be displayed).

In this case, we are appending the Site Title of the blog to the message being
output.

If we were to go to
Settings > General
and modify the "Site Title" setting, the rendered output would change
(without our re-opening the post in Gutenberg).

See WordPress#203
salcode added a commit to salcode/gutenberg-examples that referenced this issue Apr 29, 2022
The Site Title is not modifiable within the block, but if we
were to go to
Settings > General
and modify the "Site Title" value.

When we reload the post in Gutenberg, the Site Title would be updated.

See WordPress#203
ryanwelcher pushed a commit that referenced this issue Jun 24, 2022
* Append blog Site Title to dynamic output

Since this is a dynamic block, we can modify the markup at run time
(instead of saving the markup in the database to be displayed).

In this case, we are appending the Site Title of the blog to the message being
output.

If we were to go to
Settings > General
and modify the "Site Title" setting, the rendered output would change
(without our re-opening the post in Gutenberg).

See #203

* Display the Site Title in our block

The Site Title is not modifiable within the block, but if we
were to go to
Settings > General
and modify the "Site Title" value.

When we reload the post in Gutenberg, the Site Title would be updated.

See #203

* Add "loading..." message for site title

See https://github.com/WordPress/gutenberg-examples/pull/216/files#r870644522

* Fix linting errors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants