Subdomain: links to the Research Gallery carry the reader's language (?lang=)
This commit is contained in:
parent
89ce341c82
commit
6444a05203
2 changed files with 10 additions and 7 deletions
|
|
@ -4,10 +4,10 @@
|
|||
// on the right, plus a slide-down hamburger overlay for mobile.
|
||||
|
||||
import { PRIMARY_NAV, SECONDARY_NAV, type NavItem } from '~/utils/nav'
|
||||
const runtimeConfig = useRuntimeConfig()
|
||||
// Items switched off are not shown; an item whose URL comes from config gets it here.
|
||||
const researchGallery = useResearchGalleryUrl()
|
||||
// Items switched off are not shown; the Research item gets the gallery's URL (in the reader's language).
|
||||
const secondaryNav = computed(() => SECONDARY_NAV.filter((i) => !i.off).map((i): NavItem =>
|
||||
i.hrefConfig ? { ...i, href: String((runtimeConfig.public as Record<string, unknown>)[i.hrefConfig] || '') } : i)
|
||||
i.hrefConfig === 'researchGalleryUrl' ? { ...i, href: researchGallery() } : i)
|
||||
.filter((i) => i.href || i.to))
|
||||
|
||||
const { t } = useI18n()
|
||||
|
|
|
|||
|
|
@ -1,15 +1,18 @@
|
|||
// The Research Gallery lives on its own subdomain (the Plugin Studio container), so every link that
|
||||
// went to this site's /research or /regions page goes there instead (NUXT_PUBLIC_RESEARCH_GALLERY_URL).
|
||||
// A view is opened with ?tab=<view id> (for example 'regions-dashboard'). The /research and /regions
|
||||
// pages themselves are kept; nothing links to them any more.
|
||||
// A view is opened with ?tab=<view id> (for example 'regions-dashboard'), and the reader's language
|
||||
// travels as ?lang=<locale> (the gallery reads it, and lays Arabic out right-to-left), so an Arabic reader
|
||||
// does not land on the English gallery. The /research and /regions pages themselves are kept; nothing
|
||||
// links to them any more.
|
||||
export function useResearchGalleryUrl() {
|
||||
const config = useRuntimeConfig()
|
||||
const { locale } = useI18n()
|
||||
const base = String((config.public as { researchGalleryUrl?: string }).researchGalleryUrl || '')
|
||||
return (tab?: string): string => {
|
||||
if (!tab) return base
|
||||
try {
|
||||
const u = new URL(base)
|
||||
u.searchParams.set('tab', tab)
|
||||
if (tab) u.searchParams.set('tab', tab)
|
||||
if (locale.value && locale.value !== 'en') u.searchParams.set('lang', locale.value)
|
||||
return u.toString()
|
||||
} catch {
|
||||
return base
|
||||
|
|
|
|||
Loading…
Reference in a new issue