Skip to content

Commit 6348632

Browse files
committed
Added more information and updated layout of the article
1 parent 158ea89 commit 6348632

File tree

2 files changed

+78
-43
lines changed

2 files changed

+78
-43
lines changed

15/umbraco-cms/customizing/extending-overview/extension-kind.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,29 @@ description: Learn how to use the Kind extension in your manifest files when ext
88
This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice.
99
{% endhint %}
1010

11-
Extension Manifest Kind enables declarations to be based upon a preset Manifest.
11+
The **Extension Manifest Kind** is used to declare a preset configuration that other extensions can inherit. It ensures maintainability and consistency when creating extensions for the Umbraco CMS backoffice. By using a Kind, developers can reuse predefined settings, which reduces redundancy across extensions.
1212

13-
This is used for maintainability or to inherit existing features.
13+
When a Kind is applied, the extension's manifest inherits the fields defined in the Kind. This approach prevents the need to repeat configuration details across multiple extensions.
1414

1515
## Manifest Kind Declaration
1616

17-
A Kind is utilized by declaring it in the `kind` field of a Manifest:
17+
A **Kind** is declared in the `kind` field of the manifest, which is part of the extension registration process. The declaration is linked to a specific extension type.
1818

1919
```typescript
2020
const manifest = {
21-
type: 'headerApp',
22-
kind: 'button',
21+
type: 'headerApp', // The type of the extension
22+
kind: 'button', // The kind alias to inherit settings from
2323
...
2424
};
2525
```
2626

27-
By declaring a kind, the Manifest will inherit fields of the defined Kind.
27+
By setting the `kind` field, the extension automatically inherits all properties associated with that **Kind**. This is useful when you want to standardize a component (like a button) across multiple extensions.
2828

29-
A typical use case is a Kind that provides an element, but requires additional meta fields, to fulfill the needs of its element.
29+
## Using the Kind for Inheritance
3030

31-
In the following example, a manifest using the type 'headerApp' utilizes the 'button' kind. This brings an element and requires some additional information as part of the meta object.
31+
A Kind not only defines the basic configuration but may also require additional metadata to fully configure the element or component.
3232

33-
Adding the metadata provides the ability to use and configure existing functionality to a specific need.
33+
### Example: Using the Button Kind in a Header App
3434

3535
```typescript
3636
const manifest = {
@@ -46,10 +46,11 @@ const manifest = {
4646
};
4747
```
4848

49-
## Learn more
49+
In this example:
50+
51+
- The `kind: 'button'` inherits all default settings from the **Button Kind**.
52+
- The `meta` object is added to configure additional properties, such as the button's label, icon, and the URL to open when clicked.
5053

51-
Learn more about Kinds and how to create your own:
54+
The Kind allows you to extend existing functionality and tailor it to specific needs while maintaining consistency.
5255

53-
{% content-ref url="extension-types/kind.md" %}
54-
Kind Extension Type
55-
{% endcontent-ref %}
56+
For a deeper dive into Kind and how to create your own, see the [Kind](extension-types/kind.md) article.
Lines changed: 63 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
description: A kind extension provides the preset for other extensions to use
2+
description: A kind extension provides the preset for other extensions to use.
33
---
44

55
# Kind
@@ -8,56 +8,86 @@ description: A kind extension provides the preset for other extensions to use
88
This page is a work in progress and may undergo further revisions, updates, or amendments. The information contained herein is subject to change without notice.
99
{% endhint %}
1010

11-
A kind is matched with a specific type. When another extension uses that type and kind it will inherit the preset manifest of the kind extension.
11+
A Kind is a preset configuration that can be inherited by extensions to ensure consistency and reduce redundancy. It defines a set of default properties or behaviors that extensions can adopt, making it easier to maintain and configure extensions that share similar functionality.
1212

13-
The registration of Kinds is done in the same manner as the registration of other extensions. But the format of it is different. Let's take a look at an example of how to implement the `Kind registration` for a [**Header App**](../extension-types/header-apps.md) **Button Kind**.
13+
A Kind is always linked to a specific extension type. Extensions using the same type and referencing a Kind automatically inherit its settings, ensuring uniformity across different extensions.
1414

15-
## Understanding the Kind Extension
15+
## Benefits of Using a Kind
1616

17-
The root properties of this object define the `Kind registration`. Then the manifest property holds the preset for the extension using this kind to be based upon. This object can hold the property values that make sense for the Kind.
17+
- Reduces redundancy – Common settings are defined once and reused across extensions.
18+
- Ensures consistency – Extensions using the same Kind follow a standardized structure and behavior.
19+
- Simplifies extension definitions – Extensions inherit predefined properties, reducing manual configuration.
1820

