I didn’t wanna deprecate IndieBlocks’ Context block nor …
I didn’t wanna deprecate IndieBlocks’ Context block nor introduce a bunch of breaking changes. So I simply added a couple new blocks (https://github.com/janboddez/indieblocks/tree/new-blocks/blocks). There’s two big differences:
- The new blocks support page title and author information (whereas a Context block will only ever show a bare URL), in a so-called h-cite microformat.
- They use, or support, Gutenberg’s
InnerBlocks. This allows us to ditch sometimes unpredictable—as in, users don’t even know they’re there—block patterns.
Moved some common code into a global object thingy: https://github.com/janboddez/indieblocks/blob/new-blocks/assets/common.js. No clue if this is how it’s done, but it seems to work.
Jan Boddez on
The title and author thingy works as follows: We use apiFetch to call a custom REST API endpoint, and pass along the URL in question. The page gets downloaded and parsed, and if it sports microformats we use those to get an author name, if any, and title. If no title is found, we assume a note and fall back on the bare URL. If the page is not microformatted, we look for its title element instead.
… liked this!