Skip to content

Commit ffea303

Browse files
Ciphroxxkeshav
authored andcommitted
updated the hindi alphabets to use char code
1 parent 6fccacf commit ffea303

File tree

3 files changed

+18
-53
lines changed

3 files changed

+18
-53
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: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ export const hindiVowels = Array.from({ length: 16 }, (_, i) => ({
55
key: 2309 + i,
66
value: String.fromCodePoint(2309 + i)
77
}));
8-
const extraHindiVowelKey = [2317, 2321]; // 'ऍ' , 'ऑ'
9-
10-
// String.fromCodePoint(2384); // 'ॐ'
8+
const extraHindiVowelKey = [2317, 2321];
119
export const hindiVowelList = hindiVowels.filter((v) => !extraHindiVowelKey.includes(v.key));
1210

1311
// Consonants
@@ -50,15 +48,16 @@ export const matras = {
5048
aie: String.fromCharCode(2376),
5149
au: String.fromCharCode(2379),
5250
aau: String.fromCharCode(2380),
53-
an: String.fromCharCode(2306),
51+
an: String.fromCharCode(2385),
5452
ah: String.fromCharCode(2307),
55-
ru: String.fromCharCode(2371)
53+
ru: String.fromCharCode(2371),
5654
};
5755

5856
export const barahkhadi = (code: number) => {
5957
console.log({ code });
6058
const sanyukat = Object.values(matras);
6159
const list = [String.fromCharCode(code)];
60+
console.log(list.concat(sanyukat));
6261
return list.concat(sanyukat);
6362
};
6463

0 commit comments

Comments
 (0)