mirror of
https://github.com/modrinth/code.git
synced 2026-08-30 19:46:33 +00:00
Prevent SEO Slop (#7274)
* tell search engines not to index collections because bots keep spamming them and I can basically guarantee not a single human being is using collections in a way where this will be detrimental to them (besides the advertisement spam) * Index creator created collections
This commit is contained in:
@@ -410,6 +410,10 @@ import { onServerPrefetch } from 'vue'
|
|||||||
|
|
||||||
import AdPlaceholder from '~/components/ui/AdPlaceholder.vue'
|
import AdPlaceholder from '~/components/ui/AdPlaceholder.vue'
|
||||||
|
|
||||||
|
useSeoMeta({
|
||||||
|
robots: 'noindex',
|
||||||
|
})
|
||||||
|
|
||||||
const { handleError } = injectNotificationManager()
|
const { handleError } = injectNotificationManager()
|
||||||
const api = injectModrinthClient()
|
const api = injectModrinthClient()
|
||||||
const { formatMessage } = useVIntl()
|
const { formatMessage } = useVIntl()
|
||||||
@@ -614,6 +618,26 @@ const creator = computed(() =>
|
|||||||
|
|
||||||
const supportsMarkdown = computed(() => creator.value?.id === '2REoufqX')
|
const supportsMarkdown = computed(() => creator.value?.id === '2REoufqX')
|
||||||
|
|
||||||
|
// Query for public projects
|
||||||
|
const { data: creatorPublicProjectsSearch } = useQuery({
|
||||||
|
queryKey: computed(() => ['user', creator.value?.username, 'public-projects-search']),
|
||||||
|
queryFn: () =>
|
||||||
|
api.labrinth.projects_v3.search({
|
||||||
|
facets: [[`author:${creator.value.username}`]],
|
||||||
|
limit: 1,
|
||||||
|
}),
|
||||||
|
enabled: computed(
|
||||||
|
() =>
|
||||||
|
!isFollowingCollection.value &&
|
||||||
|
collection.value?.status === 'listed' &&
|
||||||
|
!!creator.value?.username,
|
||||||
|
),
|
||||||
|
})
|
||||||
|
|
||||||
|
const creatorHasPublicProjects = computed(
|
||||||
|
() => (creatorPublicProjectsSearch.value?.total_hits ?? 0) > 0,
|
||||||
|
)
|
||||||
|
|
||||||
// Query for followed projects
|
// Query for followed projects
|
||||||
const {
|
const {
|
||||||
data: followedProjects,
|
data: followedProjects,
|
||||||
@@ -673,10 +697,21 @@ onServerPrefetch(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (collectionData?.user) {
|
if (collectionData?.user) {
|
||||||
await queryClient.ensureQueryData({
|
const creatorData = await queryClient.ensureQueryData({
|
||||||
queryKey: ['user', collectionData.user],
|
queryKey: ['user', collectionData.user],
|
||||||
queryFn: () => api.labrinth.users_v2.get(collectionData.user),
|
queryFn: () => api.labrinth.users_v2.get(collectionData.user),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (collectionData.status === 'listed' && creatorData?.username) {
|
||||||
|
await queryClient.ensureQueryData({
|
||||||
|
queryKey: ['user', creatorData.username, 'public-projects-search'],
|
||||||
|
queryFn: () =>
|
||||||
|
api.labrinth.projects_v3.search({
|
||||||
|
facets: [[`author:${creatorData.username}`]],
|
||||||
|
limit: 1,
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collectionData?.projects?.length) {
|
if (collectionData?.projects?.length) {
|
||||||
@@ -688,8 +723,8 @@ onServerPrefetch(async () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[collection, creator],
|
[collection, creator, creatorHasPublicProjects],
|
||||||
([col, cre]) => {
|
([col, cre, hasPublicProjects]) => {
|
||||||
if (col && cre) {
|
if (col && cre) {
|
||||||
const canonicalUrl = col ? `https://modrinth.com/collection/${col.id}` : undefined
|
const canonicalUrl = col ? `https://modrinth.com/collection/${col.id}` : undefined
|
||||||
useSeoMeta({
|
useSeoMeta({
|
||||||
@@ -703,7 +738,7 @@ watch(
|
|||||||
ogDescription: col.description,
|
ogDescription: col.description,
|
||||||
ogImage: col.icon_url ?? 'https://cdn-raw.modrinth.com/placeholder-square.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' && hasPublicProjects ? 'all' : 'noindex',
|
||||||
})
|
})
|
||||||
useHead({
|
useHead({
|
||||||
link: [
|
link: [
|
||||||
|
|||||||
Reference in New Issue
Block a user