My first Gutenberg blocks! They output the published date and last modified date for your posts, with the option to add a label.
You can see them live in action here:
Good news: The blocks work in regular pages and posts.
Bad news: They way I’m pulling the date attributes doesn’t seem to work with FSE templates, returning NaN undefined NaN, and I haven’t figured it out yet. As soon as I figure that out, I plan to use these blocks in my digital garden so that it is easy to tell if a particular note is being tended to or not.
Other resources that I used to figure this out:
- This helped me figure out
getEditedPostAttributeand that I could dig around in the console in the post editor to see all of the attributes I could access, which is how I found
06 March 2022: Feedback from George
On the FSE problem, might be worth seeing how the Gutenberg plugin’s post date handles fetching the data: https://github.com/WordPress/gutenberg/blob/8001881edc6236959bd83e3e8b1b47fd0bb967c7/packages/block-library/src/post-date/edit.js