This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/components/ForeignPronoun.vue

43 lines
1.2 KiB
Vue
Raw Normal View History

2021-12-14 15:45:28 -08:00
<template>
<a :href="base + '/' + pronounWithoutDomain" class="badge bg-primary text-white mx-1">
{{ pronounName || pronounCleared }}
</a>
</template>
<script>
export default {
props: {
pronoun: { required: true },
locale: { required: true },
},
data() {
return {
pronounName: undefined,
}
},
async mounted() {
try {
const pronounName = await this.$axios.$get(`/remote-pronouns-name/${this.locale}/${this.pronounWithoutDomain}`);
if (!pronounName.startsWith('<!doctype') && pronounName.length < 36) {
this.pronounName = pronounName.toLowerCase();
}
} catch (e) {
console.error(e);
}
2021-12-14 15:45:28 -08:00
},
computed: {
base() {
return this.locales[this.locale].url;
},
pronounWithoutDomain() {
return this.pronoun.startsWith(this.base + '/')
? this.pronoun.substring(this.base.length + 1)
: this.pronoun;
},
pronounCleared() {
return this.pronounWithoutDomain.split(',')[0].substring(0, 24);
},
},
}
</script>