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
feat(link-notes): support note_snippet for reusable affiliate notes
Rules can now source their note from a Markdown snippet via `note_snippet`
(legacy alias `disclosure_snippet`) instead of duplicating the text inline
in config. Paths resolve against the project root and docs dir plus their
conventional `snippets` subdirectories.
When the snippet is a single admonition (the typical pretty affiliate box),
the plugin extracts its title (used as the standalone fallback box label
unless a `label` is set) and kind, and uses its de-indented body as the
note. An admonition cannot render inside a footnote definition, so the body
is used directly for the tooltip/footer note while the box is reproduced for
table-only links.
Also fixes multi-line footnote definitions to indent continuation lines so
multi-paragraph notes stay within the footnote.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: docs-site/docs/plugins/link-notes.md
+47-5Lines changed: 47 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,6 +51,44 @@ page's footnote list.
51
51
posts readable and avoids per-link markup such as
52
52
`--8<-- "ebay.html" text="..." url="..."`, which is noisier and easy to get wrong.
53
53
54
+
## Reusing a snippet for the note
55
+
56
+
Instead of typing the note text inline in your config, a rule can point at a Markdown
57
+
**snippet file** with `note_snippet`. This keeps a single source of truth for a disclosure
58
+
that you may also include manually elsewhere (via [snippets](snippets.md)), so the wording
59
+
stays consistent everywhere:
60
+
61
+
```json
62
+
{
63
+
"name": "ebay",
64
+
"domains": [ "ebay.us" ],
65
+
"note_snippet": "snippets/ebay-affiliate.md"
66
+
}
67
+
```
68
+
69
+
The path is resolved against the project root and the `docs/` directory, each with a
70
+
conventional `snippets` subdirectory — so `snippets/ebay-affiliate.md`,
71
+
`docs/snippets/ebay-affiliate.md`, or a bare `ebay-affiliate.md` (found in `docs/snippets`)
72
+
all work. If the snippet can't be found, the plugin logs a warning and falls back to the
73
+
inline `note` (when one is set).
74
+
75
+
When the snippet is a single **admonition** — the usual pretty affiliate box:
76
+
77
+
```markdown
78
+
!!! info "E-Bay Affiliate Links Used"
79
+
This post **DOES** include eBay affiliate links. ...
80
+
81
+
You will pay the same amount as normal ...
82
+
```
83
+
84
+
…the plugin is admonition-aware:
85
+
86
+
- its **title** (`E-Bay Affiliate Links Used`) becomes the standalone fallback box's header
87
+
(unless the rule sets an explicit `label`), and its admonition **kind** (`info`) is reused;
88
+
- its **body** becomes the tooltip / footer-note text. (An admonition can't render *inside*
89
+
a footnote, so the body is used directly there; the pretty box is reproduced for
90
+
table-only links via the standalone admonition.)
91
+
54
92
## How it works
55
93
56
94
The plugin runs as a Markdown preprocessor (order `30`, after
@@ -133,13 +171,17 @@ Each **rule** object:
133
171
| Field | Type | Required | Description |
134
172
|---|---|---|---|
135
173
|`name`| string | yes | Rule id; used to build the footnote label (`linknote-<name>`). |
136
-
|`note`| string | yes | Markdown shown as the tooltip and footer note. Legacy alias: `disclosure`. |
137
-
|`domains`| array | no*| Hosts that identify the link. Each entry is a domain string or `{ "domain": "...", "query_contains": "..." }`. Subdomains match automatically. |
138
-
|`patterns`| array | no*| Regular expressions matched (case-insensitively) against the full URL. |
174
+
|`note`| string | yes*| Markdown shown as the tooltip and footer note. Legacy alias: `disclosure`. |
175
+
|`note_snippet`| string | yes*| Path to a Markdown snippet whose content is used as the note (resolved against the project root / `docs` dir and their `snippets` subdirs). A single-admonition snippet contributes its title (→ `label`) and kind, and its body becomes the note. Legacy alias: `disclosure_snippet`. |
176
+
|`domains`| array | no† | Hosts that identify the link. Each entry is a domain string or `{ "domain": "...", "query_contains": "..." }`. Subdomains match automatically. |
177
+
|`patterns`| array | no† | Regular expressions matched (case-insensitively) against the full URL. |
139
178
|`query_contains`| string | no | Default substring a matching URL must contain (per-domain values override this). |
140
-
|`label`| string | no | Title for the standalone fallback admonition (table-only links). Default `Links`. |
179
+
|`label`| string | no | Title for the standalone fallback admonition (table-only links). Defaults to the snippet's admonition title, else `Links`. |
180
+
181
+
\* A rule must provide the note text via either `note` or `note_snippet` (if both are set and
182
+
the snippet resolves, the snippet wins; otherwise `note` is the fallback).
141
183
142
-
\* A rule must provide at least one of `domains` or `patterns`.
184
+
† A rule must provide at least one of `domains` or `patterns`.
143
185
144
186
!!! tip
145
187
Enable [`content.footnote.tooltips`](../reference/theme.md) in your theme `features`
0 commit comments