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

58 lines
1.3 KiB
Vue
Raw Normal View History

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