sholawat-json 0.3.1 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -6,35 +6,302 @@ All praise is due to Allah SWT for His countless blessings. May blessings and pe
6
6
 
7
7
  We strive for accuracy, but if you encounter any errors, please reach out. Your feedback is invaluable for improvement.
8
8
 
9
- ## CDN
10
- Check out the [`/sholawat`](https://github.com/afaf-tech/sholawat-json/tree/master/sholawat) to see all available sholawat and source files. The JSON files are also available through [JSDELIVER](https://www.jsdelivr.com/package/npm/sholawat-json) CDN
9
+ ## 🚀 Quick Start
11
10
 
12
- ### List Sholawat and Sources
13
- get the information with :
11
+ ### Option 1: CDN (Recommended for Web Projects)
12
+
13
+ No installation needed! Just fetch directly from jsDelivr CDN:
14
+
15
+ ```javascript
16
+ // Fetch list of all available sholawat
17
+ fetch('https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/sholawat.json')
18
+ .then(response => response.json())
19
+ .then(data => console.log(data));
20
+ ```
21
+
22
+ ### Option 2: npm Package
23
+
24
+ ```bash
25
+ npm install sholawat-json
26
+ ```
27
+
28
+ Then import in your project:
29
+
30
+ ```javascript
31
+ import sholawatList from 'sholawat-json/sholawat/sholawat.json';
32
+ import burdahFasl1 from 'sholawat-json/sholawat/burdah/nu_online/fasl/1.json';
33
+ ```
34
+
35
+ ---
36
+
37
+ ## 📖 Usage Guide
38
+
39
+ ### Step 1: Get Available Sholawat
40
+
41
+ First, fetch the master list to see all available sholawat, sources, and file paths:
42
+
43
+ **Endpoint:**
14
44
  ```
15
45
  https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/sholawat.json
16
46
  ```
17
- ### Get a Fasl
18
47
 
19
- You can get a single chapter (fasl) by providing its faslNumber for each sholawat. Text, transliteration and translation are provided on each fasl. To get it you can provide:
48
+ **Example Response:**
49
+ ```json
50
+ [
51
+ {
52
+ "name": "burdah",
53
+ "sources": [
54
+ {
55
+ "source_name": "nu online",
56
+ "description": "burdah-fasl",
57
+ "path_files": "sholawat/burdah/nu_online/fasl/",
58
+ "files": ["1.json", "2.json", "3.json", ...],
59
+ "schema": "burdah_fasl_v1.0.schema.json"
60
+ }
61
+ ]
62
+ }
63
+ ]
64
+ ```
65
+
66
+ ### Step 2: Fetch Specific Sholawat Content
67
+
68
+ #### For Fasl-based Sholawat (Burdah, Diba, Simtudduror)
69
+
70
+ **URL Pattern:**
71
+ ```
72
+ https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/{name}/{source}/fasl/{number}.json
73
+ ```
74
+
75
+ **Examples:**
76
+
77
+ ```javascript
78
+ // Fetch Burdah Fasl 1 from NU Online
79
+ const burdahUrl = 'https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/burdah/nu_online/fasl/1.json';
80
+
81
+ // Fetch Diba Fasl 10 from NU Online
82
+ const dibaUrl = 'https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/diba/nu_online/fasl/10.json';
83
+
84
+ // Fetch Simtudduror Fasl 5
85
+ const simtuddurorUrl = 'https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/simtudduror/nu_online/fasl/5.json';
86
+ ```
87
+
88
+ #### For Single Sholawat (Tunggal & Suluk)
89
+
90
+ **URL Pattern:**
91
+ ```
92
+ https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/{type}/{filename}.json
20
93
  ```
21
- https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/{sholawatName}/{source}/fasl/{faslNumber}.json
22
94
 
95
+ **Examples:**
96
+
97
+ ```javascript
98
+ // Fetch a tunggal sholawat
99
+ const tunggalUrl = 'https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/tunggal/assalamu-alaika-zainal-anbiya.json';
100
+
101
+ // Fetch a suluk sholawat
102
+ const sulukUrl = 'https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/suluk/hubbun-nabi.json';
23
103
  ```
24
- For Example:
25
104
 
26
- - Sholawat Diba from nu online fasl 1: `https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/diba/nu_online/fasl/10.json`
105
+ ---
27
106
 
28
- Get a Schema
29
- You can access the JSON schema for each fasl in the schemas folder. These schemas ensure the data structure remains consistent and reliable. Use the following link to get the schema:
107
+ ## 💻 Code Examples
30
108
 
31
- ```bash
109
+ ### Vanilla JavaScript (Fetch API)
110
+
111
+ ```javascript
112
+ async function getSholawat() {
113
+ try {
114
+ const response = await fetch(
115
+ 'https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/burdah/nu_online/fasl/1.json'
116
+ );
117
+ const data = await response.json();
118
+
119
+ console.log('Sholawat Name:', data.name);
120
+ console.log('Arabic Text:', data.text);
121
+ console.log('Translation:', data.translations.id.name);
122
+ } catch (error) {
123
+ console.error('Error fetching sholawat:', error);
124
+ }
125
+ }
126
+
127
+ getSholawat();
128
+ ```
129
+
130
+ ### React Example
131
+
132
+ ```jsx
133
+ import React, { useState, useEffect } from 'react';
134
+
135
+ function SholawatDisplay() {
136
+ const [sholawat, setSholawat] = useState(null);
137
+ const [loading, setLoading] = useState(true);
138
+
139
+ useEffect(() => {
140
+ fetch('https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/diba/nu_online/fasl/1.json')
141
+ .then(res => res.json())
142
+ .then(data => {
143
+ setSholawat(data);
144
+ setLoading(false);
145
+ })
146
+ .catch(err => console.error(err));
147
+ }, []);
148
+
149
+ if (loading) return <div>Loading...</div>;
150
+
151
+ return (
152
+ <div>
153
+ <h2>{sholawat.name}</h2>
154
+ <div>
155
+ {Object.entries(sholawat.text).map(([key, verse]) => (
156
+ <div key={key}>
157
+ <p className="arabic">{verse.arabic}</p>
158
+ <p className="latin">{verse.latin}</p>
159
+ </div>
160
+ ))}
161
+ </div>
162
+ </div>
163
+ );
164
+ }
165
+ ```
166
+
167
+ ### Vue.js Example
168
+
169
+ ```vue
170
+ <template>
171
+ <div v-if="sholawat">
172
+ <h2>{{ sholawat.name }}</h2>
173
+ <div v-for="(verse, key) in sholawat.text" :key="key">
174
+ <p class="arabic">{{ verse.arabic }}</p>
175
+ <p class="latin">{{ verse.latin }}</p>
176
+ </div>
177
+ </div>
178
+ </template>
179
+
180
+ <script>
181
+ export default {
182
+ data() {
183
+ return {
184
+ sholawat: null
185
+ };
186
+ },
187
+ mounted() {
188
+ fetch('https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/burdah/nu_online/fasl/1.json')
189
+ .then(res => res.json())
190
+ .then(data => this.sholawat = data);
191
+ }
192
+ };
193
+ </script>
194
+ ```
195
+
196
+ ### Axios Example
197
+
198
+ ```javascript
199
+ import axios from 'axios';
200
+
201
+ const API_BASE = 'https://cdn.jsdelivr.net/npm/sholawat-json@latest';
202
+
203
+ // Get all sholawat list
204
+ const getAllSholawat = () =>
205
+ axios.get(`${API_BASE}/sholawat/sholawat.json`);
206
+
207
+ // Get specific fasl
208
+ const getBurdahFasl = (number) =>
209
+ axios.get(`${API_BASE}/sholawat/burdah/nu_online/fasl/${number}.json`);
210
+
211
+ // Usage
212
+ getAllSholawat()
213
+ .then(response => console.log(response.data))
214
+ .catch(error => console.error(error));
215
+
216
+ getBurdahFasl(1)
217
+ .then(response => console.log(response.data))
218
+ .catch(error => console.error(error));
219
+ ```
220
+
221
+ ---
222
+
223
+ ## 📦 Data Structure
224
+
225
+ ### Fasl-based Sholawat (Burdah, Diba, Simtudduror)
226
+
227
+ ```json
228
+ {
229
+ "number": 1,
230
+ "source": "nu_online",
231
+ "name": "بَانَتْ سُعَادُ",
232
+ "text": {
233
+ "1": {
234
+ "arabic": "بَانَتْ سُعَادُ فَقَلْبِيْ الْيَوْمَ مَتْبُوْلُ",
235
+ "latin": "Bānat Su'ādu faqalbil yauma matbūlu"
236
+ }
237
+ },
238
+ "translations": {
239
+ "id": {
240
+ "name": "Suad Telah Pergi",
241
+ "text": {
242
+ "1": "Suad telah pergi, maka hatiku hari ini terguncang"
243
+ }
244
+ }
245
+ },
246
+ "last_updated": "2024-06-15"
247
+ }
248
+ ```
249
+
250
+ ### Single Sholawat (Tunggal & Suluk)
251
+
252
+ ```json
253
+ {
254
+ "source": "general",
255
+ "name": "يَا سَيِّدِيْ يَا رَسُوْلَ اللهِ",
256
+ "latin": "Ya Sayyidi Ya Rasulallah",
257
+ "text": {
258
+ "1": {
259
+ "arabic": "يَا سَيِّدِيْ يَا رَسُوْلَ اللهِ",
260
+ "latin": "Yā sayyidī yā rasūlallāh"
261
+ }
262
+ },
263
+ "translations": {
264
+ "id": {
265
+ "name": "Ya Tuanku Ya Rasulullah",
266
+ "translator": "Tim NU Online",
267
+ "text": {
268
+ "1": "Wahai tuanku wahai Rasulullah"
269
+ }
270
+ }
271
+ },
272
+ "last_updated": "2024-07-04"
273
+ }
274
+ ```
275
+
276
+ ---
277
+
278
+ ## 🔍 Schema Validation
279
+
280
+ Each sholawat type follows a JSON Schema for data consistency. You can access schemas at:
281
+
282
+ ```
32
283
  https://cdn.jsdelivr.net/npm/sholawat-json@latest/schemas/{schema_name}.schema.json
33
284
  ```
34
- For example:
35
285
 
36
- Burdah Fasl Schema (v1.0):
37
- https://cdn.jsdelivr.net/npm/sholawat-json@latest/schemas/burdah_fasl_v1.0.schema.json
286
+ **Available Schemas:**
287
+ - `burdah_fasl_v1.0.schema.json` - Burdah chapters
288
+ - `diba_fasl_v1.0.schema.json` - Diba chapters
289
+ - `simtudduror_fasl_v1.0.schema.json` - Simtudduror chapters
290
+ - `sholawat_tunggal_v1.0.schema.json` - Single sholawat
291
+ - `suluk_v1.0.schema.json` - Suluk sholawat
292
+
293
+ **Example:**
294
+ ```javascript
295
+ const schemaUrl = 'https://cdn.jsdelivr.net/npm/sholawat-json@latest/schemas/burdah_fasl_v1.0.schema.json';
296
+ ```
297
+
298
+ ---
299
+
300
+ ## 🗂️ Browse Files
301
+
302
+ Explore all available sholawat files in the repository:
303
+ - [Browse `/sholawat` directory](https://github.com/afaf-tech/sholawat-json/tree/master/sholawat)
304
+ - [View on jsDelivr CDN](https://www.jsdelivr.com/package/npm/sholawat-json)
38
305
 
39
306
  ## Data Sources
40
307
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sholawat-json",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "All praise is due to Allah SWT for His countless blessings. May blessings and peace always be upon our beloved Prophet Muhammad SAW.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -16,7 +16,9 @@
16
16
  "sholawat",
17
17
  "sholawat-json",
18
18
  "majlis",
19
- "diba", "burdah", "simtudduror"
19
+ "diba",
20
+ "burdah",
21
+ "simtudduror"
20
22
  ],
21
23
  "author": "afaf-tech",
22
24
  "license": "MIT",
@@ -0,0 +1,101 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Sholawat Tunggal Schema",
4
+ "version": "1.0",
5
+ "type": "object",
6
+ "properties": {
7
+ "source": {
8
+ "type": "string",
9
+ "description": "The source of the text."
10
+ },
11
+ "name": {
12
+ "type": "string",
13
+ "description": "The Arabic name of the sholawat."
14
+ },
15
+ "latin": {
16
+ "type": [
17
+ "string",
18
+ "null"
19
+ ],
20
+ "description": "The transliteration of the sholawat name."
21
+ },
22
+ "text": {
23
+ "type": "object",
24
+ "description": "Contains the Arabic text and its transliteration.",
25
+ "patternProperties": {
26
+ "^[0-9]+$": {
27
+ "type": "object",
28
+ "properties": {
29
+ "arabic": {
30
+ "type": "string",
31
+ "description": "The Arabic text of the verse."
32
+ },
33
+ "latin": {
34
+ "type": [
35
+ "string",
36
+ "null"
37
+ ],
38
+ "description": "The transliteration of the Arabic text."
39
+ }
40
+ },
41
+ "required": [
42
+ "arabic"
43
+ ],
44
+ "additionalProperties": false
45
+ }
46
+ },
47
+ "additionalProperties": false
48
+ },
49
+ "translations": {
50
+ "type": [
51
+ "object",
52
+ "null"
53
+ ],
54
+ "description": "Translations in various languages.",
55
+ "patternProperties": {
56
+ "^[a-z]{2}$": {
57
+ "type": "object",
58
+ "description": "The key representing the language code using a two-letter ISO 639-1 code (e.g., 'en' for English, 'id' for Indonesian).",
59
+ "properties": {
60
+ "name": {
61
+ "type": "string",
62
+ "description": "The translated name of the sholawat in the specified language."
63
+ },
64
+ "translator": {
65
+ "type": "string",
66
+ "description": "Translator of the sholawat."
67
+ },
68
+ "text": {
69
+ "type": "object",
70
+ "description": "Translated text for each verse in the specified language.",
71
+ "patternProperties": {
72
+ "^[0-9]+$": {
73
+ "type": "string",
74
+ "description": "Translated text of the verse in the specified language."
75
+ }
76
+ },
77
+ "additionalProperties": false
78
+ }
79
+ },
80
+ "required": [
81
+ "name",
82
+ "text"
83
+ ],
84
+ "additionalProperties": false
85
+ }
86
+ },
87
+ "additionalProperties": false
88
+ },
89
+ "last_updated": {
90
+ "type": "string",
91
+ "format": "date",
92
+ "pattern": "^(\\d{4})-(\\d{2})-(\\d{2})$",
93
+ "description": "The date when the content was last updated, in YYYY-MM-DD format."
94
+ }
95
+ },
96
+ "required": [
97
+ "name",
98
+ "text"
99
+ ],
100
+ "additionalProperties": false
101
+ }
@@ -0,0 +1,118 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Sholawat Tunggal Schema",
4
+ "version": "1.1",
5
+ "type": "object",
6
+ "properties": {
7
+ "source": {
8
+ "type": [
9
+ "string",
10
+ "null"
11
+ ],
12
+ "description": "The source of the text."
13
+ },
14
+ "author": {
15
+ "type": [
16
+ "string",
17
+ "null"
18
+ ],
19
+ "description": "The author of the sholawat."
20
+ },
21
+ "transmitter": {
22
+ "type": [
23
+ "string",
24
+ "null"
25
+ ],
26
+ "description": "The transmitter or narrator of the sholawat."
27
+ },
28
+ "name": {
29
+ "type": "string",
30
+ "description": "The Arabic name of the sholawat."
31
+ },
32
+ "latin": {
33
+ "type": [
34
+ "string",
35
+ "null"
36
+ ],
37
+ "description": "The transliteration of the sholawat name."
38
+ },
39
+ "text": {
40
+ "type": "object",
41
+ "description": "Contains the Arabic text and its transliteration.",
42
+ "patternProperties": {
43
+ "^[0-9]+$": {
44
+ "type": "object",
45
+ "properties": {
46
+ "arabic": {
47
+ "type": "string",
48
+ "description": "The Arabic text of the verse."
49
+ },
50
+ "latin": {
51
+ "type": [
52
+ "string",
53
+ "null"
54
+ ],
55
+ "description": "The transliteration of the Arabic text."
56
+ }
57
+ },
58
+ "required": [
59
+ "arabic"
60
+ ],
61
+ "additionalProperties": false
62
+ }
63
+ },
64
+ "additionalProperties": false
65
+ },
66
+ "translations": {
67
+ "type": [
68
+ "object",
69
+ "null"
70
+ ],
71
+ "description": "Translations in various languages.",
72
+ "patternProperties": {
73
+ "^[a-z]{2}$": {
74
+ "type": "object",
75
+ "description": "The key representing the language code using a two-letter ISO 639-1 code (e.g., 'en' for English, 'id' for Indonesian).",
76
+ "properties": {
77
+ "name": {
78
+ "type": "string",
79
+ "description": "The translated name of the sholawat in the specified language."
80
+ },
81
+ "translator": {
82
+ "type": "string",
83
+ "description": "Translator of the sholawat."
84
+ },
85
+ "text": {
86
+ "type": "object",
87
+ "description": "Translated text for each verse in the specified language.",
88
+ "patternProperties": {
89
+ "^[0-9]+$": {
90
+ "type": "string",
91
+ "description": "Translated text of the verse in the specified language."
92
+ }
93
+ },
94
+ "additionalProperties": false
95
+ }
96
+ },
97
+ "required": [
98
+ "name",
99
+ "text"
100
+ ],
101
+ "additionalProperties": false
102
+ }
103
+ },
104
+ "additionalProperties": false
105
+ },
106
+ "last_updated": {
107
+ "type": "string",
108
+ "format": "date",
109
+ "pattern": "^(\\d{4})-(\\d{2})-(\\d{2})$",
110
+ "description": "The date when the content was last updated, in YYYY-MM-DD format."
111
+ }
112
+ },
113
+ "required": [
114
+ "name",
115
+ "text"
116
+ ],
117
+ "additionalProperties": false
118
+ }
@@ -0,0 +1,101 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Suluk Schema",
4
+ "version": "1.0",
5
+ "type": "object",
6
+ "properties": {
7
+ "source": {
8
+ "type": "string",
9
+ "description": "The source of the text."
10
+ },
11
+ "name": {
12
+ "type": "string",
13
+ "description": "The Arabic name of the suluk."
14
+ },
15
+ "latin": {
16
+ "type": [
17
+ "string",
18
+ "null"
19
+ ],
20
+ "description": "The transliteration of the suluk name."
21
+ },
22
+ "text": {
23
+ "type": "object",
24
+ "description": "Contains the Arabic text and its transliteration.",
25
+ "patternProperties": {
26
+ "^[0-9]+$": {
27
+ "type": "object",
28
+ "properties": {
29
+ "arabic": {
30
+ "type": "string",
31
+ "description": "The Arabic text of the verse."
32
+ },
33
+ "latin": {
34
+ "type": [
35
+ "string",
36
+ "null"
37
+ ],
38
+ "description": "The transliteration of the Arabic text."
39
+ }
40
+ },
41
+ "required": [
42
+ "arabic"
43
+ ],
44
+ "additionalProperties": false
45
+ }
46
+ },
47
+ "additionalProperties": false
48
+ },
49
+ "translations": {
50
+ "type": [
51
+ "object",
52
+ "null"
53
+ ],
54
+ "description": "Translations in various languages.",
55
+ "patternProperties": {
56
+ "^[a-z]{2}$": {
57
+ "type": "object",
58
+ "description": "The key representing the language code using a two-letter ISO 639-1 code (e.g., 'en' for English, 'id' for Indonesian).",
59
+ "properties": {
60
+ "name": {
61
+ "type": "string",
62
+ "description": "The translated name of the suluk in the specified language."
63
+ },
64
+ "translator": {
65
+ "type": "string",
66
+ "description": "Translator of the suluk."
67
+ },
68
+ "text": {
69
+ "type": "object",
70
+ "description": "Translated text for each verse in the specified language.",
71
+ "patternProperties": {
72
+ "^[0-9]+$": {
73
+ "type": "string",
74
+ "description": "Translated text of the verse in the specified language."
75
+ }
76
+ },
77
+ "additionalProperties": false
78
+ }
79
+ },
80
+ "required": [
81
+ "name",
82
+ "text"
83
+ ],
84
+ "additionalProperties": false
85
+ }
86
+ },
87
+ "additionalProperties": false
88
+ },
89
+ "last_updated": {
90
+ "type": "string",
91
+ "format": "date",
92
+ "pattern": "^(\\d{4})-(\\d{2})-(\\d{2})$",
93
+ "description": "The date when the content was last updated, in YYYY-MM-DD format."
94
+ }
95
+ },
96
+ "required": [
97
+ "name",
98
+ "text"
99
+ ],
100
+ "additionalProperties": false
101
+ }