Skip to content

An Obsidian plugin that uses selected text as a reference ID to lookup and insert Quran and Hadith text and translation using the Ḥadīth Unlocked API (https://hadith.quranunlocked.com)

License

Notifications You must be signed in to change notification settings

iadnanmukhtar/obsidian-hadith-lookup-plugin

Repository files navigation

obsidian-hadith-lookup-plugin

An Obsidian plugin that uses selected text as a reference ID to lookup and insert Quran and Hadith text and translation using the Ḥadīth Unlocked API.

This plugin is pending publishing to the Obsidian Community plugins. Follow this README for updates.

Usage

  • Within Obsdian, find and install the plugin from the Community plugins
  • Within your Obsidian Note, type in a Ḥadīth Unlocked reference ID, e.g. quran:2:255 or bukhari:99, ideally on a new line
  • Select the reference text you typed-in ealier
  • Open the Obsidian Command palette and search for "Fetch Hadith"
  • The reference text will be replaced by the content of that reference from Ḥadīth Unlocked

References

There are two types of references you can use with this plugin:

Quran: Single Āyah or a Range

  • quran:2:255
  • quran:3:190-194
  • etc.

Hadith

  • bukhari:99
  • muslim:1
  • etc.

Hadith Book IDs

The Book IDs you can use for Hadith references are the ones available on Ḥadīth Unlocked. There are several books available. Browser the aḥādīth within the books and use the ID found in the browser URL. The ones currently available are:

  • The two authentics: bukhari, muslim
  • The four sunans: nasai, abudawud, tirmidhi, ibnmajah
  • The additional: ahmad, darami, hakim, ibnhibban, tabarani, nasai-kubra, bayhaqi
  • and the comprehensive: suyuti

Customization of replacement blocks

By default, the Obsidian Callout format is used to replace the reference with the contents from the Ḥadīth Unlocked API. The API returns a JSON array as a response and the first element of the array is the referenced hadith.

The default Callout templates found in the plugin Settings can be customized as needed. The template should contain the JavaScript object-notation surrounded by {} to access different values from the response JSON.

For example, {result[0].body_en} in the Settings template would be replaced by the contents of the following JSON:

[ 
  { 
	"body_en": "Some value"
  } 
]

See the example JSON respones of Ḥadīth Unlocked for the following references:

Default replacement templates

  • Quran (Single Āyah)
> [!note]
> {result[0].chapter.title} {result[0].num_ar} - {result[0].body}
> 
> [[{result[0].chapter.title_en} {result[0].num}]] - {result[0].body_en}
  • Quran (Āyah Range / Passage)
> [!note]
> {result[0].chapter.title} {result[0].num_ar} - {result[0].body}
> 
> [[{result[0].chapter.title_en} {result[0].num}]] - {result[0].body_en}
  • Hadith
> [!tip] {result[0].title_en}
> {result[0].book.shortName} {result[0].num} - {result[0].chain}
> {result[0].body} 
> {result[0].footnote} – {result[0].grade.grade} ({result[0].grader. shortName})
> 
> [[{result[0].book.shortName_en} {result[0].num}]] - {result[0].chain_en}
> {result[0].body_en}
> {result[0].footnote_en} – {result[0].grade.grade_en} ({result[0].grader. shortName_en})

About

An Obsidian plugin that uses selected text as a reference ID to lookup and insert Quran and Hadith text and translation using the Ḥadīth Unlocked API (https://hadith.quranunlocked.com)

Topics

Resources

License

Stars

Watchers

Forks