better unknown project embed (#7178)

* better unknown project embed

* improve placeholders, fix decriptions
This commit is contained in:
Prospector
2026-08-16 23:54:17 -07:00
committed by GitHub
parent 377ebfe746
commit 65df8b90b8
4 changed files with 30 additions and 14 deletions
+20 -9
View File
@@ -1745,16 +1745,24 @@ const following = computed(() => {
return !!user.value.follows.find((x) => x.id === project.value.id) return !!user.value.follows.find((x) => x.id === project.value.id)
}) })
const PROJECT_NOT_FOUND_DESCRIPTION =
"There's no project here, check that you have the right link! It may still be under review or no longer publicly available on Modrinth."
const title = computed(() => const title = computed(() =>
project.value ? `${project.value.title} - Minecraft ${projectTypeDisplay.value}` : '',
)
const description = computed(() =>
project.value project.value
? `${project.value.description} - Download the Minecraft ${projectTypeDisplay.value} ${ ? `${project.value.title} - Minecraft ${projectTypeDisplay.value}`
project.value.title : 'Project not found',
} by ${members.value.find((x) => x.is_owner)?.user?.username || 'a creator'} on Modrinth`
: '',
) )
const description = computed(() => {
if (!project.value) {
return PROJECT_NOT_FOUND_DESCRIPTION
}
const creator = organization.value?.name || members.value.find((x) => x.is_owner)?.user?.username
const byLine = creator ? ` by ${creator}` : ''
return `${project.value.description} - Download the Minecraft ${projectTypeDisplay.value} ${project.value.title}${byLine} on Modrinth`
})
const canCreateServerFrom = computed(() => { const canCreateServerFrom = computed(() => {
if (!project.value) return false if (!project.value) return false
@@ -1986,8 +1994,11 @@ if (!route.name.startsWith('type-project-settings')) {
title: () => title.value, title: () => title.value,
description: () => description.value, description: () => description.value,
ogTitle: () => title.value, ogTitle: () => title.value,
ogDescription: () => project.value?.description ?? '', ogDescription: () => project.value?.description ?? PROJECT_NOT_FOUND_DESCRIPTION,
ogImage: () => project.value?.icon_url ?? 'https://cdn.modrinth.com/placeholder.png', ogImage: () =>
project.value
? (project.value?.icon_url ?? 'https://cdn-raw.modrinth.com/placeholder-square.png')
: 'https://cdn-raw.modrinth.com/not-found-transparent.png',
ogUrl: createCanonicalUrl, ogUrl: createCanonicalUrl,
robots: () => (project.value?.status === 'approved' ? 'all' : 'noindex'), robots: () => (project.value?.status === 'approved' ? 'all' : 'noindex'),
}) })
@@ -740,7 +740,7 @@ watch(
}), }),
ogTitle: formatMessage(messages.collectionTitle, { name: col.name }), ogTitle: formatMessage(messages.collectionTitle, { name: col.name }),
ogDescription: col.description, ogDescription: col.description,
ogImage: col.icon_url ?? 'https://cdn.modrinth.com/placeholder.png', ogImage: col.icon_url ?? 'https://cdn-raw.modrinth.com/placeholder-square.png',
ogUrl: canonicalUrl, ogUrl: canonicalUrl,
robots: col.status === 'listed' ? 'all' : 'noindex', robots: col.status === 'listed' ? 'all' : 'noindex',
}) })
@@ -483,7 +483,7 @@ watch(
description, description,
ogTitle: title, ogTitle: title,
ogDescription: org.description, ogDescription: org.description,
ogImage: org.icon_url ?? 'https://cdn.modrinth.com/placeholder.png', ogImage: org.icon_url ?? 'https://cdn-raw.modrinth.com/placeholder-square.png',
ogUrl: canonicalUrl, ogUrl: canonicalUrl,
}) })
useHead({ useHead({
+8 -3
View File
@@ -85,10 +85,12 @@ if (projectsResult.status === 'fulfilled') {
warmProjectCheckCaches(queryClient, projectsResult.value) warmProjectCheckCaches(queryClient, projectsResult.value)
} }
const title = computed(() => const title = computed(() =>
prefetchedUser ? `${prefetchedUser.username} - Modrinth` : 'Modrinth', prefetchedUser ? `${prefetchedUser.username} - Modrinth` : 'User not found',
) )
const description = computed(() => { const description = computed(() => {
if (!prefetchedUser) return '' if (!prefetchedUser) {
return `There's no user here, check that you have the right link!`
}
return prefetchedUser.bio return prefetchedUser.bio
? `${prefetchedUser.bio} - Download ${prefetchedUser.username}'s projects on Modrinth` ? `${prefetchedUser.bio} - Download ${prefetchedUser.username}'s projects on Modrinth`
: `Download ${prefetchedUser.username}'s projects on Modrinth` : `Download ${prefetchedUser.username}'s projects on Modrinth`
@@ -99,7 +101,10 @@ useSeoMeta({
description: () => description.value, description: () => description.value,
ogTitle: () => title.value, ogTitle: () => title.value,
ogDescription: () => description.value, ogDescription: () => description.value,
ogImage: () => prefetchedUser?.avatar_url ?? 'https://cdn.modrinth.com/placeholder.png', ogImage: () =>
prefetchedUser
? (prefetchedUser?.avatar_url ?? 'https://cdn-raw.modrinth.com/placeholder-circle.png')
: 'https://cdn-raw.modrinth.com/not-found-transparent.png',
}) })
const projectCreateModal = ref<InstanceType<typeof ProjectCreateModal> | null>(null) const projectCreateModal = ref<InstanceType<typeof ProjectCreateModal> | null>(null)