-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #909 from GrabarzUndPartner/feature/docs-version-s…
…witch docs(update): added version switch
- Loading branch information
Showing
11 changed files
with
151 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<script setup> | ||
import { useData } from 'vitepress/dist/client/theme-default/composables/data'; | ||
import VPNavBarMenuLink from 'vitepress/dist/client/theme-default/components/VPNavBarMenuLink.vue'; | ||
import VPNavBarMenuGroup from 'vitepress/dist/client/theme-default/components/VPNavBarMenuGroup.vue'; | ||
import { useVersion } from '../composables/version.mjs'; | ||
const { theme } = useData(); | ||
const { nav: versionNav } = useVersion(); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<nav | ||
v-if="versionNav" | ||
aria-labelledby="main-nav-aria-label" | ||
class="VPNavBarMenu" | ||
> | ||
<span id="main-nav-aria-label" class="visually-hidden" | ||
>Version Navigation</span | ||
> | ||
<template v-for="item in versionNav" :key="item.text"> | ||
<v-p-nav-bar-menu-link v-if="'link' in item" :item="item" /> | ||
<v-p-nav-bar-menu-group v-else :item="item" /> | ||
</template> | ||
</nav> | ||
<nav | ||
v-if="theme.nav" | ||
aria-labelledby="main-nav-aria-label" | ||
class="VPNavBarMenu" | ||
> | ||
<span id="main-nav-aria-label" class="visually-hidden" | ||
>Main Navigation</span | ||
> | ||
<template v-for="item in theme.nav" :key="item.text"> | ||
<v-p-nav-bar-menu-link v-if="'link' in item" :item="item" /> | ||
<v-p-nav-bar-menu-group v-else :item="item" /> | ||
</template> | ||
</nav> | ||
</div> | ||
</template> | ||
|
||
<style scoped> | ||
/* stylelint-disable selector-class-pattern */ | ||
.VPNavBarMenu { | ||
display: none; | ||
} | ||
@media (width >=768px) { | ||
.VPNavBarMenu { | ||
display: flex; | ||
} | ||
} | ||
</style> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<script lang="ts" setup> | ||
import { useData } from 'vitepress/dist/client/theme-default/composables/data'; | ||
import VPNavScreenMenuLink from 'vitepress/dist/client/theme-default/components/VPNavScreenMenuLink.vue'; | ||
import VPNavScreenMenuGroup from 'vitepress/dist/client/theme-default/components/VPNavScreenMenuGroup.vue'; | ||
import { useVersion } from '../composables/version.mjs'; | ||
const { theme } = useData(); | ||
const { nav: versionNav } = useVersion(); | ||
</script> | ||
|
||
<template> | ||
<div> | ||
<nav v-if="versionNav" class="VPNavScreenMenu"> | ||
<template v-for="item in versionNav" :key="item.text"> | ||
<v-p-nav-screen-menu-link v-if="'link' in item" :item="item" /> | ||
<v-p-nav-screen-menu-group | ||
v-else | ||
:text="item.text || ''" | ||
:items="item.items" | ||
/> | ||
</template> | ||
</nav> | ||
<nav v-if="theme.nav" class="VPNavScreenMenu"> | ||
<template v-for="item in theme.nav" :key="item.text"> | ||
<v-p-nav-screen-menu-link v-if="'link' in item" :item="item" /> | ||
<v-p-nav-screen-menu-group | ||
v-else | ||
:text="item.text || ''" | ||
:items="item.items" | ||
/> | ||
</template> | ||
</nav> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { useData } from 'vitepress/dist/client/theme-default/composables/data'; | ||
import { computed } from 'vue'; | ||
|
||
export function useVersion() { | ||
const { theme, page } = useData(); | ||
|
||
const defaultVersion = computed( | ||
() => theme.value.version.find(({ isDefault }) => isDefault)?.version | ||
); | ||
|
||
const currentVersion = computed(() => | ||
Number( | ||
(/v(\d+)\/.*/.test(page.value.relativePath) && | ||
page.value.relativePath.replace(/v(\d+)\/.*/, '$1')) || | ||
defaultVersion.value | ||
) | ||
); | ||
|
||
const nav = computed(() => { | ||
return ( | ||
theme.value.version?.length && [ | ||
{ | ||
text: `v${currentVersion.value}`, | ||
items: theme.value.version | ||
.filter(({ version }) => version !== currentVersion.value) | ||
.map(({ version, isDefault }) => { | ||
return { | ||
text: `v${version}`, | ||
link: isDefault ? '/' : `/v${version}/` | ||
}; | ||
}) | ||
} | ||
] | ||
); | ||
}); | ||
|
||
return { | ||
defaultVersion, | ||
currentVersion, | ||
nav | ||
}; | ||
} |