Add project redir + fix version 404 (#762)

This commit is contained in:
Geometrically 2022-11-20 21:18:30 -07:00 committed by GitHub
parent df1a939798
commit e08d803a33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 9 deletions

View File

@ -168,8 +168,6 @@ Questions? [Join the Modrinth Discord for support!](https://discord.gg/EUHuJHt)`
})
)
console.log(formData)
try {
await this.$axios({
url: 'project',

View File

@ -915,7 +915,10 @@ export default {
try {
if (
!data.params.id ||
!data.$tag.projectTypes.find((x) => x.id === data.params.type)
!(
data.$tag.projectTypes.find((x) => x.id === data.params.type) ||
data.params.type === 'project'
)
) {
data.error({
statusCode: 404,
@ -968,12 +971,15 @@ export default {
project.project_type !== data.params.type ||
data.params.id !== project.slug
) {
const route = data.route.fullPath.split('/')
let route = data.route.fullPath.split('/')
route.splice(0, 3)
route = route.filter((x) => x)
data.redirect(
301,
`/${project.project_type}/${project.slug}/${route.join('/')}`
`/${project.project_type}/${project.slug}${
route.length > 0 ? `/${route.join('/')}` : ''
}`
)
return

View File

@ -1,5 +1,5 @@
<template>
<div>
<div v-if="version">
<div v-if="showKnownErrors" class="known-errors card">
<ul>
<li v-if="version.version_number === ''">
@ -53,7 +53,7 @@
Back to list
</nuxt-link>
</div>
<div v-if="version">
<div>
<div v-if="mode === 'version'" class="version-header">
<h2>{{ version.name }}</h2>
@ -630,6 +630,7 @@
<NuxtChild v-show="false" :mode.sync="mode" />
</div>
</div>
<div v-else></div>
</template>
<script>
import Multiselect from 'vue-multiselect'
@ -735,11 +736,10 @@ export default {
}
},
async fetch() {
console.log(this.$nuxt.context.from)
await this.setVersion()
},
head() {
if (!this.version.game_versions) {
if (!this.version || !this.version.game_versions) {
return {}
}
const title = `${