sholawat-json 0.3.2 → 0.3.5

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.2",
3
+ "version": "0.3.5",
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": {
@@ -75,7 +75,14 @@
75
75
  "7.json",
76
76
  "8.json",
77
77
  "9.json",
78
- "10.json"
78
+ "10.json",
79
+ "11.json",
80
+ "12.json",
81
+ "13.json",
82
+ "14.json",
83
+ "15.json",
84
+ "16.json",
85
+ "17.json"
79
86
  ],
80
87
  "schema": "simtudduror_fasl_v1.0.schema.json"
81
88
  }
@@ -2,7 +2,7 @@
2
2
  "number": 17,
3
3
  "source": "nu-online",
4
4
  "name": "",
5
- "latin": "Wa ḫîna baraza…",
5
+ "latin": "Wa lammâ nadhamal-fikru…",
6
6
  "sections": {
7
7
  "1": {
8
8
  "name": "",
package/PUBLISHING.md DELETED
@@ -1,190 +0,0 @@
1
- # Publishing Guide
2
-
3
- ## How Publishing Works
4
-
5
- This project automatically publishes to **npm** when you create a GitHub release. Once published to npm, **jsDelivr** automatically mirrors the package within minutes.
6
-
7
- ### Distribution Chain
8
- ```
9
- GitHub Release → npm → jsDelivr CDN
10
- ```
11
-
12
- ## Quick Start: Publishing a New Version
13
-
14
- 1. **Make your changes** and ensure they pass validation
15
- 2. **Create a GitHub release**:
16
- - Go to https://github.com/afaf-tech/sholawat-json/releases/new
17
- - Choose a version tag (e.g., `v0.3.2` or `0.3.2`)
18
- - Write release notes
19
- - Click "Publish release"
20
- 3. **Automated workflow runs**:
21
- - ✅ Validates all JSON files
22
- - ✅ Updates `package.json` version
23
- - ✅ Publishes to npm
24
- 4. **Wait ~5 minutes** for jsDelivr to pick up the new version
25
-
26
- ## Prerequisites (One-Time Setup)
27
-
28
- ### 1. Create npm Account
29
- If you don't have one: https://www.npmjs.com/signup
30
-
31
- ### 2. Get npm Access Token
32
- 1. Log in to npm: https://www.npmjs.com/
33
- 2. Click your profile → "Access Tokens"
34
- 3. Click "Generate New Token" → "Classic Token"
35
- 4. Select **Automation** type
36
- 5. Copy the token (starts with `npm_...`)
37
-
38
- ### 3. Add Token to GitHub
39
- 1. Go to: https://github.com/afaf-tech/sholawat-json/settings/secrets/actions
40
- 2. Click "New repository secret"
41
- 3. Name: `NPM_TOKEN`
42
- 4. Value: Paste your npm token
43
- 5. Click "Add secret"
44
-
45
- ## Version Numbering
46
-
47
- Follow [Semantic Versioning](https://semver.org/):
48
-
49
- - **Patch** (e.g., `0.3.1` → `0.3.2`): Bug fixes, typo corrections
50
- - **Minor** (e.g., `0.3.1` → `0.4.0`): New content, new translations, backwards-compatible
51
- - **Major** (e.g., `0.3.1` → `1.0.0`): Breaking changes to JSON structure/schema
52
-
53
- ## Creating a Release
54
-
55
- ### Via GitHub Web Interface
56
-
57
- 1. Go to: https://github.com/afaf-tech/sholawat-json/releases/new
58
- 2. **Tag version**: Enter version (e.g., `v0.3.2` or `0.3.2`)
59
- 3. **Target**: Keep as `master`
60
- 4. **Release title**: Same as tag (e.g., `v0.3.2`)
61
- 5. **Description**: Summarize changes:
62
- ```markdown
63
- ## What's New
64
- - Added Indonesian translation for Burdah Fasl 10
65
- - Fixed typo in Simtudduror Fasl 5
66
-
67
- ## Files Changed
68
- - sholawat/burdah/nu_online/fasl/10.json
69
- - sholawat/simtudduror/nu_online/fasl/5.json
70
- ```
71
- 6. Click **"Publish release"**
72
-
73
- ### Via Command Line (Alternative)
74
-
75
- ```bash
76
- # Tag the current commit
77
- git tag v0.3.2
78
-
79
- # Push the tag
80
- git push origin v0.3.2
81
-
82
- # Then create release on GitHub using the tag
83
- ```
84
-
85
- ## What Happens During Publish
86
-
87
- 1. **GitHub Actions triggers** (`.github/workflows/publish.yml`)
88
- 2. **Validation runs** using Go validator
89
- - If validation fails, publish stops
90
- 3. **Version updated** in `package.json` based on release tag
91
- 4. **Published to npm** with provenance attestation
92
- 5. **jsDelivr mirrors** automatically within 5-10 minutes
93
-
94
- ## Verifying Publication
95
-
96
- ### Check npm
97
- ```bash
98
- npm view sholawat-json version
99
- ```
100
-
101
- Or visit: https://www.npmjs.com/package/sholawat-json
102
-
103
- ### Check jsDelivr
104
- - Latest version: https://cdn.jsdelivr.net/npm/sholawat-json@latest/sholawat/sholawat.json
105
- - Specific version: https://cdn.jsdelivr.net/npm/sholawat-json@0.3.2/sholawat/sholawat.json
106
- - Purge cache: https://www.jsdelivr.com/tools/purge
107
-
108
- ## Manual Publishing (Fallback)
109
-
110
- If automated workflow fails:
111
-
112
- ```bash
113
- # 1. Validate locally
114
- cd validator
115
- go run main.go
116
-
117
- # 2. Update version in package.json
118
- npm version patch # or minor, major
119
-
120
- # 3. Login to npm (one time)
121
- npm login
122
-
123
- # 4. Publish
124
- npm publish --access public
125
- ```
126
-
127
- ## Continuous Integration
128
-
129
- ### Validation Workflow (`.github/workflows/validate.yml`)
130
-
131
- Runs on every push/PR to master that modifies JSON files:
132
- - ✅ Validates all JSON against schemas
133
- - ✅ Prevents invalid data from being merged
134
- - ✅ Ensures data integrity before release
135
-
136
- ### When Validation Fails
137
-
138
- 1. Check the Actions tab: https://github.com/afaf-tech/sholawat-json/actions
139
- 2. Click the failed workflow run
140
- 3. Read the error messages from validator
141
- 4. Fix the JSON files
142
- 5. Commit and push fixes
143
-
144
- ## Best Practices
145
-
146
- 1. **Always validate locally** before pushing:
147
- ```bash
148
- cd validator && go run main.go
149
- ```
150
-
151
- 2. **Test changes** in a branch before merging to master
152
-
153
- 3. **Write clear release notes** describing what changed
154
-
155
- 4. **Use semantic versioning** consistently
156
-
157
- 5. **Don't delete releases** - users may depend on specific versions
158
-
159
- 6. **Update sholawat.json** when adding new files or sources
160
-
161
- ## Troubleshooting
162
-
163
- ### "NPM_TOKEN not found"
164
- - Ensure the secret is added in repository settings
165
- - Name must be exactly `NPM_TOKEN`
166
-
167
- ### "Validation failed"
168
- - Run `cd validator && go run main.go` locally
169
- - Fix reported schema violations
170
- - Commit fixes and re-release
171
-
172
- ### "Permission denied" when publishing
173
- - Verify npm token has correct permissions
174
- - Ensure you're a maintainer on npm package
175
-
176
- ### jsDelivr shows old version
177
- - Wait 5-10 minutes for CDN propagation
178
- - Force purge: https://www.jsdelivr.com/tools/purge
179
- - Use specific version URL instead of `@latest`
180
-
181
- ## Resources
182
-
183
- - npm package: https://www.npmjs.com/package/sholawat-json
184
- - jsDelivr CDN: https://www.jsdelivr.com/package/npm/sholawat-json
185
- - GitHub Actions: https://github.com/afaf-tech/sholawat-json/actions
186
- - Semantic Versioning: https://semver.org/
187
-
188
- ## Questions?
189
-
190
- Open an issue: https://github.com/afaf-tech/sholawat-json/issues