1
0
silverbullet/website/Attributes.md

58 lines
1.3 KiB
Markdown
Raw Normal View History

2023-11-27 16:12:47 +00:00
Attribute syntax can contribute additional [[Metadata]] to various [[Objects]], including:
2023-07-25 15:33:24 +00:00
* Pages
* Items
* Tasks
## Syntax
2023-07-26 15:12:56 +00:00
The syntax is as follows:
2023-07-25 15:33:24 +00:00
```
2023-07-26 15:12:56 +00:00
[attributeName: value]
2023-07-25 15:33:24 +00:00
```
2023-07-26 15:12:56 +00:00
For Obsidian/LogSeq compatibility, you can also double the colon like this: `[attributeName:: value]`
2023-11-27 16:12:47 +00:00
Attribute names need to be alpha-numeric. Values are interpreted as [[YAML]] values. So here are some examples of valid attribute definitions:
2023-07-25 15:33:24 +00:00
2023-07-26 15:12:56 +00:00
* string: [attribute1: sup]
* number: [attribute2: 10]
* array: [attribute3: [sup, yo]]
2023-07-25 15:33:24 +00:00
2023-07-26 15:12:56 +00:00
Multiple attributes can be attached to a single entity, e.g. like so:
2023-07-25 15:33:24 +00:00
2023-07-26 15:12:56 +00:00
* Some item [attribute1: sup][attribute2: 22]
2023-07-25 15:33:24 +00:00
## Scope
2023-07-26 15:12:56 +00:00
Depending on where these attributes appear, they attach to different things. For instance, this attaches an attribute to a page:
2023-07-25 15:33:24 +00:00
[pageAttribute: hello]
2023-11-27 16:12:47 +00:00
However, usually, [[Frontmatter]] is used for this purpose instead.
2023-07-25 15:33:24 +00:00
2023-07-26 15:12:56 +00:00
Example query:
```query
page where name = "{{@page.name}}" select name, pageAttribute
```
2023-07-26 15:12:56 +00:00
This attaches an attribute to an item:
2023-07-25 15:33:24 +00:00
* Item [itemAttribute: hello] #specialitem
2023-07-25 15:33:24 +00:00
2023-07-26 15:12:56 +00:00
Example query:
```query
specialitem where itemAttribute = "hello" select name, itemAttribute
```
2023-07-26 15:12:56 +00:00
This attaches an attribute to a task:
2023-07-25 15:33:24 +00:00
* [ ] Task [taskAttribute: hello]
2023-07-25 15:33:24 +00:00
2023-07-26 15:12:56 +00:00
Example query:
```query
task where page = "Attributes" and taskAttribute = "hello" select name, taskAttribute
```