Piped/src/components/TrendingPage.vue

44 lines
1.0 KiB
Vue
Raw Normal View History

2020-11-17 05:15:35 +00:00
<template>
2021-12-27 14:46:26 +00:00
<h1 v-t="'titles.trending'" class="font-bold text-center" />
2020-11-17 05:15:35 +00:00
<hr />
2021-12-27 14:46:22 +00:00
<div class="video-grid">
<VideoItem v-for="video in videos" :key="video.url" :video="video" height="118" width="210" />
2020-11-17 05:15:35 +00:00
</div>
</template>
<script>
2021-06-16 19:14:46 +00:00
import VideoItem from "@/components/VideoItem.vue";
2020-11-17 05:15:35 +00:00
export default {
components: {
VideoItem,
},
2020-11-17 05:15:35 +00:00
data() {
return {
videos: [],
2020-11-17 05:15:35 +00:00
};
},
mounted() {
let region = this.getPreferenceString("region", "US");
this.fetchTrending(region).then(videos => {
this.videos = videos;
this.updateWatched(this.videos);
});
2020-11-17 05:15:35 +00:00
},
activated() {
document.title = this.$t("titles.trending") + " - Piped";
if (this.videos.length > 0) this.updateWatched(this.videos);
},
2020-11-17 05:15:35 +00:00
methods: {
async fetchTrending(region) {
return await this.fetchJson(this.apiUrl() + "/trending", {
region: region || "US",
});
},
},
2020-11-17 05:15:35 +00:00
};
</script>