You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a31d6fd
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/plugins/glossary.md
+52-1Lines changed: 52 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,6 +38,33 @@ export default defineConfig({
38
38
39
39
Or wrap the config with `withGlossary` from `markdown-it-glossary/vitepress`. It plays nicely with other `withX()` wrappers.
40
40
41
+
### Touch devices
42
+
43
+
`<abbr title>` tooltips only appear on hover, so they never show on a phone or tablet. Call `enableGlossaryTouch()` once in the browser and tapping a term shows its definition in a small popover instead. Tapping elsewhere, scrolling, or pressing Escape dismisses it. It only activates on devices that can't hover, so desktop keeps the native tooltip.
44
+
45
+
In VitePress, call it from your theme's `enhanceApp`:
|`selector`|`'abbr[title]'`| Which elements carry a definition in their `title`. |
63
+
|`touchOnly`|`true`| Only activate on devices that can't hover. `false` also enables it on desktop. |
64
+
|`injectStyles`|`true`| Inject the default popover styles. `false` lets you style `.glossary-popover`. |
65
+
66
+
The default look follows VitePress theme colors and can be overridden with the `--glossary-popover-bg`, `--glossary-popover-fg`, and `--glossary-popover-border` CSS variables. `enableGlossaryTouch()` returns a function that removes its listeners.
67
+
41
68
## Writing the glossary file
42
69
43
70
Each term is a `###` heading followed by its definition as the next paragraph. This site's own [glossary file](/reference/glossary) is written like this:
@@ -64,7 +91,31 @@ glossary: false
64
91
---
65
92
```
66
93
67
-
The glossary page itself uses this so its headings don't tooltip themselves. To override one term on one page, write a real markdown-it-abbr definition anywhere on that page: `*[CI]: something else`.
94
+
The glossary page itself uses this so its headings don't tooltip themselves.
95
+
96
+
Opting out only turns off the site-wide glossary for that page. The page still supports [markdown-it-abbr](https://github.com/markdown-it/markdown-it-abbr), so you can add tooltips by hand. Write a definition line anywhere in the page's Markdown, in the form `*[Term]: definition`:
97
+
98
+
```md
99
+
---
100
+
glossary: false
101
+
---
102
+
103
+
# Release notes
104
+
105
+
We cut a release every sprint, and each one is gated on CI passing.
106
+
107
+
*[CI]: Continuous Integration, only this page's definition applies.
108
+
```
109
+
110
+
Every exact, case-sensitive occurrence of `CI` on that page becomes an `<abbr title>`, and nothing else from the glossary does. The definition line itself isn't rendered. Use this to keep a few terms on an otherwise opted-out page, or to define terms that aren't in the glossary at all.
111
+
112
+
### Override one term on one page
113
+
114
+
The same syntax works on a page that has _not_ opted out. A page-local definition always wins over the site-wide one for that term, on that page:
0 commit comments