summaryrefslogtreecommitdiff
path: root/src/components/Global/PageTitle.vue
blob: f5e6df92dd4517f3373790ff1bb32f0d5c1584fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<template>
  <div class="page-title">
    <h1>{{ title }}</h1>
    <p v-if="description">{{ description }}</p>
  </div>
</template>

<script>
import i18n from '@/i18n';
export default {
  name: 'PageTitle',
  props: {
    description: {
      type: String,
      default: '',
    },
  },
  data() {
    return {
      title: this.$route.meta.title,
    };
  },
  created() {
    let title = this.$route.name;
    let i = 1;
    if (title) {
      while (i < this.$route.name.split('-').length) {
        let index = title.search('-');
        title = title.replace(
          '-' + title.charAt(index + 1),
          title.charAt(index + 1).toUpperCase()
        );
        i++;
      }
      this.title = i18n.t('appPageTitle.' + title);
      document.title = this.title;
    }
  },
};
</script>

<style lang="scss" scoped>
.page-title {
  margin-bottom: $spacer * 2;
}
p {
  max-width: 72ch;
}
</style>