From affe539383bf7c6b4de366015fb87f18bf3bd963 Mon Sep 17 00:00:00 2001 From: Pasquale Antonante Date: Sun, 18 Feb 2024 21:33:18 -0800 Subject: [PATCH] Docs version selector --- .github/workflows/deploy_docs.yml | 50 --------------------------- docs/astro.config.mjs | 6 ++++ docs/src/components/ThemeSelect.astro | 29 ++++++++++++++++ docs/src/content/config.ts | 9 +++++ 4 files changed, 44 insertions(+), 50 deletions(-) delete mode 100644 .github/workflows/deploy_docs.yml create mode 100644 docs/src/components/ThemeSelect.astro diff --git a/.github/workflows/deploy_docs.yml b/.github/workflows/deploy_docs.yml deleted file mode 100644 index ec802d6..0000000 --- a/.github/workflows/deploy_docs.yml +++ /dev/null @@ -1,50 +0,0 @@ -name: Deploy docs - -on: - push: - branches: - - main - paths: - - docs/** - pull_request: - types: [opened, synchronize, reopened, closed] - paths: - - docs/** - branches: - - main - -jobs: - build_and_deploy_job: - if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed') - runs-on: ubuntu-latest - name: Build and Deploy Job - steps: - - uses: actions/checkout@v3 - with: - submodules: true - lfs: false - - name: Build And Deploy - id: builddeploy - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_CALM_BAY_0D448F910 }} - repo_token: ${{ secrets.GITHUB_TOKEN }} # Used for Github integrations (i.e. PR comments) - action: "upload" - ###### Repository/Build Configurations - These values can be configured to match your app requirements. ###### - # For more information regarding Static Web App workflow configurations, please visit: https://aka.ms/swaworkflowconfig - app_location: "/docs" # App source code path - api_location: "" # Api source code path - optional - output_location: "/dist" # Built app content directory - optional - ###### End of Repository/Build Configurations ###### - - close_pull_request_job: - if: github.event_name == 'pull_request' && github.event.action == 'closed' - runs-on: ubuntu-latest - name: Close Pull Request Job - steps: - - name: Close Pull Request - id: closepullrequest - uses: Azure/static-web-apps-deploy@v1 - with: - azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN_CALM_BAY_0D448F910 }} - action: "close" diff --git a/docs/astro.config.mjs b/docs/astro.config.mjs index d0e55b3..3a1fa2a 100644 --- a/docs/astro.config.mjs +++ b/docs/astro.config.mjs @@ -5,6 +5,8 @@ import rehypeMathjax from 'rehype-mathjax'; // https://astro.build/config export default defineConfig({ + base: '/v0.3', + outDir: './dist/v0.3', markdown: { remarkPlugins: [remarkMath], rehypePlugins: [rehypeMathjax], @@ -12,6 +14,10 @@ export default defineConfig({ integrations: [ starlight({ title: 'Continuous Eval', + components: { + // Override the default `SocialIcons` component. + ThemeSelect: './src/components/ThemeSelect.astro', + }, tableOfContents: { minHeadingLevel: 2, maxHeadingLevel: 4, }, customCss: [ // Relative path to your custom CSS file diff --git a/docs/src/components/ThemeSelect.astro b/docs/src/components/ThemeSelect.astro new file mode 100644 index 0000000..092de5e --- /dev/null +++ b/docs/src/components/ThemeSelect.astro @@ -0,0 +1,29 @@ +--- +import type { Props } from '@astrojs/starlight/props'; +import Default from '@astrojs/starlight/components/ThemeSelect.astro'; +import Select from '@astrojs/starlight/components/Select.astro'; +import { defaultVersion, versions } from '../content/config.ts'; + +const url = new URL(Astro.url); +const currentVersion = /^\/v\d+/.test(url.pathname) + ? url.pathname.split('/')[1] + : defaultVersion; +const options = versions.map(([version, label]) => ({ + label, + selected: currentVersion === version, + value: `/${version}`, +})); +--- + + + +