tangled
alpha
login
or
join now
finxol.io
/
blog
0
fork
atom
Personal blog
finxol.io
blog
0
fork
atom
overview
issues
pulls
pipelines
chore: country flag emoji is now directly in api response
finxol.io
6 months ago
10762452
56fbd26c
verified
This commit was signed with the committer's
known signature
.
finxol.io
SSH Key Fingerprint:
SHA256:olFE3asYdoBMScuJOt60UxXdJ0RFdGv5kVKrdOtIcPI=
+6
-14
1 changed file
expand all
collapse all
unified
split
app
components
Country.vue
+6
-14
app/components/Country.vue
···
1
1
<script setup lang="ts">
2
2
const data = await $fetch("https://hook.finxol.io/sensors/country")
3
3
.then((res) => {
4
4
-
return res as { country: string; country_code: string };
4
4
+
return res as {
5
5
+
country: string;
6
6
+
country_code: string;
7
7
+
country_flag: string;
8
8
+
};
5
9
})
6
10
.catch((e) => {
7
11
console.error(e);
8
12
});
9
13
10
14
const country = data?.country;
11
11
-
12
12
-
const letterA = "a".codePointAt(0);
13
13
-
//biome-ignore format: breaks emoji
14
14
-
const regionalIndicatorA = '🇦'.codePointAt(0);
15
15
-
16
16
-
const toRegionalIndicator = (char: string) =>
17
17
-
//@ts-ignore
18
18
-
String.fromCodePoint(char.codePointAt(0) - letterA + regionalIndicatorA);
19
19
-
20
20
-
const emoji = data?.country_code
21
21
-
.split("")
22
22
-
.map((char) => toRegionalIndicator(char))
23
23
-
.join("");
15
15
+
const emoji = data?.country_flag;
24
16
</script>
25
17
26
18
<template>