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/routes/pronoun.vue

176 lines
7.0 KiB
Vue
Raw Normal View History

2020-07-22 13:19:23 -07:00
<template>
<NotFound v-if="!selectedPronoun"/>
2020-11-29 02:03:01 -08:00
<div v-else>
2020-09-11 03:17:29 -07:00
<h2>
2020-07-22 13:19:23 -07:00
<Icon v="tag"/>
<T>pronouns.intro</T>:
2020-09-11 03:17:29 -07:00
</h2>
2020-07-22 13:19:23 -07:00
<section>
<div class="alert alert-primary">
<h2 class="text-center mb-0">
2020-12-10 07:23:39 -08:00
<template v-if="nameOptions.length === 1">
<strong>{{ selectedPronoun.name(glue) }}</strong><small v-if="selectedPronoun.smallForm">/{{selectedPronoun.morphemes[selectedPronoun.smallForm]}}</small>
</template>
<template v-else>
<template v-for="(nameOption, i) in nameOptions">
<nuxt-link :to="'/' + addSlash(nameOption)">
<strong>
2021-04-12 04:57:18 -07:00
<Spelling :text="nameOption" escape/>
</strong>
</nuxt-link>
<span v-if="i < nameOptions.length - 1"><Spelling :text="glue"/></span>
</template>
</template>
2020-07-22 13:19:23 -07:00
</h2>
<p class="h6 small text-center mb-0 mt-2" v-if="selectedPronoun.description">
2020-07-22 13:19:23 -07:00
<em>
2021-04-12 04:57:18 -07:00
(<Spelling escape :text="Array.isArray(selectedPronoun.description)
? ($t('pronouns.alt.header') + ': ' + selectedPronoun.description.join(glue))
: selectedPronoun.description"/>)
2020-07-22 13:19:23 -07:00
</em>
</p>
</div>
</section>
<section>
<h2 class="h4">
<Icon v="file-signature"/>
<T>pronouns.examples</T>:
2020-07-22 13:19:23 -07:00
</h2>
<ul>
<li v-for="example in examples" class="my-1">
2020-11-28 07:52:48 -08:00
<Example :example="example" :pronoun="selectedPronoun" :counter="counter" pronunciation/>
</li>
2020-07-22 13:19:23 -07:00
</ul>
</section>
<section v-if="selectedPronoun.history">
2021-05-13 12:36:42 -07:00
<template v-for="part in selectedPronoun.history.replace('\\@', '###').split('@')">
2020-12-25 07:05:28 -08:00
<div v-if="part === '__generator__'" class="alert alert-warning">
<Icon v="exclamation-triangle"/>
<T>pronouns.generated</T>
</div>
<div v-else class="alert alert-info">
<Icon v="info-circle"/>
2021-05-13 12:36:42 -07:00
<LinkedText :text="part.replace('###', '@')"/>
2020-12-25 07:05:28 -08:00
</div>
</template>
2020-07-24 11:21:30 -07:00
</section>
2020-12-25 07:05:28 -08:00
<GrammarTables :selectedPronoun="selectedPronoun" :counter="counter"/>
<section v-if="pronounGroup && pronounGroup.group.description">
<ul class="list-group mt-4">
<li class="list-group-item">
<p class="h5">
<Spelling :text="pronounGroup.group.name"/>
</p>
<div class="small my-1">
<Icon v="info-circle"/>
2021-02-06 14:51:43 -08:00
<em><Spelling :text="pronounGroup.group.description"></Spelling></em>
</div>
<ul class="list-unstyled">
<li v-for="pronoun in pronounGroup.groupPronouns" :key="pronoun.canonicalName">
<nuxt-link v-if="typeof pronoun === 'string'" :to="'/' + pronoun">
<strong><Spelling :text="pronoun.replace(/&/g, ' ' + $t('pronouns.or') + ' ')"/></strong>
</nuxt-link>
<nuxt-link v-else :to="addSlash('/' + pronoun.canonicalName)">
<strong><Spelling :text="pronoun.name(glue)"/></strong><small v-if="pronoun.smallForm">/<Spelling :text="pronoun.morphemes[pronoun.smallForm]"/></small>
<small><Spelling :text="pronoun.description"/></small>
</nuxt-link>
<NormativeBadge v-if="pronoun.normative"/>
</li>
</ul>
</li>
<nuxt-link to="/" class="list-group-item list-group-item-action text-center">
<Icon v="ellipsis-h-alt"/>
</nuxt-link>
</ul>
</section>
2020-07-24 05:14:37 -07:00
<section>
<Share :title="`${$t('pronouns.intro')}: ${selectedPronoun.name(glue)}`"/>
2020-07-24 05:14:37 -07:00
</section>
<section v-if="Object.values(groupedSources).filter(x => !!x).length">
2020-12-10 07:23:39 -08:00
<Literature :pronoun="selectedPronoun" :sources="groupedSources"/>
2020-07-22 13:19:23 -07:00
</section>
<Separator icon="info"/>
<section class="mb-0">
<h2 class="h4">
<Icon v="info-circle"/>
2020-11-20 05:41:00 -08:00
<T>home.whatisit</T>
2020-07-22 13:19:23 -07:00
</h2>
<T>home.about</T>
2020-07-22 13:19:23 -07:00
<Homepage align="center"/>
</section>
</div>
</template>
<script>
import { examples, pronouns, getSources, pronounLibrary } from "~/src/data";
2020-11-15 05:13:14 -08:00
import {buildPronoun} from "../src/buildPronoun";
import {head} from "../src/helpers";
import GrammarTables from "../data/pronouns/GrammarTables";
import LinkedText from "../components/LinkedText";
2020-12-04 13:09:57 -08:00
import {SourceLibrary} from "../src/classes";
2020-07-22 13:19:23 -07:00
export default {
components: {LinkedText, GrammarTables },
2020-07-22 13:19:23 -07:00
data() {
const selectedPronoun = this.config.pronouns.enabled
? buildPronoun(pronouns, decodeURIComponent(this.$route.path.substr(1).replace(/\/$/, '')))
2020-10-28 08:22:29 -07:00
: null;
2020-07-22 13:19:23 -07:00
return {
examples,
pronouns,
glue: ' ' + this.$t('pronouns.or') + ' ',
2020-07-22 13:19:23 -07:00
selectedPronoun,
nameOptions: selectedPronoun ? selectedPronoun.nameOptions() : [],
pronounGroup: pronounLibrary.find(selectedPronoun),
2020-07-26 04:14:25 -07:00
counter: 0,
}
},
2020-12-04 13:09:57 -08:00
async asyncData({app}) {
return {
sources: await app.$axios.$get(`/sources`),
}
},
2020-07-26 04:14:25 -07:00
mounted() {
if (process.client) {
setInterval(_ => this.counter++, 1000);
2020-07-22 13:19:23 -07:00
}
},
head() {
return this.selectedPronoun ? head({
title: `${this.$t('pronouns.intro')}: ${this.selectedPronoun.name(this.glue)}`,
2020-10-31 13:33:59 -07:00
banner: `api/banner${this.$route.path.replace(/\/$/, '')}.png`,
2020-09-23 12:29:55 -07:00
}) : {};
2020-07-22 13:19:23 -07:00
},
methods: {
addSlash(link) {
return link + (['*', `'`].includes(link.substr(link.length - 1)) ? '/' : '');
},
},
computed: {
2020-12-04 13:09:57 -08:00
sourceLibrary() {
return new SourceLibrary(this.sources);
},
groupedSources() {
let key = this.selectedPronoun.canonicalName;
if (this.config.sources.mergePronouns[key] !== undefined) {
key = this.config.sources.mergePronouns[key];
}
return this.sourceLibrary.getForPronounExtended(key);
},
},
2020-07-22 13:19:23 -07:00
}
</script>