mirror of
https://github.com/modrinth/code.git
synced 2026-08-27 01:54:47 +00:00
feat: imgur proxying for blocked countries (#7104)
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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
|
||||
})
|
||||
Reference in New Issue
Block a user