Skip to content

Commit

Permalink
feat(theme): allow customizing skip to content label
Browse files Browse the repository at this point in the history
closes #4288
  • Loading branch information
brc-dd committed Dec 6, 2024
1 parent 18858f7 commit ff254dc
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 6 deletions.
3 changes: 2 additions & 1 deletion docs/.vitepress/config/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export const es = defineConfig({
sidebarMenuLabel: 'Menu Lateral',
darkModeSwitchLabel: 'Tema Oscuro',
lightModeSwitchTitle: 'Cambiar a modo claro',
darkModeSwitchTitle: 'Cambiar a modo oscuro'
darkModeSwitchTitle: 'Cambiar a modo oscuro',
skipToContentLabel: 'Saltar al contenido'
}
})

Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/config/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ export const ko = defineConfig({
sidebarMenuLabel: '사이드바 메뉴',
darkModeSwitchLabel: '다크 모드',
lightModeSwitchTitle: '라이트 모드로 변경',
darkModeSwitchTitle: '다크 모드로 변경'
darkModeSwitchTitle: '다크 모드로 변경',
skipToContentLabel: '본문으로 건너뛰기'
}
})

Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/config/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export const pt = defineConfig({
sidebarMenuLabel: 'Menu Lateral',
darkModeSwitchLabel: 'Tema Escuro',
lightModeSwitchTitle: 'Mudar para Modo Claro',
darkModeSwitchTitle: 'Mudar para Modo Escuro'
darkModeSwitchTitle: 'Mudar para Modo Escuro',
skipToContentLabel: 'Pular para o Conteúdo'
}
})

Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/config/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ export const ru = defineConfig({
darkModeSwitchTitle: 'Переключить на тёмную тему',
sidebarMenuLabel: 'Меню',
returnToTopLabel: 'Вернуться к началу',
langMenuLabel: 'Изменить язык'
langMenuLabel: 'Изменить язык',
skipToContentLabel: 'Перейти к содержимому'
}
})

Expand Down
3 changes: 2 additions & 1 deletion docs/.vitepress/config/zh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ export const zh = defineConfig({
sidebarMenuLabel: '菜单',
darkModeSwitchLabel: '主题',
lightModeSwitchTitle: '切换到浅色模式',
darkModeSwitchTitle: '切换到深色模式'
darkModeSwitchTitle: '切换到深色模式',
skipToContentLabel: '跳转到内容'
}
})

Expand Down
7 changes: 7 additions & 0 deletions docs/en/reference/default-theme-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

## 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

- Type: `boolean`
Expand Down
4 changes: 3 additions & 1 deletion src/client/theme-default/components/VPSkipLink.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<script lang="ts" setup>
import { ref, watch } from 'vue'
import { useRoute } from 'vitepress'
import { useData } from '../composables/data'
const { theme } = useData()
const route = useRoute()
const backToTop = ref()
Expand Down Expand Up @@ -33,7 +35,7 @@ function focusOnTargetAnchor({ target }: Event) {
class="VPSkipLink visually-hidden"
@click="focusOnTargetAnchor"
>
Skip to content
{{ theme.skipToContentLabel || 'Skip to content' }}
</a>
</template>

Expand Down
5 changes: 5 additions & 0 deletions types/default-theme.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ export namespace DefaultTheme {
*/
langMenuLabel?: string

/**
* @default 'Skip to content'
*/
skipToContentLabel?: string

search?:
| { provider: 'local'; options?: LocalSearchOptions }
| { provider: 'algolia'; options: AlgoliaSearchOptions }
Expand Down

0 comments on commit ff254dc

Please sign in to comment.