2018-09-05 23:46:35 +03:00
|
|
|
<template>
|
2018-09-12 23:09:34 +03:00
|
|
|
<v-container grid-list-md>
|
|
|
|
<v-layout
|
|
|
|
row
|
|
|
|
wrap
|
|
|
|
justify-space-between
|
|
|
|
>
|
2018-09-05 23:46:35 +03:00
|
|
|
<v-flex
|
2018-09-12 23:51:13 +03:00
|
|
|
class="mr-3 mt-4"
|
2018-09-12 23:09:34 +03:00
|
|
|
column
|
|
|
|
xs12
|
|
|
|
sm5
|
|
|
|
md3
|
|
|
|
lg3
|
|
|
|
xl1
|
|
|
|
v-for="(groupCategories, groupName, index) in groups"
|
2018-09-05 23:46:35 +03:00
|
|
|
:key="index"
|
|
|
|
>
|
2018-09-12 23:09:34 +03:00
|
|
|
<div class="category-group">
|
|
|
|
<h4 class="display-1 font-weight-black"> {{ groupName }} </h4>
|
|
|
|
<a
|
|
|
|
class="category-title"
|
2018-09-12 23:23:07 +03:00
|
|
|
target="_blank"
|
|
|
|
rel="noopener noreferrer"
|
2018-09-12 23:09:34 +03:00
|
|
|
v-for="(category, index) in groupCategories"
|
|
|
|
:key="index"
|
2018-09-12 23:23:07 +03:00
|
|
|
:href="`https://guide.aelve.com/haskell/${getCategoryUrl(category)}`"
|
2018-09-12 23:09:34 +03:00
|
|
|
>
|
|
|
|
<h6
|
|
|
|
class="ml-2 subheading font-weight-bold"
|
2018-09-05 23:46:35 +03:00
|
|
|
:key="index"
|
2018-09-12 23:09:34 +03:00
|
|
|
>
|
2018-09-05 23:46:35 +03:00
|
|
|
{{ category.title }}
|
2018-09-12 23:09:34 +03:00
|
|
|
</h6>
|
2018-09-05 23:46:35 +03:00
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</v-flex>
|
|
|
|
</v-layout>
|
|
|
|
</v-container>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import _groupBy from 'lodash/groupBy'
|
2018-09-12 23:23:07 +03:00
|
|
|
import _toKebabCase from 'lodash/kebabCase'
|
2018-09-05 23:46:35 +03:00
|
|
|
import Vue from 'vue'
|
|
|
|
import Component from 'vue-class-component'
|
2018-09-12 23:23:07 +03:00
|
|
|
import { ICategory } from 'client/service/Category'
|
2018-09-05 23:46:35 +03:00
|
|
|
|
|
|
|
@Component
|
2018-09-12 23:09:34 +03:00
|
|
|
export default class Categories extends Vue {
|
|
|
|
// TODO add type for store
|
|
|
|
async asyncData({ store }) {
|
|
|
|
return store.dispatch('category/loadCategoryList')
|
|
|
|
}
|
|
|
|
// TODO create state getter and replace to it
|
|
|
|
get categories() {
|
|
|
|
return this.$store.state.category.categoryList
|
2018-09-05 23:46:35 +03:00
|
|
|
}
|
2018-09-12 23:09:34 +03:00
|
|
|
get groups() {
|
|
|
|
return _groupBy(this.categories, 'group')
|
2018-09-05 23:46:35 +03:00
|
|
|
}
|
2018-09-12 23:23:07 +03:00
|
|
|
getCategoryUrl(category: ICategory): string {
|
|
|
|
return `${_toKebabCase(category.title)}-${category.uid}`
|
|
|
|
}
|
2018-09-05 23:46:35 +03:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2018-09-12 23:09:34 +03:00
|
|
|
<style scoped>
|
|
|
|
.category-group {
|
2018-09-05 23:46:35 +03:00
|
|
|
text-align: left;
|
|
|
|
}
|
2018-09-12 23:51:13 +03:00
|
|
|
.category-title:not(:last-child) {
|
|
|
|
margin-bottom: 5px;
|
|
|
|
}
|
2018-09-12 23:09:34 +03:00
|
|
|
.category-title {
|
2018-09-12 23:51:13 +03:00
|
|
|
display: block;
|
2018-09-12 23:09:34 +03:00
|
|
|
text-decoration-line: none;
|
|
|
|
}
|
|
|
|
.category-title:hover {
|
|
|
|
text-decoration-line: underline;
|
|
|
|
}
|
2018-09-05 23:46:35 +03:00
|
|
|
</style>
|