<template>
    <div
        v-if="tag"
        class="content tag"
    >
        <div class="header">
            <span>
                <h2 class="title">{{ tag.name }}</h2>

                <span class="description">{{ tag.description }}</span>
            </span>
        </div>

        <div class="content-inner">
            <h3 class="heading">Latest releases</h3>

            <ul class="nolist scenes">
                <li
                    v-for="release in releases"
                    :key="`release-${release.id}`"
                >
                    <ReleaseTile :release="release" />
                </li>
            </ul>
        </div>
    </div>
</template>

<script>
import ReleaseTile from '../tile/release.vue';

async function mounted() {
    [this.tag] = await this.$store.dispatch('fetchTags', this.$route.params.tagSlug);
    this.releases = await this.$store.dispatch('fetchTagReleases', this.$route.params.tagSlug);

    this.pageTitle = this.tag.name;
}

export default {
    components: {
        ReleaseTile,
    },
    data() {
        return {
            tag: null,
            releases: null,
            pageTitle: null,
        };
    },
    mounted,
};
</script>

<style lang="scss" scoped>
@import 'theme';

.header {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
}

.title {
    display: inline-block;
    margin: 0 .5rem 0 0;
    text-transform: capitalize;
}

.heading {
    padding: 0;
    margin: 0 0 1rem 0;
}

.bio-heading {
    display: inline-block;
    font-weight: bold;
    margin: .5rem 0 0 0;

    &::after {
        content: ':';
    }
}
</style>
