it-tools/components/Tool.vue

36 lines
866 B
Vue
Raw Normal View History

2021-02-06 11:14:28 +01:00
<script lang="ts">
import {Component, Vue} from 'nuxt-property-decorator'
2021-02-13 19:55:45 +01:00
import ToolWrapper from '~/components/ToolWrapper.vue'
2021-03-14 23:37:57 +01:00
import type {ToolConfig} from '~/types/ToolConfig'
2021-02-06 11:14:28 +01:00
@Component({components: {ToolWrapper}})
export default class Tool extends Vue {
2021-02-13 19:55:45 +01:00
config(): ToolConfig {
throw new Error('You need to specify a config() method your custom Tool.')
};
2021-02-06 11:14:28 +01:00
public head() {
2021-02-13 19:55:45 +01:00
const {title, description, keywords} = this.config()
2021-02-06 11:14:28 +01:00
2021-05-17 21:18:35 +02:00
const uniqueKeywordsCleaned = [...new Set([...keywords, ...title.split(/\s+/)].map(s => s.trim().toLowerCase()))]
2021-02-06 11:14:28 +01:00
return {
title,
2021-02-13 19:55:45 +01:00
meta: [
{
name: 'description',
2021-03-15 17:38:50 +01:00
content: description,
hid: 'description'
2021-02-13 19:55:45 +01:00
},
{
name: 'keywords',
2021-05-17 21:18:35 +02:00
content: uniqueKeywordsCleaned,
2021-03-15 17:38:50 +01:00
hid: 'keywords'
2021-02-13 19:55:45 +01:00
}
]
2021-02-06 11:14:28 +01:00
}
}
}
</script>