19-
```typescript
20-
...
21+
## Kind Registration
22+
23+
To register a Kind, use the same method as other extensions. The key properties that define a Kind registration are:
24+
25+
- `type`: Always set to `kind`.
26+
- `alias`: A unique identifier for the Kind.
27+
- `matchType`: Specifies the extension type that the Kind applies to.
28+
- `matchKind`: Defines the Kind alias, which extensions must reference.
29+
- `manifest`: Contains the preset values that extensions will inherit.
2130

31+
### Example: Registering a Button Kind for Header Apps
32+
33+
The following example shows how to register a Button Kind for [**Header Apps**](../extension-types/header-apps.md). This kind provides a preset configuration for a button element that can be reused by other Header App extensions.
34+
35+
```typescript
2236
const manifest: ManifestKind = {
2337
type: 'kind',
24-
alias: 'Umb.Kind.MyButtonKind',
25-
matchType: 'headerApp',
26-
matchKind: 'button',
38+
alias: 'Umb.Kind.MyButtonKind', // Unique alias for the Kind
39+
matchType: 'headerApp', // Applies to Header App extensions
40+
matchKind: 'button', // Defines the Kind alias
2741
manifest: {
28-
...
42+
// Add default properties for the 'button' Kind
43+
elementName: 'umb-header-app-button',
2944
},
3045
};
31-
32-
...
3346
```
3447

35-
For the kind to be used, it needs to match up with the registration of the extension using it. This happens when the extension uses a type, which matches the value of `matchType` of the Kind. As well the extension has to utilize that kind, by setting the value of `kind` to the value of `matchKind` the Kind.
48+
In this example:
3649

37-
```typescript
38-
...
50+
- `type` is set to 'kind' to register it as a Kind extension.
51+
- `matchType` is 'headerApp', specifying that this Kind is for Header App extensions.
52+
- `matchKind` is 'button', which is the alias of the Kind.
53+
- The `manifest` contains default properties like elementName that extensions using this Kind will inherit.
54+
55+
## Using the Kind in Other Extensions
3956

57+
To use the Kind in other extensions, the extension must reference it by setting the `type` and `kind` properties. The extension will automatically inherit the Kind's properties.
58+
59+
### Example: Header App Extension Using the Button Kind
60+
61+
```typescript
4062
const manifest = {
41-
type: 'headerApp',
42-
kind: 'button',
43-
...
63+
type: 'headerApp', // Extension type
64+
kind: 'button', // References the 'button' Kind
65+
name: 'My Header App Example',
66+
alias: 'My.HeaderApp.Example',
67+
meta: {
68+
label: 'My Example',
69+
icon: 'icon-home',
70+
href: '/some/path/to/open/when/clicked',
71+
},
4472
};
4573

46-
...
74+
extensionRegistry.register(manifest);
4775
```
4876

49-
## Kind example
77+
In this example, the Header App extension uses the `kind: 'button'`, meaning it inherits the `elementName` defined in the Button Kind. The extension can still add custom properties (like metadata in this case) to further customize the behavior or appearance.
78+
79+
## Kind Example
5080

51-
In the following example, a kind is registered. This kind provides a default element for extensions utilizing this kind.
81+
Here’s an example of how to register and use the Button Kind in a Header App extension:
5282

5383
```typescript
5484
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
5585

5686
const manifest: UmbExtensionManifest = {
5787
type: 'kind',
58-
alias: 'Umb.Kind.MyButtonKind',
59-
matchType: 'headerApp',
60-
matchKind: 'button',
88+
alias: 'Umb.Kind.MyButtonKind', // Alias for the Kind
89+
matchType: 'headerApp', // Extension type the Kind applies to
90+
matchKind: 'button', // Defines the Kind alias
6191
manifest: {
6292
elementName: 'umb-header-app-button',
6393
},
@@ -66,16 +96,16 @@ const manifest: UmbExtensionManifest = {
6696
umbExtensionsRegistry.register(manifest);
6797
```
6898

69-
This enables other extensions to use this kind and inherit the manifest properties defined in the kind.
99+
This code registers the Button Kind, so other Header App extensions using `type: 'headerApp'` and `kind: 'button'` will inherit the preset `elementName: 'umb-header-app-button'`.
70100

71-
In this example a **Header App** is registered without defining an element, this is possible because the registration inherits the elementName from the kind.
101+
Now, another Header App extension can be created without defining `elementName`, as it will automatically inherit it from the Kind:
72102

73103
```typescript
74104
import { extensionRegistry } from '@umbraco-cms/extension-registry';
75105

76106
const manifest = {
77-
type: 'headerApp',
78-
kind: 'button',
107+
type: 'headerApp', // Extension type
108+
kind: 'button', // References the 'button' Kind
79109
name: 'My Header App Example',
80110
alias: 'My.HeaderApp.Example',
81111
meta: {
@@ -87,3 +117,7 @@ const manifest = {
87117

88118
extensionRegistry.register(manifest);
89119
```
120+
121+
By referencing the Kind, the extension inherits shared properties like `elementName`, ensuring consistency and reducing redundancy across extensions. This method also makes it easier to update configurations across multiple extensions.
122+
123+
By using Kinds, you can create reusable, standardized configurations for extensions, helping to streamline development, ensure consistency, and reduce duplication. Understanding how to register and reference Kinds effectively will enhance the maintainability of your Umbraco extensions.

0 commit comments

Comments
 (0)