34 lines
712 B
TypeScript
34 lines
712 B
TypeScript
import { useI18n } from 'vue-i18n'
|
|
import { i18nPages } from '@/i18n/i18n-pages'
|
|
|
|
export function useI18nPages () {
|
|
const { locale } = useI18n()
|
|
|
|
const getRoute = (key: keyof typeof i18nPages) => {
|
|
const entry = i18nPages[key]
|
|
if (!entry) return ''
|
|
|
|
if ('paths' in entry) {
|
|
return entry.paths[locale.value]
|
|
}
|
|
|
|
return entry[locale.value]
|
|
}
|
|
|
|
const getProjectLink = (slug: string) => {
|
|
const path = getRoute('projekt___link')
|
|
return path.replace(':link', slug)
|
|
}
|
|
|
|
const getArticleLink = (slug: string) => {
|
|
const path = getRoute('artikel___link')
|
|
return path.replace(':link', slug)
|
|
}
|
|
|
|
return {
|
|
getRoute,
|
|
getProjectLink,
|
|
getArticleLink
|
|
}
|
|
}
|