Skip to content

High performance self-hosted photo and video management solution.

docs: version switcher (#10091)

Jason Rasmussen321c3ccfc6b1
diff --git a/docs/docusaurus.config.js b/docs/docusaurus.config.js
index 5962407dcc..902d7e900e 100644
--- a/docs/docusaurus.config.js
+++ b/docs/docusaurus.config.js
@@ -94,6 +94,10 @@ const config = {
srcDark: 'img/immich-logo-inline-dark.png',
},
items: [
+ {
+ type: 'custom-versionSwitcher',
+ position: 'right',
+ },
{
to: '/docs/overview/introduction',
position: 'right',
diff --git a/docs/src/components/version-switcher.tsx b/docs/src/components/version-switcher.tsx
new file mode 100644
index 0000000000..dae822f4f7
--- /dev/null
+++ b/docs/src/components/version-switcher.tsx
@@ -0,0 +1,59 @@
+import '@docusaurus/theme-classic/lib/theme/Unlisted/index';
+import { useWindowSize } from '@docusaurus/theme-common';
+import DropdownNavbarItem from '@theme/NavbarItem/DropdownNavbarItem';
+import React, { useEffect, useState } from 'react';
+
+export default function VersionSwitcher(): JSX.Element {
+ const [versions, setVersions] = useState([]);
+ const [label, setLabel] = useState('Versions');
+
+ const windowSize = useWindowSize();
+
+ useEffect(() => {
+ async function getVersions() {
+ try {
+ let baseUrl = 'https://immich.app';
+ if (window.location.origin === 'http://localhost:3005') {
+ baseUrl = window.location.origin;
+ }
+
+ const response = await fetch(`${baseUrl}/archived-versions.json`);
+
+ const archiveVersions = await response.json();
+
+ const allVersions = [
+ { label: 'Next', url: 'https://main.preview.immich.app' },
+ { label: 'Latest', url: 'https://immich.app' },
+ ...archiveVersions,
+ ];
+ setVersions(allVersions);
+
+ const activeVersion = allVersions.find((version) => new URL(version.url).origin === window.location.origin);
+ if (activeVersion) {
+ setLabel(activeVersion.label);
+ }
+ } catch (error) {
+ console.error('Failed to fetch versions', error);
+ }
+ }
+
+ if (versions.length === 0) {
+ getVersions();
+ }
+ }, []);
+
+ return (
+ versions.length > 0 && (
+ <DropdownNavbarItem
+ className="navbar__item"
+ label={label}
+ mobile={windowSize === 'mobile'}
+ items={versions.map(({ label, url }) => ({
+ label,
+ to: url,
+ target: '_self',
+ }))}
+ />
+ )
+ );
+}
diff --git a/docs/src/theme/NavbarItem/ComponentTypes.js b/docs/src/theme/NavbarItem/ComponentTypes.js
new file mode 100644
index 0000000000..eb4d4e2aa5
--- /dev/null
+++ b/docs/src/theme/NavbarItem/ComponentTypes.js
@@ -0,0 +1,7 @@
+import ComponentTypes from '@theme-original/NavbarItem/ComponentTypes';
+import VersionSwitcher from '@site/src/components/version-switcher';
+
+export default {
+ ...ComponentTypes,
+ 'custom-versionSwitcher': VersionSwitcher,
+};
diff --git a/docs/static/archived-versions.json b/docs/static/archived-versions.json
new file mode 100644
index 0000000000..e005df9c27
--- /dev/null
+++ b/docs/static/archived-versions.json
@@ -0,0 +1,6 @@
+[
+ {
+ "label": "v1.105.1",
+ "url": "https://v1.105.1.archive.immich.app/"
+ }
+]
diff --git a/misc/release/archive-version.js b/misc/release/archive-version.js
new file mode 100755
index 0000000000..449fe19eb2
--- /dev/null
+++ b/misc/release/archive-version.js
@@ -0,0 +1,17 @@
+#! /usr/bin/env node
+const { readFileSync, writeFileSync } = require('node:fs');
+
+const lastVersion = process.argv[2];
+if (!lastVersion) {
+ console.log('Usage: archive-version.js <version>');
+ process.exit(1);
+}
+
+const filename = './docs/static/archived-versions.json';
+const oldVersions = JSON.parse(readFileSync(filename));
+const newVersions = [
+ { label: lastVersion, url: `https://${lastVersion}.archive.immich.app` },
+ ...oldVersions,
+];
+
+writeFileSync(filename, JSON.stringify(newVersions, null, 2) + '\n');
diff --git a/misc/release/pump-version.sh b/misc/release/pump-version.sh
index 0d0ae4b9e2..81c9cbabb3 100755
--- a/misc/release/pump-version.sh
+++ b/misc/release/pump-version.sh
@@ -83,4 +83,6 @@ sed -i "s/version_number: \"$CURRENT_SERVER\"$/version_number: \"$NEXT_SERVER\"/
sed -i "s/\"android\.injected\.version\.code\" => $CURRENT_MOBILE,/\"android\.injected\.version\.code\" => $NEXT_MOBILE,/" mobile/android/fastlane/Fastfile
sed -i "s/^version: $CURRENT_SERVER+$CURRENT_MOBILE$/version: $NEXT_SERVER+$NEXT_MOBILE/" mobile/pubspec.yaml
+./misc/release/archive-version.js "$NEXT_SERVER"
+
echo "IMMICH_VERSION=v$NEXT_SERVER" >>"$GITHUB_ENV"