Skip to content

Commit

Permalink
Merge pull request #909 from GrabarzUndPartner/feature/docs-version-s…
Browse files Browse the repository at this point in the history
…witch

docs(update): added version switch
  • Loading branch information
ThornWalli authored Nov 27, 2023
2 parents 08e50d4 + 2fb664a commit 4b32b46
Show file tree
Hide file tree
Showing 11 changed files with 151 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: [19]
node: [20]

steps:
- uses: actions/setup-node@v4
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: [19]
node: [20]

steps:
- uses: actions/setup-node@v4
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: [19]
node: [20]

steps:
- uses: actions/setup-node@v4
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: [19]
node: [20]

steps:
- uses: actions/setup-node@v4
Expand Down Expand Up @@ -117,7 +117,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: [19]
node: [20]
steps:
- name: Download Artifact (Docs)
uses: actions/download-artifact@master
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/sonar-cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
node: [19]
node: [20]

steps:
- uses: actions/setup-node@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
os: [ubuntu-latest]
#os: [ubuntu-latest, macos-latest, windows-latest]
node: [19]
node: [20]

steps:
- uses: actions/setup-node@v4
Expand Down
14 changes: 13 additions & 1 deletion docs/.vitepress/config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,19 @@ export default defineConfig(() => ({
{
find: /^.*\/VPNavBarTitle\.vue$/,
replacement: fileURLToPath(
new URL('./components/VPNavBarTitle.vue', import.meta.url)
new URL('../components/VPNavBarTitle.vue', import.meta.url)
)
},
{
find: /^.*\/VPNavBarMenu\.vue$/,
replacement: fileURLToPath(
new URL('../components/VPNavBarMenu.vue', import.meta.url)
)
},
{
find: /^.*\/VPNavScreenMenu\.vue$/,
replacement: fileURLToPath(
new URL('../components/VPNavScreenMenu.vue', import.meta.url)
)
}
]
Expand Down
11 changes: 1 addition & 10 deletions docs/.vitepress/navigation.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
export default {
nav: [
{
text: 'Version',
items: [
{ text: 'v3', link: '/' },
{ text: 'v2', link: '/v2/' },
{ text: 'v1', link: '/v1/' }
]
}
],
version: [{ version: 3, isDefault: true }, { version: 2 }, { version: 1 }],

sidebar: {
'/v1/': [
Expand Down
File renamed without changes.
54 changes: 54 additions & 0 deletions docs/components/VPNavBarMenu.vue
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.
34 changes: 34 additions & 0 deletions docs/components/VPNavScreenMenu.vue
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>
42 changes: 42 additions & 0 deletions docs/composables/version.mjs
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
};
}

0 comments on commit 4b32b46

Please sign in to comment.