Manage citation sources
Supply source data, publish updates, and choose how revisions are tracked.
Each source has a stable id, a display label, and the JSON data you want to track. Your app fetches or extracts that data. If you supply a URL alone, Smart Citations tracks the URL string.
Try a source change
Edit Source text and click Apply source change. Only citations of the selected source need review.
Refresh source data
Keep the configured source collection while the editor is open. This example assumes /api/manual returns plain text and replaces the data for the existing manual source.
const response = await fetch('/api/manual')
if (!response.ok) {
throw new Error(`Could not load the manual: ${response.status}`)
}
sources.update('manual', { data: { text: await response.text() } })Keep the last known source if a fetch fails. Run refreshes for the same source in order so an older response cannot overwrite newer data. Finish fetching before applying related updates in sources.batch().
Choose a revision strategy
| Strategy | Configuration | Behavior |
|---|---|---|
| Automatic | Omit revision and getRevision. | Hashes canonical JSON with SHA-256. Array order matters. Object key order has no effect. |
| Explicit | Set revision to a version ID or ETag. | Your app decides when to change the revision. |
| Selected fields | Set getRevision: data => data.text. | Hashes the selector result, so changes to unrelated fields leave the revision unchanged. |
Only sources with an explicit revision accept revision updates. Remove and re-add a source to change its strategy.
Selectors run on insert and data replacement. They receive frozen data and must return finite JSON. If a selector throws, the collection keeps its previous state and rethrows the error.
This source tracks text and ignores refresh timestamps.
const sources = createSources([
{
id: 'manual',
label: 'Editor manual',
data: { text: 'First version', fetchedAt: new Date().toISOString() },
getRevision: data => data.text,
},
])See the source collection API for updates, subscriptions, and batches.