feat(theme): allow customizing skip to content label

closes #4288
pull/3806/merge
Divyansh Singh 10 months ago
parent 18858f7dec
commit ff254dcbe6

@ -48,7 +48,8 @@ export const es = defineConfig({
sidebarMenuLabel: 'Menu Lateral', sidebarMenuLabel: 'Menu Lateral',
darkModeSwitchLabel: 'Tema Oscuro', darkModeSwitchLabel: 'Tema Oscuro',
lightModeSwitchTitle: 'Cambiar a modo claro', lightModeSwitchTitle: 'Cambiar a modo claro',
darkModeSwitchTitle: 'Cambiar a modo oscuro' darkModeSwitchTitle: 'Cambiar a modo oscuro',
skipToContentLabel: 'Saltar al contenido'
} }
}) })

@ -44,7 +44,8 @@ export const ko = defineConfig({
sidebarMenuLabel: '사이드바 메뉴', sidebarMenuLabel: '사이드바 메뉴',
darkModeSwitchLabel: '다크 모드', darkModeSwitchLabel: '다크 모드',
lightModeSwitchTitle: '라이트 모드로 변경', lightModeSwitchTitle: '라이트 모드로 변경',
darkModeSwitchTitle: '다크 모드로 변경' darkModeSwitchTitle: '다크 모드로 변경',
skipToContentLabel: '본문으로 건너뛰기'
} }
}) })

@ -48,7 +48,8 @@ export const pt = defineConfig({
sidebarMenuLabel: 'Menu Lateral', sidebarMenuLabel: 'Menu Lateral',
darkModeSwitchLabel: 'Tema Escuro', darkModeSwitchLabel: 'Tema Escuro',
lightModeSwitchTitle: 'Mudar para Modo Claro', lightModeSwitchTitle: 'Mudar para Modo Claro',
darkModeSwitchTitle: 'Mudar para Modo Escuro' darkModeSwitchTitle: 'Mudar para Modo Escuro',
skipToContentLabel: 'Pular para o Conteúdo'
} }
}) })

@ -42,7 +42,8 @@ export const ru = defineConfig({
darkModeSwitchTitle: 'Переключить на тёмную тему', darkModeSwitchTitle: 'Переключить на тёмную тему',
sidebarMenuLabel: 'Меню', sidebarMenuLabel: 'Меню',
returnToTopLabel: 'Вернуться к началу', returnToTopLabel: 'Вернуться к началу',
langMenuLabel: 'Изменить язык' langMenuLabel: 'Изменить язык',
skipToContentLabel: 'Перейти к содержимому'
} }
}) })

@ -48,7 +48,8 @@ export const zh = defineConfig({
sidebarMenuLabel: '菜单', sidebarMenuLabel: '菜单',
darkModeSwitchLabel: '主题', darkModeSwitchLabel: '主题',
lightModeSwitchTitle: '切换到浅色模式', lightModeSwitchTitle: '切换到浅色模式',
darkModeSwitchTitle: '切换到深色模式' darkModeSwitchTitle: '切换到深色模式',
skipToContentLabel: '跳转到内容'
} }
}) })

@ -444,6 +444,13 @@ Can be used to customize the label of the return to top button. This label is on
Can be used to customize the aria-label of the language toggle button in navbar. This is only used if you're using [i18n](../guide/i18n). Can be used to customize the aria-label of the language toggle button in navbar. This is only used if you're using [i18n](../guide/i18n).
## skipToContentLabel
- Type: `string`
- Default: `Skip to content`
Can be used to customize the label of the skip to content link. This link is shown when the user is navigating the site using a keyboard.
## externalLinkIcon ## externalLinkIcon
- Type: `boolean` - Type: `boolean`

@ -1,7 +1,9 @@
<script lang="ts" setup> <script lang="ts" setup>
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
import { useRoute } from 'vitepress' import { useRoute } from 'vitepress'
import { useData } from '../composables/data'
const { theme } = useData()
const route = useRoute() const route = useRoute()
const backToTop = ref() const backToTop = ref()
@ -33,7 +35,7 @@ function focusOnTargetAnchor({ target }: Event) {
class="VPSkipLink visually-hidden" class="VPSkipLink visually-hidden"
@click="focusOnTargetAnchor" @click="focusOnTargetAnchor"
> >
Skip to content {{ theme.skipToContentLabel || 'Skip to content' }}
</a> </a>
</template> </template>

@ -126,6 +126,11 @@ export namespace DefaultTheme {
*/ */
langMenuLabel?: string langMenuLabel?: string
/**
* @default 'Skip to content'
*/
skipToContentLabel?: string
search?: search?:
| { provider: 'local'; options?: LocalSearchOptions } | { provider: 'local'; options?: LocalSearchOptions }
| { provider: 'algolia'; options: AlgoliaSearchOptions } | { provider: 'algolia'; options: AlgoliaSearchOptions }

Loading…
Cancel
Save