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

Create a block to display Search banter #24

Open
bobbingwide opened this issue May 4, 2022 · 2 comments
Open

Create a block to display Search banter #24

bobbingwide opened this issue May 4, 2022 · 2 comments
Assignees

Comments

@bobbingwide
Copy link
Owner

bobbingwide commented May 4, 2022

In the SB theme we need to display some additional Search Banter on the search results page.
For details of what the block needs to display see the Search results section in bobbingwide/sb#24

Proposed solution

  • Implement a server side rendered block called bigram/search-banter.
  • The code used in genesis-SB needs to be copied and cobbled to provide the banter when the main query is a search.

Implementation notes

@bobbingwide bobbingwide self-assigned this May 4, 2022
@bobbingwide
Copy link
Owner Author

bobbingwide commented May 5, 2022

Steps to update the existing bigram/seen-before block

  • Update wp-scripts using npm run packages-update
  • Move the block's src files into separate folder within src/seen-before
  • Move the block.json file into the same folder.
  • Change the block's block.json file to refer to the appropriate entry-point and CSS
  • Update server logic to load the block.json from the build folder
  • Build using npm run dev
  • Test

Not necessary since the block's not internationalized.

  • Call wp_set_script_translations() for each block's editor-script
  • Correct the filter function for load_script_textdomain_relative_path

Steps to add the new bigram/search-banter block

  • Create a new subdirectory src/search-banter
  • Copy and cobble source files from seen-before
  • Add the block registration in bigram_block_block_init
  • Develop the new dynamic block's server side rendering function bigram_block_dynamic_block_search_banter

@bobbingwide
Copy link
Owner Author

bobbingwide commented May 5, 2022

The lastest documentation for wp-scripts implies that it's possible to create multiple entry points automatically

When using the start or build commands, the source code directory ( the default is ./src) and its subdirectories are scanned for the existence of block.json files. If one or more are found, they are treated a entry points and will be output into corresponding folders in the build directory. This allows for the creation of multiple blocks that use a single build process.

See https://developer.wordpress.org/block-editor/reference-guides/packages/packages-scripts/#automatic-block-json-detection-and-the-source-code-directory

I couldn't get this to work.
No matter what value I entered for editorScript in block.json I got messages from the build and nothing was output.

In the end I used the same solution as for oik, a custom webpack.config.js, but changed the server side registration to use the build folder rather than the src folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant