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

65 lines
1.6 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>
<Preview v-if="showPreview" :config="previewConfig" />
2020-07-03 10:42:43 +09:00
<p class="description" v-html="translatedCode.description"></p>
2022-10-07 23:02:40 +09:00
<component v-if="configUI" :is="configUI" :version="version"
:previewConfig="previewConfig" @config="$emit('config', {[code.id]: $event})" />
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 { previewIds } from './codes/preview.js';
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 },
previewConfig: { type: Object },
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];
},
showPreview() {
return previewIds.includes(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>