]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/Technique.js
revert color of language switcher
[alttp.git] / resources / js / helpers / Technique.js
index 410f01595657de34f339d8c0f88b529bbdab316c..c1375bb6c787810119c624aa7de5169aafd3e65d 100644 (file)
@@ -1,5 +1,15 @@
 import i18n from '../i18n';
 
+export const getLink = tech => {
+       if (tech.type === 'mode') {
+               return `/modes/${tech.name}`;
+       }
+       if (tech.type === 'ruleset') {
+               return `/rulesets/${tech.name}`;
+       }
+       return `/tech/${tech.name}`;
+};
+
 export const getRelations = (tech, type) => {
        const rs = (tech && tech.relations) || [];
        return type ? rs.filter(r => r && r.pivot && r.pivot.type === type) : rs;
@@ -7,6 +17,8 @@ export const getRelations = (tech, type) => {
 
 export const hasRelations = (tech, type) => getRelations(tech, type).length > 0;
 
+export const getLanguages = tech => ['en', ...tech.translations.map(t => t.locale)];
+
 export const getTranslation = (tech, prop, lang) => {
        const direct = tech.translations.find(t => t.locale === lang);
        if (direct) {
@@ -26,6 +38,7 @@ export const sorted = (techs) => [...techs].sort(compareTranslation('title', i18
 
 export default {
        compareTranslation,
+       getLanguages,
        getRelations,
        getTranslation,
        hasRelations,