Skip to content

Commit 17bbd01

Browse files
committed
docs(#141): document alertsOptions
1 parent 1955536 commit 17bbd01

2 files changed

Lines changed: 90 additions & 3 deletions

File tree

docs/customization.md

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,92 @@ keys:
7575
```
7676

7777
- **`"alertsOptions"`**\
78-
Todo
78+
Options to customize [Alerts](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts)
79+
beyond the 5 default ones used by GitHub. You may also know this feature by the name of
80+
[Obsidian Callouts](https://help.obsidian.md/callouts).
81+
82+
```json
83+
"alertsOptions": {
84+
"icons": {
85+
"foo": "zap",
86+
"bar": "./icons/flower.svg",
87+
"baz": "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'><path d='M0 0 10 5 0 10z' fill='currentColor'/></svg>"
88+
},
89+
"titles": {
90+
"bar": "Tip of the day"
91+
},
92+
"fallbackIcon": "alert"
93+
}
94+
```
95+
96+
In more detail:
97+
98+
- **`"icons"`**
99+
100+
**Key:** Any custom marker name. Can also be a multi-word string. Has to be fully
101+
lowercased.
102+
103+
**Value:** A custom svg to use in one of three formats:
104+
105+
1. Name of an [octicon](https://primer.style/octicons/) (in kebab-case)
106+
2. Path to an svg file, either relative to Vivify's config directory, or an absolute path.
107+
Tilde (`~`) can be used in an absolute path.
108+
3. A raw svg tag as a string. Note: must escape double quotes or use single quotes
109+
inside the string.
110+
111+
> [!WARNING]
112+
> We're considering switching from octicons to lucide as the main icon provider, so
113+
> option 1 is subject to change.
114+
115+
- **`"fallbackIcon"`**
116+
117+
Icon to fall back to for markers you have not explicitly set a custom icon for. Given
118+
in the same format as an entry in the `"icons"` table.
119+
120+
The fallback icon defaults to the icon used by `[!NOTE]`, to match the default
121+
behavior in Obsidian.
122+
123+
- **`"titles"`**
124+
125+
If you want an alert to have a different title than the marker string itself, it can
126+
be mapped in this table.
127+
128+
**Key:** Any custom marker name. Can also be a multi-word string. Has to be fully
129+
lowercased.
130+
131+
**Value:** Any string.
132+
133+
Note that custom titles can also be given with this markdown syntax, with no config
134+
required:
135+
136+
```md
137+
> [!NOTE] Nota bene
138+
```
139+
140+
To customize alert colors, set in your custom stylesheet (see `"styles"` above):
141+
142+
```css
143+
.alert-foo { --color: #00ff00; }
144+
```
145+
146+
To set the same color as a default marker, use one of these variables variables:
147+
- `--alert-note`
148+
- `--alert-tip`
149+
- `--alert-important`
150+
- `--alert-warning`
151+
- `--alert-caution`
152+
153+
These would be used as follows:
154+
155+
```css
156+
.alert-bar { --color: var(--alert-tip); }
157+
```
158+
159+
For customization of all unconfigured custom markers at once, we have a color variable:
160+
- `--fallback-alert`
161+
162+
and a special class for the base alert div:
163+
- `.fallback-alert`
79164

80165
Vivify reads the config on startup, i.e. when you want it to reload the config,
81166
you have to restart Vivify. You can do this for example by running

tests/rendering/markdown-additional.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,9 @@ Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy, and <kbd>Ctrl</kbd> + <kbd>V</kbd>
5656

5757
This paragraph has a red background color.{style=background-color:red}
5858

59-
## GitHub style alert
59+
## Alerts
60+
61+
Known by many names: GitHub Alerts, Obsidian Callouts, Admonitions...
6062

6163
### The 5 default GitHub style alerts
6264

@@ -86,7 +88,7 @@ This paragraph has a red background color.{style=background-color:red}
8688
> Set custom icon and color for any marker
8789
8890
> [!TIP] Unconfigured custom markers
89-
> Markers fall back to `[!NOTE]` by default
91+
> Markers fall back to `[!NOTE]` by default, to match Obsidian's default behavior
9092
>
9193
> Optionally, the fallback icon can be set separately as
9294
> `config.alertsOptions.fallbackIcon`

0 commit comments

Comments
 (0)