chore: rename and remove string from locale repository type + update translation sfc

userquin/feat-add-external-translation-repo-links
userquin 1 year ago
parent e65610907a
commit 66d7ed1669

@ -17,18 +17,26 @@ const { localeLinks, currentLang } = useLangs({ correspondingLink: true })
:label="theme.langMenuLabel || 'Change language'"
>
<div class="items">
<div v-if="currentLang.repo">
<div v-if="currentLang.repository">
<div class="menu-item">
<p class="title">{{ currentLang.label }}</p>
<VPSocialLink icon="github" :link="currentLang.repo.link" :ariaLabel="currentLang.repo.title" />
<VPSocialLink
icon="github"
:link="currentLang.repository.link"
:ariaLabel="currentLang.repository.title"
/>
</div>
</div>
<p v-else class="title">{{ currentLang.label }}</p>
<template v-for="locale in localeLinks" :key="locale.link">
<div v-if="locale.repo" class="menu-item">
<div v-if="locale.repository" class="menu-item">
<VPMenuLink :item="locale" />
<VPSocialLink icon="github" :link="locale.repo.link" :ariaLabel="locale.repo.title" />
<VPSocialLink
icon="github"
:link="locale.repository.link"
:ariaLabel="locale.repository.title"
/>
</div>
<VPMenuLink v-else :item="locale" />
</template>

@ -6,7 +6,7 @@ import VPSocialLink from "./VPSocialLink.vue";
const { localeLinks, currentLang } = useLangs({ correspondingLink: true })
const isOpen = ref(false)
const repo = computed(() => !!currentLang.value.repo || (localeLinks.value.length > 1 && localeLinks.value.some(l => !!l.repo)))
const repo = computed(() => !!currentLang.value.repository || (localeLinks.value.length > 1 && localeLinks.value.some(l => !!l.repository)))
function toggle() {
isOpen.value = !isOpen.value
@ -19,8 +19,8 @@ function toggle() {
class="VPNavScreenTranslations"
:class="{ open: isOpen, repo }"
>
<button class="title" :class="{ repo: !!currentLang.repo }" @click="toggle">
<span v-if="currentLang.repo" class="repo">
<button class="title" :class="{ repo: !!currentLang.repository }" @click="toggle">
<span v-if="currentLang.repository" class="repo">
<span class="vpi-languages icon lang" />
<span>{{ currentLang.label }}</span>
<span class="vpi-chevron-down icon chevron" />
@ -30,13 +30,28 @@ function toggle() {
<span>{{ currentLang.label }}</span>
<span class="vpi-chevron-down icon chevron" />
</template>
<VPSocialLink v-if="currentLang.repo" icon="github" :link="currentLang.repo.link" :ariaLabel="currentLang.repo.title" />
<VPSocialLink
v-if="currentLang.repository"
icon="github"
:link="currentLang.repository.link"
:ariaLabel="currentLang.repository.title"
/>
</button>
<ul class="list">
<li v-for="locale in localeLinks" :key="locale.link" :class="{ repo: !!locale.repo }" class="item">
<li
v-for="locale in localeLinks"
:key="locale.link"
:class="{ repo: !!locale.repository }"
class="item"
>
<VPLink class="link" :href="locale.link">{{ locale.text }}</VPLink>
<VPSocialLink v-if="locale.repo" icon="github" :link="locale.repo.link" :ariaLabel="locale.repo.title" />
<VPSocialLink
v-if="locale.repository"
icon="github"
:link="locale.repository.link"
:ariaLabel="locale.repository.title"
/>
</li>
</ul>
</div>

@ -12,13 +12,10 @@ export function useLangs({ correspondingLink = false } = {}) {
lang?.link || localeIndex.value === 'root'
? '/'
: `/${localeIndex.value}/`,
repo: lang?.repo
repository: lang?.repository
? {
link: typeof lang.repo === 'string' ? lang.repo : lang.repo.link,
title:
typeof lang.repo === 'string'
? `${lang.label} repository`
: lang.repo.title
link: lang.repository.link,
title: lang.repository.title
}
: undefined
}
@ -30,16 +27,10 @@ export function useLangs({ correspondingLink = false } = {}) {
? []
: {
text: value.label,
repo: value.repo
repository: value.repository
? {
link:
typeof value.repo === 'string'
? value.repo
: value.repo.link,
title:
typeof value.repo === 'string'
? `${value.label} repository`
: value.repo.title
link: value.repository.link,
title: value.repository.title
}
: undefined,
link:

8
types/shared.d.ts vendored

@ -164,11 +164,13 @@ export type LocaleConfig<ThemeConfig = any> = Record<
LocaleSpecificConfig<ThemeConfig> & {
label: string
link?: string
repo?:
| string
| {
repository?: {
link: string
title: string
help?: {
link: string
text: string
}
}
}
>

Loading…
Cancel
Save