feat: imgur proxying for blocked countries (#7104)

This commit is contained in:
Calum H.
2026-08-11 16:40:03 +00:00
committed by GitHub
parent 26e05ee9e5
commit 2d567b93ce
12 changed files with 167 additions and 37 deletions
+1
View File
@@ -18,4 +18,5 @@ export * from './project-page-new'
export * from './server-context'
export * from './server-settings-modal'
export * from './tags'
export * from './user-country'
export * from './web-notifications'
+28
View File
@@ -0,0 +1,28 @@
import { setMarkdownUserCountryResolver } from '@modrinth/utils'
import type { Ref } from 'vue'
import { hasInjectionContext } from 'vue'
import { createContext } from './create-context'
const [injectUserCountryContext, provideUserCountryContext] = createContext<Ref<string>>(
'root',
'userCountry',
)
let clientCountry: Ref<string> | null = null
export const injectUserCountry = injectUserCountryContext
export const useUserCountry = injectUserCountryContext
export function provideUserCountry(country: Ref<string>) {
if (typeof window !== 'undefined') {
clientCountry = country
}
return provideUserCountryContext(country)
}
setMarkdownUserCountryResolver(() => {
const injectedCountry = hasInjectionContext() ? injectUserCountryContext(null) : null
return injectedCountry?.value ?? clientCountry?.value
})