Skip to content

Commit 7e1b5fc

Browse files
committed
updated the hindi alphabets to use char code
1 parent 30c3ab6 commit 7e1b5fc

File tree

3 files changed

+32
-63
lines changed

3 files changed

+32
-63
lines changed

src/pages/barahkhadi/[consonant].astro

Lines changed: 3 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,50 +2,15 @@
22
import "@/assets/styles/barahkhadi/consonant.css";
33
import BaseLayout from "@/layouts/Base";
44
5+
import { hindiConsonants as consonants, matras } from "@/utils/common";
6+
57
export function getStaticPaths() {
6-
const consonants = [
7-
"",
8-
"",
9-
"",
10-
"",
11-
"",
12-
"",
13-
"",
14-
"",
15-
"",
16-
"",
17-
"",
18-
"",
19-
"",
20-
"",
21-
"",
22-
"",
23-
"",
24-
"",
25-
"",
26-
"",
27-
"",
28-
"",
29-
"",
30-
"",
31-
"",
32-
"",
33-
"",
34-
"",
35-
"",
36-
"",
37-
"",
38-
"",
39-
""
40-
];
418
return consonants.map((consonant) => ({ params: { consonant } }));
429
}
4310
4411
const { consonant } = Astro.params;
4512
46-
const matras = ["", "", "ि", "", "", "", "", "", "", "", "", "", ""];
47-
48-
const combinations = matras.map((matra) => consonant + matra);
13+
const combinations = [consonant, ...Object.values(matras).map((matra) => consonant + matra)];
4914
---
5015

5116
<BaseLayout meta={{ title: `Barahkhadi - ${consonant}` }}>

src/pages/barahkhadi/index.astro

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
import BaseLayout from "@/layouts/Base";
33
import "@/assets/styles/barahkhadi/index.css";
44
5+
import { hindiConsonants } from "@/utils/common";
6+
import { matras } from "@/utils/common";
7+
58
const consonants = [
6-
["", "", "", "", ""],
7-
["", "", "", "", ""],
8-
["", "", "", "", ""],
9-
["", "", "", "", ""],
10-
["", "", "", "", ""],
11-
["", "", "", ""],
12-
["", "", "", ""]
9+
hindiConsonants.slice(0, 5), // क, ख, ग, घ, ङ
10+
hindiConsonants.slice(5, 10), // च, छ, ज, झ, ञ
11+
hindiConsonants.slice(10, 15), // ट, ठ, ड, ढ, ण
12+
hindiConsonants.slice(15, 20), // त, थ, द, ध, न
13+
hindiConsonants.slice(20, 25), // प, फ, ब, भ, म
14+
hindiConsonants.slice(25, 29), // य, र, ल, व
15+
hindiConsonants.slice(29, 33) // श, ष, स, ह
1316
];
14-
15-
const matras = ["", "", "ि", "", "", "", "", "", "", "", "", ""];
1617
---
1718

1819
<script>
@@ -53,7 +54,7 @@ const matras = ["", "ा", "ि", "ी", "ु", "ू", "े", "ै", "ो", "ौ
5354
<button class="quick-view-btn">🔍</button>
5455
<div class="barahkhadi-popover">
5556
<div class="variations-grid">
56-
{matras.map((matra) => (
57+
{Object.values(matras).map((matra) => (
5758
<div class="variation">{consonant + matra}</div>
5859
))}
5960
</div>

src/utils/common.ts

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
// Generating arrays for Hindi vowels (स्वर) and consonants (व्यंजन)
22

33
// Vowels
4-
const hindiVowels = Array.from({ length: 16 }, (_, i) => ({ key: 2309 + i, value: String.fromCodePoint(2309 + i) }));
4+
export const hindiVowels = Array.from({ length: 16 }, (_, i) => ({
5+
key: 2309 + i,
6+
value: String.fromCodePoint(2309 + i)
7+
}));
58
const extraHindiVowelKey = [2317, 2321];
69
export const hindiVowelList = hindiVowels.filter((v) => !extraHindiVowelKey.includes(v.key));
710

@@ -20,25 +23,25 @@ export const hindiConsonants = Array.from({ length: 37 }, (_, i) => String.fromC
2023
additionalConsonants
2124
);
2225

23-
const matra = {
24-
aa: 2366,
25-
e: 2367,
26-
ee: 2368,
27-
u: 2369,
28-
uu: 2370,
29-
ae: 2375,
30-
aie: 2376,
31-
au: 2379,
32-
aau: 2380,
33-
an: 2385,
34-
ah: 2307
26+
export const matras = {
27+
aa: String.fromCharCode(2366),
28+
e: String.fromCharCode(2367),
29+
ee: String.fromCharCode(2368),
30+
u: String.fromCharCode(2369),
31+
uu: String.fromCharCode(2370),
32+
ae: String.fromCharCode(2375),
33+
aie: String.fromCharCode(2376),
34+
au: String.fromCharCode(2379),
35+
aau: String.fromCharCode(2380),
36+
an: String.fromCharCode(2385),
37+
ah: String.fromCharCode(2307),
38+
ru: String.fromCharCode(2371),
3539
};
3640

3741
export const barahkhadi = (code: number) => {
3842
console.log({ code });
39-
const vowels = Object.values(matra);
43+
const sanyukat = Object.values(matras);
4044
const list = [String.fromCharCode(code)];
41-
const sanyukat = vowels.map((m) => String.fromCharCode(code, m));
4245
console.log(list.concat(sanyukat));
4346
return list.concat(sanyukat);
4447
};

0 commit comments

Comments
 (0)