- Build
- References
Annotations
Detailed reference on enabling highlights on HTML elements via annotations.
Inline editing is made possible by annotating HTML elements. This tells Netlify Create how to map content in the source to where it appears within the structure of the rendered page in the preview.
Here is usage information for the two data attributes used in inline editing:
Learn more about inline editing in the feature guide.
data-sb-object-id
Scopes all descendant elements within the context of the given ID value, so that any field path mentioned in HTML descendants are automatically attributed to the document with the specified ID.
Usage
1
Example
It is conventional to attach a property similar to id
to a document object being rendered in a page template or component. Basic examples are shown below.
1
ID Exceptions
Most of the time, this value will be obvious. Content sources tend to make the uniquely-identifying value for a document easy to find.
With Git CMS, the ID value is the path to the source file, relative to the root of the project, and including the file extension.
data-sb-field-path
Provide a path (absolute or relative) from the root of the document, identifying the field to be editing in the content source, along with additional instruction on how to locate the content for that field in the DOM.
Usage and exceptions are noted below. See the inline editing feature guide for more specific examples.
Usage
1
Example
It is conventional to attach a property similar to id
to a document object being rendered in a page template or component. Basic examples are shown below.
1
2
3
4
5
6
7
8
9
10
11
12
Advanced Field Path Patterns
There are a number of unique ways to use annotations. Here is a short list of common advanced patterns.
Find more detail and additional examples in the feature guide.
Nested Objects
Some content sources provide the ability to nest fields within other fields. This is a common case in Git CMS, where all fields for a document may live in the same document, rather than linking to document objects.
In this case, you can use dot notation to target the nested element.
1
2
3
4
When a path begins with a dot, it will chain itself to the current path. This is the equivalent of the previous example.
1
2
3
4
5
6
This also applies to lists, in which the index for the item in the list can be used.
1
2
3
4
5
6
7
8
9
10
Changing Document Context
When a field comes from a document outside the current context, the scope can be refined with data-sb-object-id
.
1
2
3
4
5
6
7
8
A full path that includes the ID will also work.
1
2
3
4
5
6
Unwrapped Children
When an element has multiple children with floating text, square brackets can target the appropriate text.
1
2
3
4
5
6
7
8
9