2021-02-12 23:13:59 +00:00
|
|
|
<template lang="html">
|
|
|
|
<div class="game-description">
|
2021-02-25 23:03:07 +00:00
|
|
|
<div v-if="loading" class="mb-4">
|
2021-02-12 23:13:59 +00:00
|
|
|
<b-skeleton
|
|
|
|
v-for="n in 3"
|
|
|
|
:key="n"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<!-- TODO: get images from article and add them to screenshots -->
|
|
|
|
<template v-else>
|
|
|
|
<small>Source: {{ source }}</small>
|
|
|
|
|
|
|
|
<p>
|
2021-02-18 00:52:04 +00:00
|
|
|
<span
|
|
|
|
:class="{'break-spaces': source === 'IGDB' }"
|
|
|
|
v-html="description"
|
|
|
|
/>
|
2021-02-16 23:58:10 +00:00
|
|
|
|
2021-02-19 23:13:38 +00:00
|
|
|
<b-button v-b-modal.wikipediaArticle v-if="source === 'Wikipedia'">
|
2021-02-18 00:52:04 +00:00
|
|
|
<i class="fab fa-wikipedia-w" aria-hidden />
|
|
|
|
Read more
|
|
|
|
</b-button>
|
2021-02-12 23:13:59 +00:00
|
|
|
|
2021-02-18 00:52:04 +00:00
|
|
|
<!-- <template v-if="!trimmedDescription">
|
2021-02-12 23:13:59 +00:00
|
|
|
<div
|
|
|
|
v-html="gameDescription"
|
|
|
|
:class="{'break-spaces': source === 'IGDB' }"
|
|
|
|
/>
|
2021-02-18 00:52:04 +00:00
|
|
|
</template> -->
|
2021-02-12 23:13:59 +00:00
|
|
|
</p>
|
|
|
|
</template>
|
2021-02-18 00:52:04 +00:00
|
|
|
|
|
|
|
<b-modal
|
|
|
|
id="wikipediaArticle"
|
|
|
|
scrollable
|
2021-02-18 23:10:44 +00:00
|
|
|
hide-footer
|
2021-02-21 18:14:46 +00:00
|
|
|
:header-bg-variant="darkTheme ? 'dark' : null"
|
|
|
|
:header-text-variant="darkTheme ? 'white' : null"
|
|
|
|
:body-bg-variant="darkTheme ? 'dark' : null"
|
|
|
|
:body-text-variant="darkTheme ? 'white' : null"
|
2021-02-18 00:52:04 +00:00
|
|
|
>
|
|
|
|
<template v-slot:modal-header="{ close }">
|
|
|
|
<modal-header
|
|
|
|
:title="game.name"
|
|
|
|
subtitle="Wikipedia article"
|
|
|
|
@close="close"
|
|
|
|
>
|
|
|
|
<template v-slot:header>
|
|
|
|
<b-img
|
|
|
|
:src="activeGameCoverUrl"
|
|
|
|
:alt="game.name"
|
|
|
|
class="float-left mr-2"
|
|
|
|
height="40"
|
|
|
|
rounded
|
|
|
|
/>
|
|
|
|
</template>
|
|
|
|
</modal-header>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<p
|
|
|
|
:class="{'break-spaces': source === 'IGDB' }"
|
|
|
|
v-html="gameDescription"
|
|
|
|
/>
|
|
|
|
</b-modal>
|
2021-02-12 23:13:59 +00:00
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2021-02-18 00:52:04 +00:00
|
|
|
import { mapGetters } from 'vuex';
|
2021-02-12 23:13:59 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
props: {
|
|
|
|
game: Object,
|
|
|
|
},
|
|
|
|
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
wikipediaArticle: {},
|
|
|
|
loading: true,
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
computed: {
|
2021-02-21 18:14:46 +00:00
|
|
|
...mapGetters(['darkTheme', 'activeGameCoverUrl']),
|
2021-02-18 00:52:04 +00:00
|
|
|
|
|
|
|
description() {
|
|
|
|
return this.trimmedDescription
|
|
|
|
? this.trimmedDescription
|
|
|
|
: this.gameDescription;
|
|
|
|
},
|
|
|
|
|
2021-02-12 23:13:59 +00:00
|
|
|
gameDescription() {
|
|
|
|
const wikipediaDescription = this.wikipediaArticle && this.wikipediaArticle.extract
|
|
|
|
? this.wikipediaArticle.extract
|
|
|
|
: null;
|
|
|
|
|
|
|
|
const igdbDescription = this.game && this.game.summary
|
|
|
|
? this.game.summary
|
|
|
|
: null;
|
|
|
|
|
2021-02-24 23:07:31 +00:00
|
|
|
// Default to wikipedia, fall back to igdb
|
2021-02-12 23:13:59 +00:00
|
|
|
return wikipediaDescription || igdbDescription;
|
|
|
|
},
|
|
|
|
|
|
|
|
trimmedDescription() {
|
2021-02-16 21:36:19 +00:00
|
|
|
return this.gameDescription && this.gameDescription.length > 600
|
|
|
|
? `${this.gameDescription.substr(0, 600)}...`
|
2021-02-12 23:13:59 +00:00
|
|
|
: null;
|
|
|
|
},
|
|
|
|
|
|
|
|
source() {
|
|
|
|
return this.wikipediaArticle && this.wikipediaArticle.extract
|
|
|
|
? 'Wikipedia'
|
|
|
|
: 'IGDB';
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.loadWikipediaArticle();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
async loadWikipediaArticle() {
|
|
|
|
const wikiData = this.game && this.game.websites
|
2021-02-24 23:07:31 +00:00
|
|
|
? this.game.websites.find(({ url, category }) => {
|
|
|
|
const wikipediaIgdbCategory = 3;
|
|
|
|
|
|
|
|
return url.includes('/wiki/') && category === wikipediaIgdbCategory;
|
|
|
|
})
|
2021-02-12 23:13:59 +00:00
|
|
|
: null;
|
|
|
|
|
|
|
|
if (!wikiData) {
|
|
|
|
this.loading = false;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const articleTitle = wikiData.url.split('/wiki/')[1];
|
|
|
|
|
|
|
|
this.wikipediaArticle = await this.$store.dispatch('LOAD_WIKIPEDIA_ARTICLE', articleTitle)
|
|
|
|
.catch(() => {
|
|
|
|
this.loading = false;
|
|
|
|
});
|
|
|
|
|
|
|
|
this.loading = false;
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" rel="stylesheet/scss" scoped>
|
|
|
|
.break-spaces {
|
|
|
|
white-space: break-spaces;
|
|
|
|
}
|
|
|
|
|
|
|
|
h2 {
|
|
|
|
background-color: red;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<style lang="scss" rel="stylesheet/scss">
|
|
|
|
.game-description {
|
2021-02-16 20:40:04 +00:00
|
|
|
h2, h3 {
|
|
|
|
margin-bottom: 0;
|
|
|
|
padding-bottom: .5rem;
|
|
|
|
}
|
|
|
|
|
2021-02-12 23:13:59 +00:00
|
|
|
h2 {
|
2021-02-16 20:40:04 +00:00
|
|
|
font-size: 24px;
|
|
|
|
top: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
h3 {
|
|
|
|
font-size: 18px;
|
|
|
|
}
|
|
|
|
|
|
|
|
h4, h5, h6 {
|
|
|
|
font-size: 16px;
|
|
|
|
font-weight: bold;
|
2021-02-12 23:13:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
.mw-empty-elt {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
</style>
|