A starting set of custom blocks for WordPress 5.9+.
- WordPress 5.9+
- Advanced Custom Fields Pro (needed for the Featured Cards block)
- Gesso [not technically required but you probably want it]
- Node 14.x.x
- npm 7.x.x
If you are installing the plugin for use in a site, you can install it with Composer or download it and place it in the plugins folder. Enable the plugin, and you can begin using the available blocks.
The F1 Block Library is a shared set of common blocks. For custom blocks for a site, you can use the Block Plugins Template or @wordpress/create-block.
You should not override this plugin on a site-by-site basis. To customize the block styling, use the starting styles in Gesso or otherwise style the blocks in your theme.
To set up the plugin locally to contribute to it:
npm ci
npm run dev
To build assets for production:
npm ci
npm run build
The Forum One Block Library uses @wordpress/scripts for the linting and building process, with a few styling and prettier overrides.
The Block Editor Handbook has a walkthrough to creating custom blocks. You will want to refer to it and to the Block API reference if you are new to creating custom blocks. As a broad-level overview, each time you create a new block, you'll need to:
- Add a block.json file that defines the block name, editorScript JS file, and any other relevant info, such as attributes.
- Add the Edit and Save functions. The convention blocks in the Forum One Block Library follow is to define the edit function in
_Edit.js
and the save function in_Save.js
and import both intoindex.js
. - Add any other assets, such as a SCSS file or additional scripts to load with the block. See the Slider block for an example of both.
- Add the index.js file and call the
registerBlock
function. - Register the block within the
f1_block_library_register_blocks
inf1-block-library.php
.
An accessible accordion.
An individual item within an accordion. Can only be used inside the Accordion block.
An <address>
element.
A link to jump back to the top of the page.
A card display of content. Comes in three varieties:
Requires Advanced Custom Fields. Allows the editor to select pieces of content and displays them as cards using the featured image, post title, and post excerpt.
Used within a Query Loop block in place of the Post Template block to display the results of a Query Loop in card format.
A card display that allows editors to manually enter each part of the card.
The shared markup for the various card displays is in card-output.php, which takes the card values as parameters and returns the markup displayed on the front-end.
A dynamic block showing the current year and whatever text the user enters for the copyright statement.
A wrapper around the Navigation block to make the navigation use mega menu styling.
A section with a title and optional link (e.g. for "Read all").
Accessible link to skip to the main content. Note that you will need to add the ID of main to the appropriate element in your template(s) as well.
Carousel using Tiny Slider. Each slide must be a core Group block that can then contain whatever block(s), such as images or quotes, make up the slide.
A non-button link displayed on its own (i.e. not part of a paragraph of text). A common use for this is a "Read more" type link. Additional Block Styles can be added for link styling. The WP Next Theme adds an Arrow style that adds an arrow after the link.