Skip to content

Commit

Permalink
Templates, compound blocks & muliti-section blocks support (#68)
Browse files Browse the repository at this point in the history
* feat: support for compound blocks, multi-section blocks and templates

* Fix: add padding when top level element doesn't have arrow

* fix: lint

* chore: README update

* chore: Update README.md

* fix: broken progress bar

* fix: don't modify page metadata keys

* fix: feedback updates

* chore: Update README.md
  • Loading branch information
dylandepass authored Sep 13, 2023
1 parent a52b402 commit 28c8a78
Show file tree
Hide file tree
Showing 17 changed files with 1,644 additions and 375 deletions.
46 changes: 43 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,27 @@ To generate content for the blocks plugin, you need to prepare a separate Word d

![Library.xlsx](https://github.com/adobe/franklin-sidekick-library/assets/3231084/5f645ab8-cc30-4cd6-932b-94024d01713b)

### (Optional) Authoring block names and descriptions.
## Library Metadata
The blocks plugins supports a special type of block called `library metadata` which provides a way for developers to tell the blocks plugin some information about the block or how it should be rendered.

By default the block name (with variation) will be used to render the item in the blocks plugin. For example, if the name of the block is `columns (center, background)` than that name will be used as the label when it’s rendered in the blocks plugin. This can be customized by creating a library metadata section within the same section as the block. Library metadata can also be used to author a description of the block as well as adding `searchTags` to include an alias for the block when using the search feature.
### Supported library metadata options
| Key Name | Value | Description | Required |
|-----------------------|------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------|
| name | Name of the block | Allows you to set a custom name for the block | false |
| description | A description of the block | Allows you to set a custom description for a block | false |
| type | The type of the block | This tells the blocks plugin how to group the content that makes up your block. Possible options are `template` or `section` (details below) | false |
| include next sections | How many sections to include in the block item | Use if your block requires content from subsequence sections in order to render. Should be a number value that indicates how much subsequent sections to include. | false |
| searchtags | A comma seperated list of search terms | Allows you to define other terms that could be used when searching for this block in the blocks plugin | false |

### Default Library metadata vs Library metadata

There are two types of `library metadata`. Library metadata that lives within a section containing the block, or `default library metadata` that applies to the document as a whole and lives in a section on it's own (only child in a section).

Let's take an example of a hero block that has 5 variants. Suppose you want to add the same description for each variation of the block, rather than duplicating the `library metadata` with the description into each section containing the variations. You could instead use `default library metadata` to apply the same description to every variation of the block. If you decide that one variation actually needs a slightly different description you could add `library metadata` to the section containing the variation and it would override the `default library metadata` description when it's rendered within the blocks plugin.

### Authoring block names and descriptions using Library Metadata

By default the block name (with variation) will be used to render the item in the blocks plugin. For example, if the name of the block is `columns (center, background)` than that name will be used as the label when it’s rendered in the blocks plugin. This can be customized by creating a `library metadata` section within the same section as the block. Library metadata can also be used to author a description of the block as well as adding `searchTags` to include an alias for the block when using the search feature.

Example block with custom name and description

Expand All @@ -61,7 +79,29 @@ Example block with custom name and description

### Autoblocks and Default Content

The blocks plugin is capable of rendering [default content](https://www.hlx.live/developer/markup-sections-blocks#default-content) and [autoblocks](https://www.hlx.live/developer/markup-sections-blocks#auto-blocking). In order to achieve this, it is necessary to place your `default content` or `autoblock` within a dedicated section, which should include a library metadata table defining a name property, as previously described. If no name is specified in the library metadata, the item will be labeled as "Unnamed Item."
The blocks plugin is capable of rendering [default content](https://www.hlx.live/developer/markup-sections-blocks#default-content) and [autoblocks](https://www.hlx.live/developer/markup-sections-blocks#auto-blocking). In order to achieve this, it is necessary to place your `default content` or `autoblock` within a dedicated section, which should include a `library metadata` table defining a `name` property, as previously described. If no name is specified in the library metadata, the item will be labeled as "Unnamed Item."

### Multi-section Blocks

Multi-section blocks are a way to group multiple sections into a single item in the blocks plugin. Some block implementations require multiple sections of content. A common example of this is a tabs block where the subsequent sections after the block is declared contain the content for each tab.

In order to tell the block plugin to include an `n` number of subsequent sections you can use the `include next sections` property in `library metadata`.

![Screenshot 2023-09-07 at 2 42 13 PM](https://github.com/adobe/franklin-sidekick-library/assets/3231084/09353409-9036-4e18-8f52-597897b4e1d2)

In the example above, the block plugin will group this section and the 3 sections after into a single item.

### Templates

Templates are a way to group an entire document into a single element in the sidekick library. To mark a document as a template set `type` to `template` in `default library metadata`.

> Important, the `library metadata` needs to be in it's own section and be the only child to be considered `default library metadata`.
Supporting `metadata` is also desirable for templates. To add a metadata table to the template you can use a `Page metadata` block.

![266064147-12883ee0-147b-4171-b89a-c313e33eef24](https://github.com/adobe/franklin-sidekick-library/assets/3231084/d4b6f9af-0829-4c73-815f-0cac036ce942)

When the template is copied a `metadata` with the values will be added along with the content to the clipboard.

## Sidekick plugin setup

Expand Down
Loading

0 comments on commit 28c8a78

Please sign in to comment.