You've already forked AstralRinth
forked from didirus/AstralRinth
Add versions section
This commit is contained in:
96
pages/mod/_id/version/_version.vue
Normal file
96
pages/mod/_id/version/_version.vue
Normal file
@@ -0,0 +1,96 @@
|
||||
<template>
|
||||
<ModPage :mod="mod" :versions="versions" :members="members">
|
||||
<div class="version"></div>
|
||||
</ModPage>
|
||||
</template>
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
import ModPage from '@/components/ModPage'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ModPage,
|
||||
},
|
||||
auth: false,
|
||||
async asyncData(data) {
|
||||
let res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`
|
||||
)
|
||||
const mod = res.data
|
||||
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/team/${mod.team}/members`
|
||||
)
|
||||
const members = res.data
|
||||
for (let i = 0; i < members.length; i++) {
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/user/${members[i].user_id}`
|
||||
)
|
||||
members[i].avatar_url = res.data.avatar_url
|
||||
}
|
||||
|
||||
const versions = []
|
||||
for (const version of mod.versions) {
|
||||
res = await axios.get(
|
||||
`https://api.modrinth.com/api/v1/version/${version}`
|
||||
)
|
||||
|
||||
versions.push(res.data)
|
||||
}
|
||||
|
||||
return {
|
||||
mod,
|
||||
versions,
|
||||
members,
|
||||
}
|
||||
},
|
||||
head() {
|
||||
return {
|
||||
title: this.mod.title + ' - Modrinth - Files',
|
||||
meta: [
|
||||
{
|
||||
hid: 'description',
|
||||
name: 'description',
|
||||
content:
|
||||
this.mod.description +
|
||||
' View other minecraft mods on Modrinth today! Modrinth is a new and modern Minecraft modding platform that is compatible with CurseForge too!',
|
||||
},
|
||||
|
||||
{
|
||||
hid: 'apple-mobile-web-app-title',
|
||||
name: 'apple-mobile-web-app-title',
|
||||
content: this.mod.title + ' - Modrinth',
|
||||
},
|
||||
{
|
||||
hid: 'og:site_name',
|
||||
name: 'og:site_name',
|
||||
content: this.mod.title + ' - Modrinth',
|
||||
},
|
||||
{
|
||||
hid: 'og:description',
|
||||
name: 'og:description',
|
||||
content: this.mod.description,
|
||||
},
|
||||
{ hid: 'og:type', name: 'og:type', content: 'article' },
|
||||
{
|
||||
hid: 'og:image',
|
||||
name: 'og:image',
|
||||
content: this.mod.icon_url
|
||||
? this.mod.icon_url
|
||||
: 'https://cdn.modrinth.com/placeholder.png',
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.version {
|
||||
background: var(--color-bg);
|
||||
border-radius: 0 0 0.5rem 0.5rem;
|
||||
box-shadow: 0 2px 3px 1px var(--color-grey-2);
|
||||
padding: 1em;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user