Like the codebase, this documentation was scaffolded and written with GitHub Copilot. I don't have a background in technical writing, and wanted to get something out there.
Pages that have not undergone any human review are explicitly marked, but the others may also read funny or need work too. Sorry about that.
Please report any issues so they can be prioritized.
Thanks, Avi
Show commentary and connected texts
This page has not been reviewed by a human.
The Connections Panel,
<sefaria-connections-panel>, shows the texts that Sefaria connects to a reference: commentaries, midrash, halakhah, and more. Readers pick a category, page through its connections, and choose one. Your page decides what happens next.What the panel shows
Set
srefto a reference such asMicah 6:8. The panel shows:Connections for Micah 6:8.Commentary (16)andMidrash (19).Commentarycomes first, then the rest in alphabetical order.194 text connections. Select a category.Sheets aren't included.To try changes, choose Edit, change the code, and choose Run. The example wraps the panel in a div that caps its height at 28rem and scrolls.
Browse categories and pages
Choosing a category lists its connections, 20 per page, with a status such as
Page 1: 19 of 19 Midrash connections. Paging buttons are First page, Previous, and More. Each entry shows:Open Bamidbar Rabbah 1:3 in context.That button does not navigate. It fires an event, and your page decides what to do. For example, you can show that text in a Source Card. See Make components respond to each other.
The panel changes its own category and page when a reader clicks. You can also set them yourself:
srefcategoryMidrash. Leave it out for Overview.pageshow-previewswith-textBoth options are on by default. To turn them off, use JavaScript:
panel.withText = falseorpanel.showPreviews = false. Writing the attribute in HTML can only turn them on. IfwithTextis false and previews are shown, the panel showsPreview text was not requested.and aLoad previewsbutton.For every attribute, see Reference › Components.
React to what readers do
The panel fires five events. They bubble and cross the component boundary, so you can listen on the panel or on a parent.
event.detailsefaria-connections-category-change{ category }categoryisnullfor Overview.sefaria-connections-page-change{ page }pagecounts from 0.sefaria-connections-preview-request{}Load previews.sefaria-connection-select{ id, targetRef }sefaria-connections-panel-error{ error, sref }sreffailed.You can cancel the category, page, and preview events. Calling
event.preventDefault()stops the panel from acting itself, so your page can take over. For every event, see Reference › Components. The example logs each event. Choose a category and open a connection. To try paging, choose a category with more than 20 connections, such asQuoting Commentary (47), then choose More. Choose Overview to return to the summary.Learn more: Component events · Add the complete Reader
How many requests it makes
A fresh load makes one request, to Sefaria's links endpoint. Changing
category,page, orshow-previewsmakes no request, because the panel reuses the data it already loaded. Changingwith-textorsrefloads again. If you loaded without text, choosingLoad previewsmakes one more request.When there's nothing to show
Read
statusfrom the element in JavaScript. It isempty,loading,ready, orerror. Here is what each situation looks like:statusloadingerrorsefaria-connections-panel-errorerrorsref, nothing shownemptyemptyA failed load keeps the connections already showing. See the full empty-state detail. The example has a good reference, a text that isn't a reference, and an empty panel. Choose Show each status to log each one's status.
Learn more: Troubleshoot a page · How the toolkit works
Use your own data
The panel has no
dataproperty. To load links from your own storage, give it a custom loader throughsource. See Give components your own data.Next steps