goldnead/statamic-bard-footnotes
A Statamic addon that adds footnote support to Bard rich text fields. Editors insert inline references and the addon renders a clean, linked footnotes list on the front end, with sensible defaults and easy customization for both content editors and developers.
php artisan vendor:publish); run npm run build/npm run dev in your site if the addon publishes Vue/JS assets that need to be compiled into your Bard set.resources/fieldsets/*.yaml (or the blueprint) should enable footnotes, then open the field in the control panel and add a citation.footnotes.js helpers, which is where most day-to-day work will happen.Footnotes::number() and convert with Augmentor::convertToHtml(), mirroring the pattern in the README, and check that fnref-n appears only once for repeated citations.Full-field rendering (the simple case). Number the Bard value once via Footnotes::number() and pass the result to Augmentor::convertToHtml(). Keep the numbered value as the single source of truth for the request — do not re-number per partial.
Rendering a Bard field in parts. The v2.1.0 headline workflow:
Footnotes::number() on the whole field first. This is idempotent — a fully numbered document comes back unchanged, including its first flags.Augmentor::convertToHtml().Because numbering happens up front, counters continue across parts and fnref-n is emitted only on the field-wide first occurrence. Avoid the old pattern of numbering inside each part loop; that restarted at 1 per part and broke anchors.
Editor-side integration. The Sources panel is mounted as a ProseMirror plugin view via TipTap's VueRenderer, so it inherits the same app context and provides as a node view. Practical implications:
Using the pure helpers. footnotes.js exports hasFootnotes, nextCitation, isHttpUrl, reusedCount (now with a wholeSource mode), and citationHighlightPlugin with the setCitationHighlight command. These are tested against a real ProseMirror schema, so they're safe to reuse in custom Vue components, toolbar buttons, or export/preview tooling — for example, wiring your own "jump to next citation" control by calling nextCitation.
Highlighting programmatically. setCitationHighlight is deliberately not recorded for undo, which makes it the right tool for transient UI (hover previews, search results, deep links into a citation). Pair it with the highlight plugin when you build a custom citation navigator.
Localisation. Ship or override the en/de strings — sources_heading, cited_count, cited_times, open_link, go_to_citation, next_citation, edit, edit_source, apply_source — via your normal translation/config override path when supporting other locales.
Footnotes::number() is idempotent and preserves first flags, but a partly numbered document is re-numbered from scratch. If any middleware, cache layer, or partial render touches only a slice before you number, you'll silently lose existing numbers.setCitationHighlight. Clear them explicitly when your transient UI closes, otherwise a highlight can linger after an undo stack change.reusedCount semantic change. The new wholeSource option changes counting scope; audit any custom code calling reusedCount to confirm which behaviour it expects.en/de shipped, an unlocalised site may render raw keys in the panel — verify sources_heading and friends resolve before reporting a bug.fnref-n appears more than once for the same source (numbering ran per part) and whether counters restart at 1 (numbering ran after splitting). Both point to the same root cause.How can I help you explore Laravel packages today?