gctGenerator/site/.vuepress/components/CodeInfo.vue

58 lines
1.3 KiB
Vue
Raw Normal View History

2020-06-27 23:33:20 +02:00
<template>
<div>
2020-07-03 03:42:43 +02:00
<h3>{{ translatedCode.title }}</h3>
2020-06-27 23:33:20 +02:00
<div class="metadata">
2020-07-10 00:57:16 +02:00
<span>
2020-07-10 00:59:26 +02:00
{{ getLabel('codeinfo.version') }} {{ translatedCode.version }} ({{ translatedCode.date }})
2020-07-10 00:57:16 +02:00
</span>
2020-07-10 00:59:26 +02:00
<span v-if="code.author.includes(',')"
>{{ getLabel('codeinfo.authors') }} {{ translatedCode.author }}</span
>
2020-07-03 03:42:43 +02:00
<span v-else>{{ getLabel('codeinfo.author') }} {{ translatedCode.author }}</span>
2020-06-27 23:33:20 +02:00
</div>
2020-07-03 03:42:43 +02:00
<p class="description" v-html="translatedCode.description"></p>
<component v-if="configUI" :is="configUI" :version="version"></component>
2020-06-27 23:33:20 +02:00
</div>
</template>
<script>
2020-07-03 03:42:43 +02:00
import { translate, translateCode } from '../i18n/localeHelper';
import configUIs from './codes/ui.js';
2020-07-03 03:42:43 +02:00
2020-06-27 23:33:20 +02:00
export default {
props: {
2020-06-28 20:04:31 +02:00
anchor: { type: Boolean },
2020-06-27 23:33:20 +02:00
code: { type: Object },
version: { type: String },
2020-06-27 23:33:20 +02:00
},
2020-07-10 00:57:16 +02:00
computed: {
2020-07-10 00:59:26 +02:00
translatedCode: function () {
2020-07-10 02:39:45 +02:00
return translateCode(this.code, this.$lang);
2020-07-10 00:59:26 +02:00
},
configUI: function () {
return configUIs[this.code.id];
},
2020-07-03 03:42:43 +02:00
},
2020-06-28 20:04:31 +02:00
data() {
2020-07-10 00:57:16 +02:00
return {};
2020-06-28 20:04:31 +02:00
},
2020-07-03 03:42:43 +02:00
methods: {
getLabel(key) {
return translate(key, this.$lang);
},
},
2020-06-27 23:33:20 +02:00
};
</script>
<style scoped>
.metadata span {
display: block;
font-style: italic;
font-size: 0.9rem;
}
.description td {
padding: 0;
}
</style>