Skip to content

Commit

Permalink
feat(theme-default): allow nav labels to be set per language (closes:…
Browse files Browse the repository at this point in the history
… 21)
  • Loading branch information
nruffing committed Jan 27, 2024
1 parent 99477cf commit 9047b0f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
11 changes: 6 additions & 5 deletions themes/theme-default/src/client/components/NavbarItems.vue
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,15 @@ useUpdateDeviceStatus(
}
},
)
const navbarLabel = computed(() => {
const themeLocale = useThemeLocaleData()
return themeLocale.value.navbarLabel ?? 'site navigation'
})
</script>

<template>
<nav
v-if="navbarLinks.length"
class="navbar-items"
aria-label="site navigation"
>
<nav v-if="navbarLinks.length" class="navbar-items" :aria-label="navbarLabel">
<div v-for="item in navbarLinks" :key="item.text" class="navbar-item">
<NavbarDropdown
v-if="item.children"
Expand Down
9 changes: 7 additions & 2 deletions themes/theme-default/src/client/components/PageNav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
NavLink,
ResolvedSidebarItem,
} from '../../shared/index.js'
import { useSidebarItems } from '../composables/index.js'
import { useSidebarItems, useThemeLocaleData } from '../composables/index.js'
import { getNavLink } from '../utils/index.js'
/**
Expand Down Expand Up @@ -96,13 +96,18 @@ const nextNavLink = computed(() => {
return resolveFromSidebarItems(sidebarItems.value, route.path, 1)
})
const navbarLabel = computed(() => {
const themeLocale = useThemeLocaleData()
return themeLocale.value.pageNavbarLabel ?? 'page navigation'
})
</script>

<template>
<nav
v-if="prevNavLink || nextNavLink"
class="page-nav"
aria-label="page navigation"
:aria-label="navbarLabel"
>
<p class="inner">
<span v-if="prevNavLink" class="prev">
Expand Down
10 changes: 10 additions & 0 deletions themes/theme-default/src/shared/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,16 @@ export interface DefaultThemeLocaleData extends LocaleData {
*/
navbar?: false | NavbarConfig

/**
* Navbar label used for screen readers using the `aria-label` attribute
*/
navbarLabel?: null | string

/**
* Page navbar label used for screen readers using the `aria-label` attribute
*/
pageNavbarLabel?: null | string

/**
* Navbar logo config
*
Expand Down

0 comments on commit 9047b0f

Please sign in to comment.