You've already forked AstralRinth
forked from didirus/AstralRinth
Move mod pages to nuxt child (#201)
* Move mod pages to nuxt child * Minor fixes * Fix lockfile
This commit is contained in:
772
pages/mod/_id.vue
Normal file
772
pages/mod/_id.vue
Normal file
@@ -0,0 +1,772 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="page-contents">
|
||||
<div class="content">
|
||||
<div class="header">
|
||||
<div class="icon">
|
||||
<img
|
||||
:src="
|
||||
mod.icon_url
|
||||
? mod.icon_url
|
||||
: 'https://cdn.modrinth.com/placeholder.svg?inline'
|
||||
"
|
||||
alt="mod - icon"
|
||||
/>
|
||||
</div>
|
||||
<div class="info">
|
||||
<h1 class="title">{{ mod.title }}</h1>
|
||||
<p class="description">
|
||||
{{ mod.description }}
|
||||
</p>
|
||||
<div class="alt-nav">
|
||||
<p>
|
||||
<nuxt-link to="/mods"> Mods </nuxt-link>
|
||||
>
|
||||
<nuxt-link :to="'/mod/' + (mod.slug ? mod.slug : mod.id)">{{
|
||||
mod.title
|
||||
}}</nuxt-link>
|
||||
<span v-if="linkBar.length > 0"> ></span>
|
||||
<nuxt-link
|
||||
v-for="(link, index) in linkBar"
|
||||
:key="index"
|
||||
:to="/mod/ + (mod.slug ? mod.slug : mod.id) + '/' + link[1]"
|
||||
>{{ link[0] }}
|
||||
<span v-if="index !== linkBar.length - 1"> > </span>
|
||||
</nuxt-link>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="buttons">
|
||||
<nuxt-link
|
||||
v-if="this.$auth.user"
|
||||
:to="`/report/create?id=${mod.id}&t=mod`"
|
||||
class="iconified-button"
|
||||
>
|
||||
<ReportIcon />
|
||||
Report
|
||||
</nuxt-link>
|
||||
<button
|
||||
v-if="userFollows && !userFollows.includes(mod.id)"
|
||||
class="iconified-button"
|
||||
@click="followMod"
|
||||
>
|
||||
<FollowIcon />
|
||||
Follow
|
||||
</button>
|
||||
<button
|
||||
v-if="userFollows && userFollows.includes(mod.id)"
|
||||
class="iconified-button"
|
||||
@click="unfollowMod"
|
||||
>
|
||||
<FollowIcon fill="currentColor" />
|
||||
Unfollow
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<Advertisement
|
||||
v-if="mod.status === 'approved' || mod.status === 'unlisted'"
|
||||
type="banner"
|
||||
small-screen="square"
|
||||
/>
|
||||
<div class="mod-navigation">
|
||||
<div class="tabs">
|
||||
<nuxt-link
|
||||
:to="'/mod/' + (mod.slug ? mod.slug : mod.id)"
|
||||
class="tab"
|
||||
>
|
||||
<span>Description</span>
|
||||
</nuxt-link>
|
||||
<nuxt-link
|
||||
:to="'/mod/' + (mod.slug ? mod.slug : mod.id) + '/versions'"
|
||||
class="tab"
|
||||
>
|
||||
<span>Versions</span>
|
||||
</nuxt-link>
|
||||
<nuxt-link
|
||||
v-if="currentMember"
|
||||
:to="'/mod/' + (mod.slug ? mod.slug : mod.id) + '/settings'"
|
||||
class="tab"
|
||||
>
|
||||
<span>Settings</span>
|
||||
</nuxt-link>
|
||||
<a
|
||||
v-if="mod.wiki_url"
|
||||
:href="mod.wiki_url"
|
||||
target="_blank"
|
||||
class="tab"
|
||||
>
|
||||
<ExternalIcon />
|
||||
<span>Wiki</span>
|
||||
</a>
|
||||
<a
|
||||
v-if="mod.issues_url"
|
||||
:href="mod.issues_url"
|
||||
target="_blank"
|
||||
class="tab"
|
||||
>
|
||||
<ExternalIcon />
|
||||
<span>Issues</span>
|
||||
</a>
|
||||
<a
|
||||
v-if="mod.source_url"
|
||||
:href="mod.source_url"
|
||||
target="_blank"
|
||||
class="tab"
|
||||
>
|
||||
<ExternalIcon />
|
||||
<span>Source</span>
|
||||
</a>
|
||||
<a
|
||||
v-if="mod.discord_url"
|
||||
:href="mod.discord_url"
|
||||
target="_blank"
|
||||
class="tab"
|
||||
>
|
||||
<ExternalIcon />
|
||||
<span>Discord</span>
|
||||
</a>
|
||||
<div class="filler" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="mod-content">
|
||||
<NuxtChild
|
||||
:mod="mod"
|
||||
:versions="versions"
|
||||
:featured-versions="featuredVersions"
|
||||
:members="members"
|
||||
:current-member="currentMember"
|
||||
:link-bar.sync="linkBar"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<section class="mod-info">
|
||||
<div class="mod-stats section">
|
||||
<div class="stat">
|
||||
<DownloadIcon />
|
||||
<div class="info">
|
||||
<h4>Downloads</h4>
|
||||
<p class="value">{{ formatNumber(mod.downloads) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<CalendarIcon />
|
||||
<div class="info">
|
||||
<h4>Created</h4>
|
||||
<p
|
||||
v-tooltip="
|
||||
$dayjs(mod.published).format(
|
||||
'[Created on] YYYY-MM-DD [at] HH:mm A'
|
||||
)
|
||||
"
|
||||
class="value"
|
||||
>
|
||||
{{ $dayjs(mod.published).fromNow() }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<TagIcon />
|
||||
<div class="info">
|
||||
<h4>Available For</h4>
|
||||
<p class="value">
|
||||
{{
|
||||
versions[0]
|
||||
? versions[0].game_versions[0]
|
||||
? versions[0].game_versions[
|
||||
versions[0].game_versions.length - 1
|
||||
]
|
||||
: 'None'
|
||||
: 'None'
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<EditIcon />
|
||||
<div class="info">
|
||||
<h4>Updated</h4>
|
||||
<p
|
||||
v-tooltip="
|
||||
$dayjs(mod.updated).format(
|
||||
'[Updated on] YYYY-MM-DD [at] HH:mm A'
|
||||
)
|
||||
"
|
||||
class="value"
|
||||
>
|
||||
{{ $dayjs(mod.updated).fromNow() }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<ClientIcon />
|
||||
<div class="info">
|
||||
<h4>Client Side</h4>
|
||||
<p class="value capitalize">{{ mod.client_side }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<ServerIcon />
|
||||
<div class="info">
|
||||
<h4>Server Side</h4>
|
||||
<p class="value capitalize">{{ mod.server_side }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<FileTextIcon />
|
||||
<div class="info">
|
||||
<h4>License</h4>
|
||||
<p v-tooltip="mod.license.name" class="value ellipsis">
|
||||
<a
|
||||
v-if="mod.license.url ? mod.license.url : '#'"
|
||||
:href="mod.license.url"
|
||||
>
|
||||
{{ mod.license.id.toUpperCase() }}</a
|
||||
>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="stat">
|
||||
<CodeIcon />
|
||||
<div class="info">
|
||||
<h4>Project ID</h4>
|
||||
<p class="value">{{ mod.id }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<Categories :categories="mod.categories.concat(mod.loaders)" />
|
||||
</div>
|
||||
<div class="section">
|
||||
<h3>Members</h3>
|
||||
<div
|
||||
v-for="member in members"
|
||||
:key="member.user_id"
|
||||
class="team-member columns"
|
||||
>
|
||||
<img :src="member.avatar_url" alt="profile-picture" />
|
||||
<div class="member-info">
|
||||
<nuxt-link :to="'/user/' + member.user_id">
|
||||
<h4>{{ member.name }}</h4>
|
||||
</nuxt-link>
|
||||
<h3>{{ member.role }}</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="featuredVersions.length > 0" class="section">
|
||||
<h3>Featured Versions</h3>
|
||||
<div
|
||||
v-for="version in featuredVersions"
|
||||
:key="version.id"
|
||||
class="featured-version"
|
||||
>
|
||||
<a
|
||||
:href="findPrimary(version).url"
|
||||
class="download"
|
||||
@click.prevent="
|
||||
downloadFile(
|
||||
findPrimary(version).hashes.sha1,
|
||||
findPrimary(version).url
|
||||
)
|
||||
"
|
||||
>
|
||||
<DownloadIcon />
|
||||
</a>
|
||||
<div class="info">
|
||||
<div class="top">
|
||||
<span
|
||||
v-if="version.version_type === 'release'"
|
||||
class="badge green"
|
||||
>
|
||||
Release
|
||||
</span>
|
||||
<span
|
||||
v-if="version.version_type === 'beta'"
|
||||
class="badge yellow"
|
||||
>
|
||||
Beta
|
||||
</span>
|
||||
<span v-if="version.version_type === 'alpha'" class="badge red">
|
||||
Alpha
|
||||
</span>
|
||||
<h4 class="title">
|
||||
<nuxt-link
|
||||
:to="
|
||||
'/mod/' +
|
||||
(mod.slug ? mod.slug : mod.id) +
|
||||
'/version/' +
|
||||
version.id
|
||||
"
|
||||
>
|
||||
{{ version.name }}
|
||||
</nuxt-link>
|
||||
</h4>
|
||||
</div>
|
||||
<div class="bottom">
|
||||
<span class="version-number limit-text-width">
|
||||
{{ version.version_number }} ·
|
||||
</span>
|
||||
<FabricIcon
|
||||
v-if="version.loaders.includes('fabric')"
|
||||
class="loader"
|
||||
/>
|
||||
<ForgeIcon
|
||||
v-if="version.loaders.includes('forge')"
|
||||
class="loader"
|
||||
/>
|
||||
<span
|
||||
v-if="version.game_versions.length > 0"
|
||||
class="game-version limit-text-width"
|
||||
>
|
||||
·
|
||||
{{ version.game_versions[version.game_versions.length - 1] }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="mod.donation_urls && mod.donation_urls.length > 0"
|
||||
class="section"
|
||||
>
|
||||
<h3>Donation Links</h3>
|
||||
<div
|
||||
v-for="(item, index) in mod.donation_urls"
|
||||
:key="index"
|
||||
class="links"
|
||||
>
|
||||
<a :href="item.url" class="link">
|
||||
<ExternalIcon />
|
||||
{{ item.platform }}
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<Advertisement
|
||||
v-if="mod.status === 'approved' || mod.status === 'unlisted'"
|
||||
type="square"
|
||||
small-screen="destroy"
|
||||
/>
|
||||
<m-footer class="footer" />
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
import Categories from '~/components/ui/search/Categories'
|
||||
import MFooter from '~/components/layout/MFooter'
|
||||
|
||||
import CalendarIcon from '~/assets/images/utils/calendar.svg?inline'
|
||||
import DownloadIcon from '~/assets/images/utils/download.svg?inline'
|
||||
import EditIcon from '~/assets/images/utils/edit.svg?inline'
|
||||
import TagIcon from '~/assets/images/utils/tag.svg?inline'
|
||||
import ClientIcon from '~/assets/images/utils/client.svg?inline'
|
||||
import ServerIcon from '~/assets/images/utils/server.svg?inline'
|
||||
import FileTextIcon from '~/assets/images/utils/file-text.svg?inline'
|
||||
import CodeIcon from '~/assets/images/sidebar/mod.svg?inline'
|
||||
import ReportIcon from '~/assets/images/utils/report.svg?inline'
|
||||
import FollowIcon from '~/assets/images/utils/heart.svg?inline'
|
||||
|
||||
import ExternalIcon from '~/assets/images/utils/external.svg?inline'
|
||||
|
||||
import ForgeIcon from '~/assets/images/categories/forge.svg?inline'
|
||||
import FabricIcon from '~/assets/images/categories/fabric.svg?inline'
|
||||
import Advertisement from '~/components/ads/Advertisement'
|
||||
|
||||
export default {
|
||||
name: 'ModPage',
|
||||
components: {
|
||||
Advertisement,
|
||||
MFooter,
|
||||
Categories,
|
||||
ExternalIcon,
|
||||
ForgeIcon,
|
||||
FabricIcon,
|
||||
DownloadIcon,
|
||||
CalendarIcon,
|
||||
EditIcon,
|
||||
TagIcon,
|
||||
ClientIcon,
|
||||
ServerIcon,
|
||||
FileTextIcon,
|
||||
CodeIcon,
|
||||
ReportIcon,
|
||||
FollowIcon,
|
||||
},
|
||||
async asyncData(data) {
|
||||
try {
|
||||
const mod = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
|
||||
const [members, versions, featuredVersions, userFollows] = (
|
||||
await Promise.all([
|
||||
axios.get(`https://api.modrinth.com/api/v1/team/${mod.team}/members`),
|
||||
axios.get(`https://api.modrinth.com/api/v1/mod/${mod.id}/version`),
|
||||
axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${mod.id}/version?featured=true`
|
||||
),
|
||||
axios.get(
|
||||
data.$auth.user
|
||||
? `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`
|
||||
: `https://api.modrinth.com`,
|
||||
data.$auth.headers
|
||||
),
|
||||
])
|
||||
).map((it) => it.data)
|
||||
|
||||
const users = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
|
||||
members.map((it) => it.user_id)
|
||||
)}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
|
||||
users.forEach((it) => {
|
||||
const index = members.findIndex((x) => x.user_id === it.id)
|
||||
members[index].avatar_url = it.avatar_url
|
||||
members[index].name = it.username
|
||||
})
|
||||
|
||||
const currentMember = data.$auth.user
|
||||
? members.find((x) => x.user_id === data.$auth.user.id)
|
||||
: null
|
||||
|
||||
return {
|
||||
mod,
|
||||
versions,
|
||||
featuredVersions,
|
||||
members,
|
||||
currentMember,
|
||||
userFollows: userFollows.name ? null : userFollows,
|
||||
linkBar: [],
|
||||
}
|
||||
} catch {
|
||||
data.error({
|
||||
statusCode: 404,
|
||||
message: 'Mod not found',
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
formatNumber(x) {
|
||||
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
||||
},
|
||||
findPrimary(version) {
|
||||
let file = version.files.find((x) => x.primary)
|
||||
|
||||
if (!file) {
|
||||
file = version.files[0]
|
||||
}
|
||||
|
||||
if (!file) {
|
||||
file = { url: `/mod/${this.mod.id}/version/${version.id}` }
|
||||
}
|
||||
|
||||
return file
|
||||
},
|
||||
async downloadFile(hash, url) {
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/version_file/${hash}/download`
|
||||
)
|
||||
|
||||
const elem = document.createElement('a')
|
||||
elem.download = hash
|
||||
elem.href = url
|
||||
elem.click()
|
||||
},
|
||||
async followMod() {
|
||||
await axios.post(
|
||||
`https://api.modrinth.com/api/v1/mod/${this.mod.id}/follow`,
|
||||
{},
|
||||
this.$auth.headers
|
||||
)
|
||||
|
||||
this.userFollows.push(this.mod.id)
|
||||
},
|
||||
async unfollowMod() {
|
||||
await axios.delete(
|
||||
`https://api.modrinth.com/api/v1/mod/${this.mod.id}/follow`,
|
||||
this.$auth.headers
|
||||
)
|
||||
|
||||
this.userFollows.splice(this.userFollows.indexOf(this.mod.id), 1)
|
||||
},
|
||||
},
|
||||
head() {
|
||||
return {
|
||||
title: this.mod.title + ' - Modrinth',
|
||||
meta: [
|
||||
{
|
||||
hid: 'og:type',
|
||||
name: 'og:type',
|
||||
content: 'website',
|
||||
},
|
||||
{
|
||||
hid: 'og:title',
|
||||
name: 'og:title',
|
||||
content: this.mod.title,
|
||||
},
|
||||
{
|
||||
hid: 'apple-mobile-web-app-title',
|
||||
name: 'apple-mobile-web-app-title',
|
||||
content: this.mod.title,
|
||||
},
|
||||
{
|
||||
hid: 'og:description',
|
||||
name: 'og:description',
|
||||
content: this.mod.description,
|
||||
},
|
||||
{
|
||||
hid: 'description',
|
||||
name: 'description',
|
||||
content:
|
||||
this.mod.description +
|
||||
' View other minecraft mods on Modrinth today! Modrinth is a new and modern Minecraft modding platform supporting both the Forge and Fabric mod loaders.',
|
||||
},
|
||||
{
|
||||
hid: 'og:url',
|
||||
name: 'og:url',
|
||||
content: `https://modrinth.com/mod/${this.mod.id}`,
|
||||
},
|
||||
{
|
||||
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>
|
||||
.header {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
text-align: center;
|
||||
|
||||
@extend %card-spaced-b;
|
||||
width: 100%;
|
||||
.icon {
|
||||
margin: auto 0;
|
||||
img {
|
||||
width: 6rem;
|
||||
height: 6rem;
|
||||
margin: var(--spacing-card-md);
|
||||
border-radius: var(--size-rounded-icon);
|
||||
object-fit: contain;
|
||||
}
|
||||
}
|
||||
.info {
|
||||
@extend %column;
|
||||
.title {
|
||||
margin: var(--spacing-card-md) var(--spacing-card-md) 0 0;
|
||||
color: var(--color-text-dark);
|
||||
font-size: var(--font-size-lg);
|
||||
}
|
||||
.description {
|
||||
margin: var(--spacing-card-sm) var(--spacing-card-md) 0 0;
|
||||
color: var(--color-text-dark);
|
||||
}
|
||||
.alt-nav {
|
||||
margin: var(--spacing-card-sm) var(--spacing-card-md) 0 0;
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
.buttons {
|
||||
@extend %row;
|
||||
margin: var(--spacing-card-md) var(--spacing-card-md) var(--spacing-card-md)
|
||||
0;
|
||||
|
||||
button,
|
||||
a {
|
||||
margin: 0.2rem 0 0 0.2rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (min-width: 1024px) {
|
||||
align-items: unset;
|
||||
text-align: unset;
|
||||
flex-direction: row;
|
||||
|
||||
.buttons {
|
||||
flex-direction: column;
|
||||
margin-left: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.mod-navigation {
|
||||
@extend %card-spaced-b;
|
||||
padding-bottom: 0.2rem;
|
||||
}
|
||||
|
||||
.mod-info {
|
||||
height: auto;
|
||||
|
||||
@media screen and (min-width: 1024px) {
|
||||
width: 30rem;
|
||||
margin-left: var(--spacing-card-lg);
|
||||
}
|
||||
|
||||
.section {
|
||||
padding: var(--spacing-card-sm);
|
||||
@extend %card-spaced-b;
|
||||
}
|
||||
|
||||
h3 {
|
||||
@extend %large-label;
|
||||
}
|
||||
|
||||
.mod-stats {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
margin-top: 0;
|
||||
p {
|
||||
max-width: 6rem;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: '';
|
||||
margin: 3px;
|
||||
}
|
||||
.stat {
|
||||
width: 8.5rem;
|
||||
margin: 0.75rem;
|
||||
@extend %stat;
|
||||
|
||||
svg {
|
||||
padding: 0.25rem;
|
||||
border-radius: 50%;
|
||||
background-color: var(--color-button-bg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.team-member {
|
||||
margin-left: 5px;
|
||||
margin-bottom: 10px;
|
||||
|
||||
img {
|
||||
border-radius: var(--size-rounded-icon);
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
}
|
||||
.member-info {
|
||||
max-width: 150px;
|
||||
overflow: hidden;
|
||||
margin: auto 0 auto 0.5rem;
|
||||
h4 {
|
||||
font-weight: normal;
|
||||
margin: 0;
|
||||
}
|
||||
h3 {
|
||||
margin-top: 0.1rem;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.featured-version {
|
||||
@extend %row;
|
||||
padding-top: var(--spacing-card-sm);
|
||||
padding-bottom: var(--spacing-card-sm);
|
||||
.download {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 2.25rem;
|
||||
width: 2.25rem;
|
||||
border-radius: 2rem;
|
||||
background-color: var(--color-button-bg);
|
||||
margin-right: var(--spacing-card-sm);
|
||||
svg {
|
||||
width: 1.25rem;
|
||||
margin: auto;
|
||||
}
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.info {
|
||||
@extend %column;
|
||||
font-size: var(--font-size-xs);
|
||||
.top {
|
||||
@extend %row;
|
||||
.badge {
|
||||
font-size: var(--font-size-xs);
|
||||
margin-right: var(--spacing-card-sm);
|
||||
}
|
||||
.title {
|
||||
margin: auto 0;
|
||||
}
|
||||
}
|
||||
.bottom {
|
||||
margin-top: 0.25rem;
|
||||
@extend %row;
|
||||
.loader {
|
||||
height: 1rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.links {
|
||||
padding: 0.5rem 1rem;
|
||||
|
||||
.link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0.25rem 0;
|
||||
|
||||
svg {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
margin-right: 0.3rem;
|
||||
}
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
padding-bottom: calc(0.25rem - 3px);
|
||||
border-bottom: 3px solid var(--color-brand-disabled);
|
||||
color: var(--color-text-medium);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.limit-text-width {
|
||||
display: inline-block;
|
||||
height: 1em;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
@media screen and (max-width: 550px) {
|
||||
.title a {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 800px) {
|
||||
.mod-navigation {
|
||||
display: block;
|
||||
overflow-x: auto;
|
||||
overflow-wrap: break-word;
|
||||
overflow-y: hidden;
|
||||
}
|
||||
}
|
||||
/*
|
||||
@media screen and (max-width: 1400px) {
|
||||
.mod-info {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
*/
|
||||
</style>
|
||||
@@ -1,302 +1,298 @@
|
||||
<template>
|
||||
<div class="page-container">
|
||||
<div class="page-contents">
|
||||
<header class="columns">
|
||||
<h3 class="column-grow-1">Edit Mod</h3>
|
||||
<nuxt-link
|
||||
:to="'/mod/' + (mod.slug ? mod.slug : mod.id)"
|
||||
class="button column"
|
||||
>
|
||||
Back
|
||||
</nuxt-link>
|
||||
<button
|
||||
v-if="mod.status === 'rejected' || mod.status === 'draft'"
|
||||
title="Submit for Review"
|
||||
class="button column"
|
||||
:disabled="!this.$nuxt.$loading"
|
||||
@click="saveModReview"
|
||||
>
|
||||
Submit for Review
|
||||
</button>
|
||||
<button
|
||||
title="Save"
|
||||
class="brand-button column"
|
||||
:disabled="!this.$nuxt.$loading"
|
||||
@click="saveMod"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</header>
|
||||
<section class="essentials">
|
||||
<h3>Name</h3>
|
||||
<label>
|
||||
<span>
|
||||
Be creative. TechCraft v7 won't be searchable and won't be clicked
|
||||
on
|
||||
</span>
|
||||
<input v-model="mod.title" type="text" placeholder="Enter the name" />
|
||||
</label>
|
||||
<h3>Summary</h3>
|
||||
<label>
|
||||
<span>
|
||||
Give a quick description to your mod. It will appear in the search
|
||||
</span>
|
||||
<input
|
||||
v-model="mod.description"
|
||||
type="text"
|
||||
placeholder="Enter the summary"
|
||||
/>
|
||||
</label>
|
||||
<h3>Categories</h3>
|
||||
<label>
|
||||
<span>
|
||||
Select up to 3 categories. They will help to find your mod
|
||||
</span>
|
||||
<multiselect
|
||||
id="categories"
|
||||
v-model="mod.categories"
|
||||
:options="availableCategories"
|
||||
:loading="availableCategories.length === 0"
|
||||
:multiple="true"
|
||||
:searchable="false"
|
||||
:show-no-results="false"
|
||||
:close-on-select="false"
|
||||
:clear-on-select="false"
|
||||
:show-labels="false"
|
||||
:max="3"
|
||||
:limit="6"
|
||||
:hide-selected="true"
|
||||
placeholder="Choose categories"
|
||||
/>
|
||||
</label>
|
||||
<h3>Vanity URL (slug)</h3>
|
||||
<label>
|
||||
<span>
|
||||
Set this to something pretty, so URLs to your mod are more readable
|
||||
</span>
|
||||
<input
|
||||
id="name"
|
||||
v-model="mod.slug"
|
||||
type="text"
|
||||
placeholder="Enter the vanity URL's last bit"
|
||||
/>
|
||||
</label>
|
||||
</section>
|
||||
<section class="mod-icon rows">
|
||||
<h3>Icon</h3>
|
||||
<div class="columns row-grow-1">
|
||||
<div class="column-grow-1 rows">
|
||||
<file-input
|
||||
accept="image/png,image/jpeg,image/gif,image/webp"
|
||||
class="choose-image"
|
||||
prompt="Choose image or drag it here"
|
||||
@change="showPreviewImage"
|
||||
/>
|
||||
<ul class="row-grow-1">
|
||||
<li>Must be a square</li>
|
||||
<li>Minimum size is 100x100</li>
|
||||
<li>Acceptable formats are PNG, JPEG, GIF and WEBP</li>
|
||||
</ul>
|
||||
<button
|
||||
class="transparent-button"
|
||||
@click="
|
||||
icon = null
|
||||
previewImage = null
|
||||
iconChanged = true
|
||||
"
|
||||
>
|
||||
Reset icon
|
||||
</button>
|
||||
</div>
|
||||
<img
|
||||
:src="
|
||||
previewImage
|
||||
? previewImage
|
||||
: mod.icon_url && !iconChanged
|
||||
? mod.icon_url
|
||||
: 'https://cdn.modrinth.com/placeholder.svg'
|
||||
"
|
||||
alt="preview-image"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
<section class="game-sides">
|
||||
<h3>Supported environments</h3>
|
||||
<div class="columns">
|
||||
<span>
|
||||
Let others know if your mod is for clients, servers or universal.
|
||||
For example, IC2 will be required + required, while OptiFine will be
|
||||
required + no functionality
|
||||
</span>
|
||||
<div class="labeled-control">
|
||||
<h3>Client</h3>
|
||||
<Multiselect
|
||||
v-model="clientSideType"
|
||||
placeholder="Select one"
|
||||
:options="sideTypes"
|
||||
:searchable="false"
|
||||
:close-on-select="true"
|
||||
:show-labels="false"
|
||||
:allow-empty="false"
|
||||
/>
|
||||
</div>
|
||||
<div class="labeled-control">
|
||||
<h3>Server</h3>
|
||||
<Multiselect
|
||||
v-model="serverSideType"
|
||||
placeholder="Select one"
|
||||
:options="sideTypes"
|
||||
:searchable="false"
|
||||
:close-on-select="true"
|
||||
:show-labels="false"
|
||||
:allow-empty="false"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="description">
|
||||
<h3>
|
||||
<label
|
||||
for="body"
|
||||
title="You can type the of the long form of your description here."
|
||||
>
|
||||
Description
|
||||
</label>
|
||||
</h3>
|
||||
<div class="page-contents">
|
||||
<header class="columns">
|
||||
<h3 class="column-grow-1">Edit Mod</h3>
|
||||
<nuxt-link
|
||||
:to="'/mod/' + (mod.slug ? mod.slug : mod.id)"
|
||||
class="button column"
|
||||
>
|
||||
Back
|
||||
</nuxt-link>
|
||||
<button
|
||||
v-if="mod.status === 'rejected' || mod.status === 'draft'"
|
||||
title="Submit for Review"
|
||||
class="button column"
|
||||
:disabled="!this.$nuxt.$loading"
|
||||
@click="saveModReview"
|
||||
>
|
||||
Submit for Review
|
||||
</button>
|
||||
<button
|
||||
title="Save"
|
||||
class="brand-button column"
|
||||
:disabled="!this.$nuxt.$loading"
|
||||
@click="saveMod"
|
||||
>
|
||||
Save
|
||||
</button>
|
||||
</header>
|
||||
<section class="essentials">
|
||||
<h3>Name</h3>
|
||||
<label>
|
||||
<span>
|
||||
You can type the of the long form of your description here. This
|
||||
editor supports markdown. You can find the syntax
|
||||
<a
|
||||
href="https://guides.github.com/features/mastering-markdown/"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>here</a
|
||||
>.
|
||||
Be creative. TechCraft v7 won't be searchable and won't be clicked on
|
||||
</span>
|
||||
<div class="columns">
|
||||
<div class="textarea-wrapper">
|
||||
<textarea id="body" v-model="mod.body"></textarea>
|
||||
</div>
|
||||
<div v-compiled-markdown="mod.body" class="markdown-body"></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="extra-links">
|
||||
<div class="title">
|
||||
<h3>External links</h3>
|
||||
</div>
|
||||
<label
|
||||
title="A place for users to report bugs, issues, and concerns about your mod."
|
||||
>
|
||||
<span>Issue tracker</span>
|
||||
<input
|
||||
v-model="mod.issues_url"
|
||||
type="url"
|
||||
placeholder="Enter a valid URL"
|
||||
<input v-model="mod.title" type="text" placeholder="Enter the name" />
|
||||
</label>
|
||||
<h3>Summary</h3>
|
||||
<label>
|
||||
<span>
|
||||
Give a quick description to your mod. It will appear in the search
|
||||
</span>
|
||||
<input
|
||||
v-model="mod.description"
|
||||
type="text"
|
||||
placeholder="Enter the summary"
|
||||
/>
|
||||
</label>
|
||||
<h3>Categories</h3>
|
||||
<label>
|
||||
<span>
|
||||
Select up to 3 categories. They will help to find your mod
|
||||
</span>
|
||||
<multiselect
|
||||
id="categories"
|
||||
v-model="mod.categories"
|
||||
:options="availableCategories"
|
||||
:loading="availableCategories.length === 0"
|
||||
:multiple="true"
|
||||
:searchable="false"
|
||||
:show-no-results="false"
|
||||
:close-on-select="false"
|
||||
:clear-on-select="false"
|
||||
:show-labels="false"
|
||||
:max="3"
|
||||
:limit="6"
|
||||
:hide-selected="true"
|
||||
placeholder="Choose categories"
|
||||
/>
|
||||
</label>
|
||||
<h3>Vanity URL (slug)</h3>
|
||||
<label>
|
||||
<span>
|
||||
Set this to something pretty, so URLs to your mod are more readable
|
||||
</span>
|
||||
<input
|
||||
id="name"
|
||||
v-model="mod.slug"
|
||||
type="text"
|
||||
placeholder="Enter the vanity URL's last bit"
|
||||
/>
|
||||
</label>
|
||||
</section>
|
||||
<section class="mod-icon rows">
|
||||
<h3>Icon</h3>
|
||||
<div class="columns row-grow-1">
|
||||
<div class="column-grow-1 rows">
|
||||
<file-input
|
||||
accept="image/png,image/jpeg,image/gif,image/webp"
|
||||
class="choose-image"
|
||||
prompt="Choose image or drag it here"
|
||||
@change="showPreviewImage"
|
||||
/>
|
||||
</label>
|
||||
<label title="A page/repository containing the source code">
|
||||
<span>Source code</span>
|
||||
<input
|
||||
v-model="mod.source_url"
|
||||
type="url"
|
||||
placeholder="Enter a valid URL"
|
||||
/>
|
||||
</label>
|
||||
<label
|
||||
title="A page containing information, documentation, and help for the mod."
|
||||
>
|
||||
<span>Wiki page</span>
|
||||
<input
|
||||
v-model="mod.wiki_url"
|
||||
type="url"
|
||||
placeholder="Enter a valid URL"
|
||||
/>
|
||||
</label>
|
||||
<label title="An inivitation link to your Discord server.">
|
||||
<span>Discord invite</span>
|
||||
<input
|
||||
v-model="mod.discord_url"
|
||||
type="url"
|
||||
placeholder="Enter a valid URL"
|
||||
/>
|
||||
</label>
|
||||
</section>
|
||||
<section class="license">
|
||||
<div class="title">
|
||||
<h3>License</h3>
|
||||
</div>
|
||||
<label>
|
||||
<span>
|
||||
It is really important to choose a proper license for your mod. You
|
||||
may choose one from our list or provide a URL to your own license.
|
||||
URL field will be filled automatically for provided licenses
|
||||
</span>
|
||||
<div class="input-group">
|
||||
<Multiselect
|
||||
v-model="license"
|
||||
placeholder="Select one"
|
||||
track-by="short"
|
||||
label="name"
|
||||
:options="availableLicenses"
|
||||
:searchable="true"
|
||||
:close-on-select="true"
|
||||
:show-labels="false"
|
||||
/>
|
||||
<input v-model="license_url" type="url" placeholder="License URL" />
|
||||
</div>
|
||||
</label>
|
||||
</section>
|
||||
<section class="donations">
|
||||
<div class="title">
|
||||
<h3>Donation links</h3>
|
||||
<ul class="row-grow-1">
|
||||
<li>Must be a square</li>
|
||||
<li>Minimum size is 100x100</li>
|
||||
<li>Acceptable formats are PNG, JPEG, GIF and WEBP</li>
|
||||
</ul>
|
||||
<button
|
||||
title="Add a link"
|
||||
class="button"
|
||||
:disabled="false"
|
||||
class="transparent-button"
|
||||
@click="
|
||||
donationPlatforms.push({})
|
||||
donationLinks.push('')
|
||||
icon = null
|
||||
previewImage = null
|
||||
iconChanged = true
|
||||
"
|
||||
>
|
||||
Add a link
|
||||
Reset icon
|
||||
</button>
|
||||
</div>
|
||||
<div v-for="(item, index) in donationPlatforms" :key="index">
|
||||
<label title="The donation link.">
|
||||
<span>Donation Link</span>
|
||||
<input
|
||||
v-model="donationLinks[index]"
|
||||
type="url"
|
||||
placeholder="Enter a valid URL"
|
||||
/>
|
||||
</label>
|
||||
<label title="The donation platform of the link.">
|
||||
<span>Donation Platform</span>
|
||||
<Multiselect
|
||||
v-model="donationPlatforms[index]"
|
||||
placeholder="Select one"
|
||||
track-by="short"
|
||||
label="name"
|
||||
:options="availableDonationPlatforms"
|
||||
:searchable="false"
|
||||
:close-on-select="true"
|
||||
:show-labels="false"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
class="button"
|
||||
@click="
|
||||
donationPlatforms.splice(index, 1)
|
||||
donationLinks.splice(index, 1)
|
||||
"
|
||||
>
|
||||
Remove Link
|
||||
</button>
|
||||
<hr />
|
||||
<img
|
||||
:src="
|
||||
previewImage
|
||||
? previewImage
|
||||
: mod.icon_url && !iconChanged
|
||||
? mod.icon_url
|
||||
: 'https://cdn.modrinth.com/placeholder.svg'
|
||||
"
|
||||
alt="preview-image"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
<section class="game-sides">
|
||||
<h3>Supported environments</h3>
|
||||
<div class="columns">
|
||||
<span>
|
||||
Let others know if your mod is for clients, servers or universal. For
|
||||
example, IC2 will be required + required, while OptiFine will be
|
||||
required + no functionality
|
||||
</span>
|
||||
<div class="labeled-control">
|
||||
<h3>Client</h3>
|
||||
<Multiselect
|
||||
v-model="clientSideType"
|
||||
placeholder="Select one"
|
||||
:options="sideTypes"
|
||||
:searchable="false"
|
||||
:close-on-select="true"
|
||||
:show-labels="false"
|
||||
:allow-empty="false"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
<m-footer class="footer" centered />
|
||||
</div>
|
||||
<div class="labeled-control">
|
||||
<h3>Server</h3>
|
||||
<Multiselect
|
||||
v-model="serverSideType"
|
||||
placeholder="Select one"
|
||||
:options="sideTypes"
|
||||
:searchable="false"
|
||||
:close-on-select="true"
|
||||
:show-labels="false"
|
||||
:allow-empty="false"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="description">
|
||||
<h3>
|
||||
<label
|
||||
for="body"
|
||||
title="You can type the of the long form of your description here."
|
||||
>
|
||||
Description
|
||||
</label>
|
||||
</h3>
|
||||
<span>
|
||||
You can type the of the long form of your description here. This editor
|
||||
supports markdown. You can find the syntax
|
||||
<a
|
||||
href="https://guides.github.com/features/mastering-markdown/"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>here</a
|
||||
>.
|
||||
</span>
|
||||
<div class="columns">
|
||||
<div class="textarea-wrapper">
|
||||
<textarea id="body" v-model="mod.body"></textarea>
|
||||
</div>
|
||||
<div v-compiled-markdown="mod.body" class="markdown-body"></div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="extra-links">
|
||||
<div class="title">
|
||||
<h3>External links</h3>
|
||||
</div>
|
||||
<label
|
||||
title="A place for users to report bugs, issues, and concerns about your mod."
|
||||
>
|
||||
<span>Issue tracker</span>
|
||||
<input
|
||||
v-model="mod.issues_url"
|
||||
type="url"
|
||||
placeholder="Enter a valid URL"
|
||||
/>
|
||||
</label>
|
||||
<label title="A page/repository containing the source code">
|
||||
<span>Source code</span>
|
||||
<input
|
||||
v-model="mod.source_url"
|
||||
type="url"
|
||||
placeholder="Enter a valid URL"
|
||||
/>
|
||||
</label>
|
||||
<label
|
||||
title="A page containing information, documentation, and help for the mod."
|
||||
>
|
||||
<span>Wiki page</span>
|
||||
<input
|
||||
v-model="mod.wiki_url"
|
||||
type="url"
|
||||
placeholder="Enter a valid URL"
|
||||
/>
|
||||
</label>
|
||||
<label title="An inivitation link to your Discord server.">
|
||||
<span>Discord invite</span>
|
||||
<input
|
||||
v-model="mod.discord_url"
|
||||
type="url"
|
||||
placeholder="Enter a valid URL"
|
||||
/>
|
||||
</label>
|
||||
</section>
|
||||
<section class="license">
|
||||
<div class="title">
|
||||
<h3>License</h3>
|
||||
</div>
|
||||
<label>
|
||||
<span>
|
||||
It is really important to choose a proper license for your mod. You
|
||||
may choose one from our list or provide a URL to your own license. URL
|
||||
field will be filled automatically for provided licenses
|
||||
</span>
|
||||
<div class="input-group">
|
||||
<Multiselect
|
||||
v-model="license"
|
||||
placeholder="Select one"
|
||||
track-by="short"
|
||||
label="name"
|
||||
:options="availableLicenses"
|
||||
:searchable="true"
|
||||
:close-on-select="true"
|
||||
:show-labels="false"
|
||||
/>
|
||||
<input v-model="license_url" type="url" placeholder="License URL" />
|
||||
</div>
|
||||
</label>
|
||||
</section>
|
||||
<section class="donations">
|
||||
<div class="title">
|
||||
<h3>Donation links</h3>
|
||||
<button
|
||||
title="Add a link"
|
||||
class="button"
|
||||
:disabled="false"
|
||||
@click="
|
||||
donationPlatforms.push({})
|
||||
donationLinks.push('')
|
||||
"
|
||||
>
|
||||
Add a link
|
||||
</button>
|
||||
</div>
|
||||
<div v-for="(item, index) in donationPlatforms" :key="index">
|
||||
<label title="The donation link.">
|
||||
<span>Donation Link</span>
|
||||
<input
|
||||
v-model="donationLinks[index]"
|
||||
type="url"
|
||||
placeholder="Enter a valid URL"
|
||||
/>
|
||||
</label>
|
||||
<label title="The donation platform of the link.">
|
||||
<span>Donation Platform</span>
|
||||
<Multiselect
|
||||
v-model="donationPlatforms[index]"
|
||||
placeholder="Select one"
|
||||
track-by="short"
|
||||
label="name"
|
||||
:options="availableDonationPlatforms"
|
||||
:searchable="false"
|
||||
:close-on-select="true"
|
||||
:show-labels="false"
|
||||
/>
|
||||
</label>
|
||||
<button
|
||||
class="button"
|
||||
@click="
|
||||
donationPlatforms.splice(index, 1)
|
||||
donationLinks.splice(index, 1)
|
||||
"
|
||||
>
|
||||
Remove Link
|
||||
</button>
|
||||
<hr />
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -305,11 +301,9 @@ import axios from 'axios'
|
||||
import Multiselect from 'vue-multiselect'
|
||||
|
||||
import FileInput from '~/components/ui/FileInput'
|
||||
import MFooter from '~/components/layout/MFooter'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
MFooter,
|
||||
FileInput,
|
||||
Multiselect,
|
||||
},
|
||||
@@ -411,6 +405,9 @@ export default {
|
||||
}
|
||||
},
|
||||
},
|
||||
created() {
|
||||
this.$emit('update:link-bar', [['Edit', 'edit']])
|
||||
},
|
||||
methods: {
|
||||
async saveModReview() {
|
||||
this.isProcessing = true
|
||||
@@ -464,7 +461,9 @@ export default {
|
||||
)
|
||||
}
|
||||
|
||||
await this.$router.replace(`/mod/${this.mod.id}`)
|
||||
await this.$router.replace(
|
||||
`/mod/${this.mod.slug ? this.mod.slug : this.mod.id}`
|
||||
)
|
||||
} catch (err) {
|
||||
this.$notify({
|
||||
group: 'main',
|
||||
@@ -545,12 +544,14 @@ label {
|
||||
grid-template:
|
||||
'header header header' auto
|
||||
'advert advert advert' auto
|
||||
'essentials essentials mod-icon' auto
|
||||
'essentials essentials essentials' auto
|
||||
'mod-icon mod-icon mod-icon' auto
|
||||
'game-sides game-sides game-sides' auto
|
||||
'description description description' auto
|
||||
'versions versions versions' auto
|
||||
'extra-links license license' auto
|
||||
'donations donations .' auto
|
||||
'extra-links extra-links extra-links' auto
|
||||
'license license license' auto
|
||||
'donations donations donations' auto
|
||||
'footer footer footer' auto
|
||||
/ 4fr 1fr 4fr;
|
||||
column-gap: var(--spacing-card-md);
|
||||
|
||||
@@ -1,136 +1,20 @@
|
||||
<template>
|
||||
<ModPage
|
||||
:mod="mod"
|
||||
:versions="versions"
|
||||
:featured-versions="featuredVersions"
|
||||
:members="members"
|
||||
:current-member="currentMember"
|
||||
:link-bar="[['Description', '']]"
|
||||
:user-follows="userFollows"
|
||||
>
|
||||
<div
|
||||
v-compiled-markdown="mod.body"
|
||||
v-highlightjs
|
||||
class="markdown-body"
|
||||
></div>
|
||||
</ModPage>
|
||||
<div v-compiled-markdown="mod.body" v-highlightjs class="markdown-body"></div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
import ModPage from '~/components/layout/ModPage'
|
||||
|
||||
export default {
|
||||
components: { ModPage },
|
||||
auth: false,
|
||||
async asyncData(data) {
|
||||
try {
|
||||
const mod = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
|
||||
if (mod.body_url && !mod.body) {
|
||||
mod.body = (await axios.get(mod.body_url)).data
|
||||
}
|
||||
|
||||
const [members, versions, featuredVersions, userFollows] = (
|
||||
await Promise.all([
|
||||
axios.get(`https://api.modrinth.com/api/v1/team/${mod.team}/members`),
|
||||
axios.get(`https://api.modrinth.com/api/v1/mod/${mod.id}/version`),
|
||||
axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${mod.id}/version?featured=true`
|
||||
),
|
||||
axios.get(
|
||||
data.$auth.user
|
||||
? `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`
|
||||
: `https://api.modrinth.com`,
|
||||
data.$auth.headers
|
||||
),
|
||||
])
|
||||
).map((it) => it.data)
|
||||
|
||||
const users = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
|
||||
members.map((it) => it.user_id)
|
||||
)}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
|
||||
users.forEach((it) => {
|
||||
const index = members.findIndex((x) => x.user_id === it.id)
|
||||
members[index].avatar_url = it.avatar_url
|
||||
members[index].name = it.username
|
||||
})
|
||||
|
||||
const currentMember = data.$auth.user
|
||||
? members.find((x) => x.user_id === data.$auth.user.id)
|
||||
: null
|
||||
|
||||
return {
|
||||
mod,
|
||||
versions,
|
||||
featuredVersions,
|
||||
members,
|
||||
currentMember,
|
||||
userFollows: userFollows.name ? null : userFollows,
|
||||
}
|
||||
} catch {
|
||||
data.error({
|
||||
statusCode: 404,
|
||||
message: 'Mod not found',
|
||||
})
|
||||
}
|
||||
props: {
|
||||
mod: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
},
|
||||
},
|
||||
},
|
||||
head() {
|
||||
return {
|
||||
title: this.mod.title + ' - Modrinth',
|
||||
meta: [
|
||||
{
|
||||
hid: 'og:type',
|
||||
name: 'og:type',
|
||||
content: 'website',
|
||||
},
|
||||
{
|
||||
hid: 'og:title',
|
||||
name: 'og:title',
|
||||
content: this.mod.title,
|
||||
},
|
||||
{
|
||||
hid: 'apple-mobile-web-app-title',
|
||||
name: 'apple-mobile-web-app-title',
|
||||
content: this.mod.title,
|
||||
},
|
||||
{
|
||||
hid: 'og:description',
|
||||
name: 'og:description',
|
||||
content: this.mod.description,
|
||||
},
|
||||
{
|
||||
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: 'og:url',
|
||||
name: 'og:url',
|
||||
content: `https://modrinth.com/mod/${this.mod.id}`,
|
||||
},
|
||||
{
|
||||
hid: 'og:image',
|
||||
name: 'og:image',
|
||||
content: this.mod.icon_url
|
||||
? this.mod.icon_url
|
||||
: 'https://cdn.modrinth.com/placeholder.png',
|
||||
},
|
||||
],
|
||||
}
|
||||
created() {
|
||||
this.$emit('update:link-bar', [['Description', '']])
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
<template>
|
||||
<ModPage
|
||||
:mod="mod"
|
||||
:versions="versions"
|
||||
:featured-versions="featuredVersions"
|
||||
:members="members"
|
||||
:current-member="currentMember"
|
||||
:link-bar="[['New Version', 'newversion']]"
|
||||
:user-follows="userFollows"
|
||||
>
|
||||
<div>
|
||||
<div class="new-version">
|
||||
<div class="controls">
|
||||
<button
|
||||
@@ -124,88 +116,44 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ModPage>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
import Multiselect from 'vue-multiselect'
|
||||
import ModPage from '~/components/layout/ModPage'
|
||||
import FileInput from '~/components/ui/FileInput'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ModPage,
|
||||
Multiselect,
|
||||
FileInput,
|
||||
},
|
||||
props: {
|
||||
mod: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
},
|
||||
},
|
||||
},
|
||||
async asyncData(data) {
|
||||
try {
|
||||
const mod = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
|
||||
const [
|
||||
members,
|
||||
versions,
|
||||
featuredVersions,
|
||||
selectableLoaders,
|
||||
selectableVersions,
|
||||
userFollows,
|
||||
] = (
|
||||
const [selectableLoaders, selectableVersions] = (
|
||||
await Promise.all([
|
||||
axios.get(`https://api.modrinth.com/api/v1/team/${mod.team}/members`),
|
||||
axios.get(`https://api.modrinth.com/api/v1/mod/${mod.id}/version`),
|
||||
axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${mod.id}/version?featured=true`
|
||||
),
|
||||
axios.get(`https://api.modrinth.com/api/v1/tag/loader`),
|
||||
axios.get(`https://api.modrinth.com/api/v1/tag/game_version`),
|
||||
axios.get(
|
||||
data.$auth.user
|
||||
? `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`
|
||||
: `https://api.modrinth.com`,
|
||||
data.$auth.headers
|
||||
),
|
||||
])
|
||||
).map((it) => it.data)
|
||||
|
||||
const users = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
|
||||
members.map((it) => it.user_id)
|
||||
)}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
|
||||
users.forEach((it) => {
|
||||
const index = members.findIndex((x) => x.user_id === it.id)
|
||||
members[index].avatar_url = it.avatar_url
|
||||
members[index].name = it.username
|
||||
})
|
||||
|
||||
const currentMember = data.$auth.user
|
||||
? members.find((x) => x.user_id === data.$auth.user.id)
|
||||
: null
|
||||
|
||||
return {
|
||||
mod,
|
||||
versions,
|
||||
featuredVersions,
|
||||
members,
|
||||
selectableLoaders,
|
||||
selectableVersions,
|
||||
currentMember,
|
||||
userFollows: userFollows.name ? null : userFollows,
|
||||
}
|
||||
} catch {
|
||||
data.error({
|
||||
statusCode: 404,
|
||||
message: 'Mod not found',
|
||||
message: 'Unable to fetch versions and loaders',
|
||||
})
|
||||
}
|
||||
},
|
||||
@@ -214,6 +162,9 @@ export default {
|
||||
createdVersion: {},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$emit('update:link-bar', [['New Version', 'newversion']])
|
||||
},
|
||||
methods: {
|
||||
async createVersion() {
|
||||
this.$nuxt.$loading.start()
|
||||
@@ -247,7 +198,11 @@ export default {
|
||||
},
|
||||
})
|
||||
).data
|
||||
await this.$router.push(`/mod/${data.mod_id}/version/${data.id}`)
|
||||
await this.$router.push(
|
||||
`/mod/${this.mod.slug ? this.mod.slug : data.mod_id}/version/${
|
||||
data.id
|
||||
}`
|
||||
)
|
||||
} catch (err) {
|
||||
this.$notify({
|
||||
group: 'main',
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
<template>
|
||||
<ModPage
|
||||
:mod="mod"
|
||||
:versions="versions"
|
||||
:members="members.filter((it) => it.accepted)"
|
||||
:current-member="currentMember"
|
||||
:featured-versions="featuredVersions"
|
||||
:link-bar="[['Settings', 'settings']]"
|
||||
:user-follows="userFollows"
|
||||
>
|
||||
<div>
|
||||
<ConfirmPopup
|
||||
ref="delete_popup"
|
||||
title="Are you sure you want to delete this mod?"
|
||||
@@ -244,82 +236,37 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ModPage>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
import ModPage from '~/components/layout/ModPage'
|
||||
|
||||
import ConfirmPopup from '~/components/ui/ConfirmPopup'
|
||||
|
||||
import DropdownIcon from '~/assets/images/utils/dropdown.svg?inline'
|
||||
|
||||
export default {
|
||||
components: { ModPage, DropdownIcon, ConfirmPopup },
|
||||
async asyncData(data) {
|
||||
try {
|
||||
const mod = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
|
||||
const [members, versions, featuredVersions, userFollows] = (
|
||||
await Promise.all([
|
||||
axios.get(
|
||||
`https://api.modrinth.com/api/v1/team/${mod.team}/members`,
|
||||
data.$auth.headers
|
||||
),
|
||||
axios.get(`https://api.modrinth.com/api/v1/mod/${mod.id}/version`),
|
||||
axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${mod.id}/version?featured=true`
|
||||
),
|
||||
axios.get(
|
||||
data.$auth.user
|
||||
? `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`
|
||||
: `https://api.modrinth.com`,
|
||||
data.$auth.headers
|
||||
),
|
||||
])
|
||||
).map((it) => it.data)
|
||||
|
||||
const [users] = (
|
||||
await Promise.all([
|
||||
axios.get(
|
||||
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
|
||||
members.map((it) => it.user_id)
|
||||
)}`,
|
||||
data.$auth.headers
|
||||
),
|
||||
])
|
||||
).map((it) => it.data)
|
||||
|
||||
users.forEach((it) => {
|
||||
const index = members.findIndex((x) => x.user_id === it.id)
|
||||
members[index].avatar_url = it.avatar_url
|
||||
members[index].name = it.username
|
||||
})
|
||||
|
||||
const currentMember = data.$auth.user
|
||||
? members.find((x) => x.user_id === data.$auth.user.id)
|
||||
: null
|
||||
|
||||
return {
|
||||
mod,
|
||||
versions,
|
||||
featuredVersions,
|
||||
members,
|
||||
currentMember,
|
||||
userFollows: userFollows.name ? null : userFollows,
|
||||
}
|
||||
} catch {
|
||||
data.error({
|
||||
statusCode: 404,
|
||||
message: 'Mod not found',
|
||||
})
|
||||
}
|
||||
components: { DropdownIcon, ConfirmPopup },
|
||||
props: {
|
||||
mod: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
},
|
||||
},
|
||||
members: {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
},
|
||||
},
|
||||
currentMember: {
|
||||
type: Object,
|
||||
default() {
|
||||
return null
|
||||
},
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -328,6 +275,8 @@ export default {
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$emit('update:link-bar', [['Settings', 'settings']])
|
||||
|
||||
this.UPLOAD_VERSION = 1 << 0
|
||||
this.DELETE_VERSION = 1 << 1
|
||||
this.EDIT_DETAILS = 1 << 2
|
||||
|
||||
@@ -1,17 +1,5 @@
|
||||
<template>
|
||||
<ModPage
|
||||
:mod="mod"
|
||||
:versions="versions"
|
||||
:featured-versions="featuredVersions"
|
||||
:members="members"
|
||||
:current-member="currentMember"
|
||||
:link-bar="[
|
||||
['Versions', 'versions'],
|
||||
[version.name, 'versions/' + version.id],
|
||||
['Edit Version', 'versions/' + version.id + '/edit'],
|
||||
]"
|
||||
:user-follows="userFollows"
|
||||
>
|
||||
<div>
|
||||
<div class="new-version">
|
||||
<div class="controls">
|
||||
<button class="brand-button" title="Save version" @click="saveVersion">
|
||||
@@ -111,106 +99,87 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</ModPage>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
import Multiselect from 'vue-multiselect'
|
||||
import ModPage from '~/components/layout/ModPage'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ModPage,
|
||||
Multiselect,
|
||||
},
|
||||
auth: false,
|
||||
props: {
|
||||
mod: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
},
|
||||
},
|
||||
versions: {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
},
|
||||
},
|
||||
members: {
|
||||
type: Array,
|
||||
default() {
|
||||
return [{}]
|
||||
},
|
||||
},
|
||||
currentMember: {
|
||||
type: Object,
|
||||
default() {
|
||||
return null
|
||||
},
|
||||
},
|
||||
},
|
||||
async fetch() {
|
||||
this.version = this.versions.find(
|
||||
(x) => x.id === this.$route.params.version
|
||||
)
|
||||
|
||||
if (!this.version.changelog && this.version.changelog_url) {
|
||||
this.version.changelog = (
|
||||
await axios.get(this.version.changelog_url)
|
||||
).data
|
||||
}
|
||||
},
|
||||
async asyncData(data) {
|
||||
try {
|
||||
const mod = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
|
||||
const [
|
||||
members,
|
||||
versions,
|
||||
featuredVersions,
|
||||
selectableLoaders,
|
||||
selectableVersions,
|
||||
userFollows,
|
||||
] = (
|
||||
const [selectableLoaders, selectableVersions] = (
|
||||
await Promise.all([
|
||||
axios.get(`https://api.modrinth.com/api/v1/team/${mod.team}/members`),
|
||||
axios.get(`https://api.modrinth.com/api/v1/mod/${mod.id}/version`),
|
||||
axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${mod.id}/version?featured=true`
|
||||
),
|
||||
axios.get(`https://api.modrinth.com/api/v1/tag/loader`),
|
||||
axios.get(`https://api.modrinth.com/api/v1/tag/game_version`),
|
||||
axios.get(
|
||||
data.$auth.user
|
||||
? `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`
|
||||
: `https://api.modrinth.com`,
|
||||
data.$auth.headers
|
||||
),
|
||||
])
|
||||
).map((it) => it.data)
|
||||
|
||||
const users = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
|
||||
members.map((it) => it.user_id)
|
||||
)}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
|
||||
users.forEach((it) => {
|
||||
const index = members.findIndex((x) => x.user_id === it.id)
|
||||
members[index].avatar_url = it.avatar_url
|
||||
members[index].name = it.username
|
||||
})
|
||||
|
||||
const version = versions.find((x) => x.id === data.params.version)
|
||||
|
||||
version.author = members.find((x) => x.user_id === version.author_id)
|
||||
|
||||
let primaryFile = version.files.find((file) => file.primary)
|
||||
|
||||
if (!primaryFile) {
|
||||
primaryFile = version.files[0]
|
||||
}
|
||||
|
||||
const currentMember = data.$auth.user
|
||||
? members.find((x) => x.user_id === data.$auth.user.id)
|
||||
: null
|
||||
|
||||
if (!version.changelog && version.changelog_url) {
|
||||
version.changelog = (await axios.get(version.changelog_url)).data
|
||||
}
|
||||
|
||||
return {
|
||||
mod,
|
||||
versions,
|
||||
featuredVersions,
|
||||
members,
|
||||
version,
|
||||
primaryFile,
|
||||
currentMember,
|
||||
selectableLoaders,
|
||||
selectableVersions,
|
||||
userFollows: userFollows.name ? null : userFollows,
|
||||
}
|
||||
} catch {
|
||||
data.error({
|
||||
statusCode: 404,
|
||||
message: 'Version not found',
|
||||
message: 'Unable to fetch versions or loaders',
|
||||
})
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
version: {},
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$emit('update:link-bar', [
|
||||
['Versions', 'versions'],
|
||||
[this.version.name, 'versions/' + this.version.id],
|
||||
['Edit Version', 'versions/' + this.version.id + '/edit'],
|
||||
])
|
||||
},
|
||||
methods: {
|
||||
async saveVersion() {
|
||||
this.$nuxt.$loading.start()
|
||||
@@ -222,7 +191,9 @@ export default {
|
||||
this.$auth.headers
|
||||
)
|
||||
await this.$router.replace(
|
||||
`/mod/${this.mod.id}/version/${this.version.id}`
|
||||
`/mod/${this.mod.slug ? this.mod.slug : this.mod.id}/version/${
|
||||
this.version.id
|
||||
}`
|
||||
)
|
||||
} catch (err) {
|
||||
this.$notify({
|
||||
|
||||
@@ -1,16 +1,5 @@
|
||||
<template>
|
||||
<ModPage
|
||||
:mod="mod"
|
||||
:versions="versions"
|
||||
:members="members"
|
||||
:current-member="currentMember"
|
||||
:featured-versions="featuredVersions"
|
||||
:link-bar="[
|
||||
['Versions', 'versions'],
|
||||
[version.name, 'versions/' + version.id],
|
||||
]"
|
||||
:user-follows="userFollows"
|
||||
>
|
||||
<div>
|
||||
<ConfirmPopup
|
||||
ref="delete_file_popup"
|
||||
title="Are you sure you want to delete this file?"
|
||||
@@ -73,7 +62,7 @@
|
||||
:href="primaryFile.url"
|
||||
class="action iconified-button"
|
||||
@click.prevent="
|
||||
downloadFile(primaryFile.hashes.sha1, primaryFile.url)
|
||||
$parent.downloadFile(primaryFile.hashes.sha1, primaryFile.url)
|
||||
"
|
||||
>
|
||||
<DownloadIcon />
|
||||
@@ -110,7 +99,9 @@
|
||||
<div class="info">
|
||||
<h4>Available For</h4>
|
||||
<p class="value">
|
||||
{{ version.game_versions.join(', ') }}
|
||||
{{
|
||||
version.game_versions ? version.game_versions.join(', ') : ''
|
||||
}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -142,12 +133,11 @@
|
||||
</div>
|
||||
<FileInput v-if="currentMember" class="file-input" @change="addFiles" />
|
||||
</div>
|
||||
</ModPage>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
import ModPage from '~/components/layout/ModPage'
|
||||
import ConfirmPopup from '~/components/ui/ConfirmPopup'
|
||||
|
||||
import Categories from '~/components/ui/search/Categories'
|
||||
@@ -163,7 +153,6 @@ export default {
|
||||
components: {
|
||||
FileInput,
|
||||
Categories,
|
||||
ModPage,
|
||||
DownloadIcon,
|
||||
CalendarIcon,
|
||||
TagIcon,
|
||||
@@ -173,98 +162,66 @@ export default {
|
||||
ConfirmPopup,
|
||||
},
|
||||
auth: false,
|
||||
async asyncData(data) {
|
||||
try {
|
||||
const mod = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
props: {
|
||||
mod: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
},
|
||||
},
|
||||
versions: {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
},
|
||||
},
|
||||
members: {
|
||||
type: Array,
|
||||
default() {
|
||||
return [{}]
|
||||
},
|
||||
},
|
||||
currentMember: {
|
||||
type: Object,
|
||||
default() {
|
||||
return null
|
||||
},
|
||||
},
|
||||
},
|
||||
async fetch() {
|
||||
this.version = this.versions.find(
|
||||
(x) => x.id === this.$route.params.version
|
||||
)
|
||||
|
||||
const [members, versions, featuredVersions, userFollows] = (
|
||||
await Promise.all([
|
||||
axios.get(`https://api.modrinth.com/api/v1/team/${mod.team}/members`),
|
||||
axios.get(`https://api.modrinth.com/api/v1/mod/${mod.id}/version`),
|
||||
axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${mod.id}/version?featured=true`
|
||||
),
|
||||
axios.get(
|
||||
data.$auth.user
|
||||
? `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`
|
||||
: `https://api.modrinth.com`,
|
||||
data.$auth.headers
|
||||
),
|
||||
])
|
||||
).map((it) => it.data)
|
||||
this.primaryFile = this.version.files.find((file) => file.primary)
|
||||
|
||||
const users = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
|
||||
members.map((it) => it.user_id)
|
||||
)}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
|
||||
users.forEach((it) => {
|
||||
const index = members.findIndex((x) => x.user_id === it.id)
|
||||
members[index].avatar_url = it.avatar_url
|
||||
members[index].name = it.username
|
||||
})
|
||||
|
||||
const version = versions.find((x) => x.id === data.params.version)
|
||||
|
||||
version.author = members.find((x) => x.user_id === version.author_id)
|
||||
|
||||
let primaryFile = version.files.find((file) => file.primary)
|
||||
|
||||
if (!primaryFile) {
|
||||
primaryFile = version.files[0]
|
||||
}
|
||||
|
||||
const currentMember = data.$auth.user
|
||||
? members.find((x) => x.user_id === data.$auth.user.id)
|
||||
: null
|
||||
|
||||
if (!version.changelog && version.changelog_url) {
|
||||
version.changelog = (await axios.get(version.changelog_url)).data
|
||||
}
|
||||
|
||||
return {
|
||||
mod,
|
||||
versions,
|
||||
featuredVersions,
|
||||
members,
|
||||
version,
|
||||
primaryFile,
|
||||
currentMember,
|
||||
userFollows: userFollows.name ? null : userFollows,
|
||||
}
|
||||
} catch {
|
||||
data.error({
|
||||
statusCode: 404,
|
||||
message: 'Version not found',
|
||||
})
|
||||
if (!this.primaryFile) {
|
||||
this.primaryFile = this.version.files[0]
|
||||
}
|
||||
|
||||
if (!this.version.changelog && this.version.changelog_url) {
|
||||
this.version.changelog = (
|
||||
await axios.get(this.version.changelog_url)
|
||||
).data
|
||||
}
|
||||
|
||||
console.log(this.version)
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
primaryFile: {},
|
||||
version: {},
|
||||
filesToUpload: [],
|
||||
popup_data: null,
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.$emit('update:link-bar', [
|
||||
['Versions', 'versions'],
|
||||
[this.version.name, 'versions/' + this.version.id],
|
||||
])
|
||||
},
|
||||
methods: {
|
||||
async downloadFile(hash, url) {
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/version_file/${hash}/download`
|
||||
)
|
||||
|
||||
const elem = document.createElement('a')
|
||||
elem.download = hash
|
||||
elem.href = url
|
||||
elem.click()
|
||||
},
|
||||
deleteFilePopup(hash) {
|
||||
this.popup_data = hash
|
||||
this.$refs.delete_file_popup.show()
|
||||
@@ -354,49 +311,6 @@ export default {
|
||||
this.$nuxt.$loading.finish()
|
||||
},
|
||||
},
|
||||
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,
|
||||
},
|
||||
{
|
||||
hid: 'og:title',
|
||||
name: 'og:title',
|
||||
content: this.mod.title,
|
||||
},
|
||||
{
|
||||
hid: 'og:url',
|
||||
name: 'og:url',
|
||||
content: `https://modrinth.com/mod/${this.mod.id}`,
|
||||
},
|
||||
{
|
||||
hid: 'og:description',
|
||||
name: 'og:description',
|
||||
content: this.mod.description,
|
||||
},
|
||||
{ hid: 'og:type', name: 'og:type', content: 'website' },
|
||||
{
|
||||
hid: 'og:image',
|
||||
name: 'og:image',
|
||||
content: this.mod.icon_url
|
||||
? this.mod.icon_url
|
||||
: 'https://cdn.modrinth.com/placeholder.png',
|
||||
},
|
||||
],
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,13 +1,5 @@
|
||||
<template>
|
||||
<ModPage
|
||||
:mod="mod"
|
||||
:versions="versions"
|
||||
:featured-versions="featuredVersions"
|
||||
:members="members"
|
||||
:current-member="currentMember"
|
||||
:link-bar="[['Versions', 'versions']]"
|
||||
:user-follows="userFollows"
|
||||
>
|
||||
<div>
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -25,12 +17,12 @@
|
||||
<tr v-for="version in versions" :key="version.id">
|
||||
<td>
|
||||
<a
|
||||
:href="findPrimary(version).url"
|
||||
:href="$parent.findPrimary(version).url"
|
||||
class="download"
|
||||
@click.prevent="
|
||||
downloadFile(
|
||||
findPrimary(version).hashes.sha1,
|
||||
findPrimary(version).url
|
||||
$parent.downloadFile(
|
||||
$parent.findPrimary(version).hashes.sha1,
|
||||
$parent.findPrimary(version).url
|
||||
)
|
||||
"
|
||||
>
|
||||
@@ -87,150 +79,42 @@
|
||||
New Version
|
||||
</nuxt-link>
|
||||
</div>
|
||||
</ModPage>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import axios from 'axios'
|
||||
|
||||
import ModPage from '~/components/layout/ModPage'
|
||||
|
||||
import DownloadIcon from '~/assets/images/utils/download.svg?inline'
|
||||
import ForgeIcon from '~/assets/images/categories/forge.svg?inline'
|
||||
import FabricIcon from '~/assets/images/categories/fabric.svg?inline'
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ModPage,
|
||||
ForgeIcon,
|
||||
FabricIcon,
|
||||
DownloadIcon,
|
||||
},
|
||||
auth: false,
|
||||
async asyncData(data) {
|
||||
try {
|
||||
const mod = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${data.params.id}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
|
||||
const [members, versions, featuredVersions, userFollows] = (
|
||||
await Promise.all([
|
||||
axios.get(`https://api.modrinth.com/api/v1/team/${mod.team}/members`),
|
||||
axios.get(`https://api.modrinth.com/api/v1/mod/${mod.id}/version`),
|
||||
axios.get(
|
||||
`https://api.modrinth.com/api/v1/mod/${mod.id}/version?featured=true`
|
||||
),
|
||||
axios.get(
|
||||
data.$auth.user
|
||||
? `https://api.modrinth.com/api/v1/user/${data.$auth.user.id}/follows`
|
||||
: `https://api.modrinth.com`,
|
||||
data.$auth.headers
|
||||
),
|
||||
])
|
||||
).map((it) => it.data)
|
||||
|
||||
const users = (
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/users?ids=${JSON.stringify(
|
||||
members.map((it) => it.user_id)
|
||||
)}`,
|
||||
data.$auth.headers
|
||||
)
|
||||
).data
|
||||
|
||||
users.forEach((it) => {
|
||||
const index = members.findIndex((x) => x.user_id === it.id)
|
||||
members[index].avatar_url = it.avatar_url
|
||||
members[index].name = it.username
|
||||
})
|
||||
|
||||
const currentMember = data.$auth.user
|
||||
? members.find((x) => x.user_id === data.$auth.user.id)
|
||||
: null
|
||||
|
||||
return {
|
||||
mod,
|
||||
versions,
|
||||
featuredVersions,
|
||||
members,
|
||||
currentMember,
|
||||
userFollows: userFollows.name ? null : userFollows,
|
||||
}
|
||||
} catch {
|
||||
data.error({
|
||||
statusCode: 404,
|
||||
message: 'Mod not found',
|
||||
})
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
findPrimary(version) {
|
||||
let file = version.files.find((x) => x.primary)
|
||||
|
||||
if (!file) {
|
||||
file = version.files[0]
|
||||
}
|
||||
|
||||
if (!file) {
|
||||
file = { url: `/mod/${this.mod.id}/version/${version.id}` }
|
||||
}
|
||||
|
||||
return file
|
||||
props: {
|
||||
mod: {
|
||||
type: Object,
|
||||
default() {
|
||||
return {}
|
||||
},
|
||||
},
|
||||
async downloadFile(hash, url) {
|
||||
await axios.get(
|
||||
`https://api.modrinth.com/api/v1/version_file/${hash}/download`
|
||||
)
|
||||
|
||||
const elem = document.createElement('a')
|
||||
elem.download = hash
|
||||
elem.href = url
|
||||
elem.click()
|
||||
versions: {
|
||||
type: Array,
|
||||
default() {
|
||||
return []
|
||||
},
|
||||
},
|
||||
currentMember: {
|
||||
type: Object,
|
||||
default() {
|
||||
return null
|
||||
},
|
||||
},
|
||||
},
|
||||
head() {
|
||||
return {
|
||||
title: this.mod.title + ' - Modrinth',
|
||||
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,
|
||||
},
|
||||
{
|
||||
hid: 'og:title',
|
||||
name: 'og:title',
|
||||
content: this.mod.title,
|
||||
},
|
||||
{
|
||||
hid: 'og:url',
|
||||
name: 'og:url',
|
||||
content: `https://modrinth.com/mod/${this.mod.id}`,
|
||||
},
|
||||
{
|
||||
hid: 'og:description',
|
||||
name: 'og:description',
|
||||
content: this.mod.description,
|
||||
},
|
||||
{ hid: 'og:type', name: 'og:type', content: 'website' },
|
||||
{
|
||||
hid: 'og:image',
|
||||
name: 'og:image',
|
||||
content: this.mod.icon_url
|
||||
? this.mod.icon_url
|
||||
: 'https://cdn.modrinth.com/placeholder.png',
|
||||
},
|
||||
],
|
||||
}
|
||||
created() {
|
||||
this.$emit('update:link-bar', [['Versions', 'versions']])
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user