diff --git a/.github/workflows/build-deploy.yml b/.github/workflows/build-deploy.yml index 009452c..b148b59 100644 --- a/.github/workflows/build-deploy.yml +++ b/.github/workflows/build-deploy.yml @@ -7,7 +7,7 @@ on: - 'v*' env: - CURRENT_MAJOR_VERSION: "4.0" + CURRENT_MAJOR_VERSION: "3.0" jobs: deploy: @@ -42,22 +42,23 @@ jobs: if [ "$BRANCH_NAME" == "main" ]; then echo "Deploying MAIN as Version ${{ env.CURRENT_MAJOR_VERSION }} (Latest)" - uv run mike deploy --deploy-prefix package -b deploy --rebase ${{ env.CURRENT_MAJOR_VERSION }} latest --update-aliases --push + uv run mike deploy --deploy-prefix package -b deploy ${{ env.CURRENT_MAJOR_VERSION }} latest --update-aliases --push + uv run mike set-default latest --push --deploy-prefix package -b deploy else # Extracts version from branch name (e.g., v3.0 -> 3.0) VERSION=$(echo $BRANCH_NAME | sed 's/^v//') echo "Deploying LEGACY Version: $VERSION" - uv run mike deploy --deploy-prefix package -b deploy --rebase $VERSION --push + uv run mike deploy --deploy-prefix package -b deploy $VERSION --push fi - name: Switch Workspace to HTML Branch - run: git checkout gh-pages + run: git checkout deploy - name: Deploy Entire Collection to Server uses: Burnett01/rsync-deployments@v8 with: switches: -avzr --delete - path: ./ + path: ./package/ remote_path: ${{ secrets.SERVER_PATH }} remote_host: ${{ secrets.SERVER_HOST }} remote_user: ${{ secrets.SERVER_USER }} diff --git a/docs/assets/css/styles.css b/docs/assets/css/styles.css index ff4d6c2..6e15fb6 100644 --- a/docs/assets/css/styles.css +++ b/docs/assets/css/styles.css @@ -17,4 +17,43 @@ article table tbody tr td { .badge.version-badge .value { background-color: #fddca1; color: black; +} +/* Light Mode (Default) */ +#version-selector { + background-color: #f6f8fa; + color: #24292f; + border: 1px solid #d0d7de; + border-radius: 6px; + padding: 4px 24px 4px 8px; + font-size: 12px; + font-weight: 600; + cursor: pointer; + appearance: none; + background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2324292f'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); + background-repeat: no-repeat; + background-position: right 4px center; + background-size: 16px; + transition: background-color 0.2s, border-color 0.2s; +} + +#version-selector:hover { + background-color: #f3f4f6; + border-color: #afb8c1; +} + +/* Dark Mode (When html has .dark class) */ +html.dark #version-selector { + background-color: #24292f; + color: #ffffff; + border-color: #444c56; + background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E"); +} + +html.dark #version-selector:hover { + background-color: #2c333a; + border-color: #768390; +} + +article .codehilite { + overflow: scroll; } \ No newline at end of file diff --git a/docs/assets/js/scripts.js b/docs/assets/js/scripts.js new file mode 100644 index 0000000..e3856dc --- /dev/null +++ b/docs/assets/js/scripts.js @@ -0,0 +1,52 @@ +document.addEventListener("DOMContentLoaded", function() { + const path = window.location.pathname; + const match = path.match(/(.*\/)(?:v?\d+\.\d+|latest)\//); + const base_path = match ? match[1] : path.substring(0, path.lastIndexOf('/') + 1); + const json_url = `${base_path}versions.json`; + const stargazers_element = document.querySelector('header div div:nth-child(3) a'); + + if (!stargazers_element) { + console.warn("Could not find the stargazers element to attach the version selector."); + return; + } + fetch(json_url) + .then(response => response.json()) + .then(data => { + const container = document.createElement("div"); + container.style.display = "flex"; + container.style.alignItems = "center"; + container.style.marginLeft = "12px"; // Space between stars and version + + // 2. Create the select element + const select = document.createElement("select"); + select.id = "version-selector"; + select.style.padding = "4px 8px"; + select.style.border = "1px solid #444"; + select.style.borderRadius = "6px"; + select.style.fontSize = "12px"; + select.style.fontWeight = "600"; + select.onchange = function() { window.location.href = this.value; }; + + // 3. Populate options + const currentPath = window.location.pathname; + data.forEach(v => { + const opt = document.createElement("option"); + const isLatest = v.aliases.includes("latest"); + + // If it's the latest, point to the /latest/ alias instead of the version folder + opt.value = isLatest ? `${base_path}/latest/` : `${base_path}/${v.version}/`; + + opt.textContent = isLatest ? `${v.title} (latest)` : v.title; + + if (currentPath.includes(`/${v.version}/`) || (isLatest && currentPath.includes('/latest/'))) { + opt.selected = true; + } + select.appendChild(opt); + }); + + container.appendChild(select); + + stargazers_element.insertAdjacentElement('afterend', container); + }) + .catch(error => console.error("Error loading versions:", error)); +}); \ No newline at end of file diff --git a/mkdocs.yml b/mkdocs.yml index 2ab6612..0a9b23f 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -1,6 +1,8 @@ site_name: Reitti Documentation site_url: https://www.dedicatedcode.com/projects/reitti/ repo_url: https://github.com/dedicatedcode/reitti +site_author: Daniel Graf +edit_url: https://github.com/dedicatedcode/reitti-documentation/edit/main/docs/ theme: name: shadcn @@ -11,6 +13,7 @@ theme: dark: github-dark topbar_sections: false show_datetime: true + custom_dir: theme/overrides plugins: - mkdocs-nav-weight - badges @@ -21,6 +24,10 @@ plugins: 'configurations/reitti-integration.md': 'integrations/reitti.md' markdown_extensions: - codehilite - +extra: + version: + provider: mike +extra_javascript: + - assets/js/scripts.js extra_css: - assets/css/styles.css \ No newline at end of file diff --git a/theme/overrides/templates/copy_button.html b/theme/overrides/templates/copy_button.html new file mode 100644 index 0000000..e69de29 diff --git a/theme/overrides/templates/footer.html b/theme/overrides/templates/footer.html new file mode 100644 index 0000000..7a79894 --- /dev/null +++ b/theme/overrides/templates/footer.html @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/uv.lock b/uv.lock index 91c522b..7b3722f 100644 --- a/uv.lock +++ b/uv.lock @@ -388,7 +388,7 @@ wheels = [ [[package]] name = "reitti-documentation" -version = "0.1.0" +version = "3.0" source = { virtual = "." } dependencies = [ { name = "mike" },