Skip to content

Commit 9bb9652

Browse files
committed
feat: add withBase support for taxonomy items
1 parent 95685fc commit 9bb9652

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

.github/workflows/deploy-github-pages.yaml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,20 @@ jobs:
4242
- name: Postprocessing Content
4343
run: |
4444
npm run post-processing-all
45+
- name: Set Base Path
46+
id: set-base-path
47+
run: |
48+
if [ "${{ github.repository }}" != "gardener/documentation" ]; then
49+
echo "VITE_PUBLIC_BASE_PATH=/documentation/" >> $GITHUB_ENV
50+
echo "Base path set to: /documentation/ (fork deployment)"
51+
else
52+
echo "VITE_PUBLIC_BASE_PATH=" >> $GITHUB_ENV
53+
echo "Base path set to: (empty) (main repo deployment to gardener.cloud)"
54+
fi
4555
- name: Build with VitePress
46-
run: npm run docs:build
47-
env:
48-
# Set base path only for forks. Main repo (gardener/documentation) deploys to gardener.cloud without base path.
49-
# Forks deploy to GitHub Pages (username.github.io/documentation/) and need the /documentation/ base path.
50-
VITE_PUBLIC_BASE_PATH: ${{ github.repository != 'gardener/documentation' && '/documentation/' || '' }}
56+
run: |
57+
echo "Building with VITE_PUBLIC_BASE_PATH: '$VITE_PUBLIC_BASE_PATH'"
58+
npm run docs:build
5159
- name: Deploy to gh-pages
5260
uses: peaceiris/actions-gh-pages@v4
5361
if: github.event_name != 'pull_request' && github.ref == 'refs/heads/master' || github.event_name != 'pull_request' && github.ref == 'refs/heads/pr-preview' # ToDo adapt before merging to only use master

.vitepress/theme/layouts/EmptyIndexLayout.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<ul v-if="currentDirItems.length > 0">
1010
<li v-for="item in currentDirItems" :key="getConsistentLink(item.link)">
11-
<a @click="taxonomyItemClicked(getConsistentLink(item.link))" :href="getConsistentLink(item.link)">{{ item.text }}</a>
11+
<a @click="taxonomyItemClicked(getConsistentLink(item.link))" :href="getConsistentLink(withBase(item.link))">{{ item.text }}</a>
1212
</li>
1313
</ul>
1414

@@ -23,7 +23,7 @@
2323
</template>
2424

2525
<script setup>
26-
import { useData, useRouter } from 'vitepress'
26+
import {useData, useRouter, withBase} from 'vitepress'
2727
import { ref, computed, onMounted, nextTick, watch } from 'vue'
2828
import DefaultTheme from 'vitepress/theme'
2929
import { data as sidebars } from '@data/sidebar.data'
@@ -181,6 +181,8 @@ const getConsistentLink = (link) => {
181181
if (consistentLink && !consistentLink.startsWith('/docs')) {
182182
return '/docs' + (consistentLink.startsWith('/') ? consistentLink : '/' + consistentLink)
183183
}
184+
185+
184186
return consistentLink
185187
}
186188

0 commit comments

Comments
 (0)