-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* docs: version switcher * chore: pump script * chore: fix linting on bash script * chore: remove 1.106.0 from archived versions * chore: change version archive script to take next server version not current version --------- Co-authored-by: Zack Pollard <[email protected]>
- Loading branch information
1 parent
05874bd
commit 321c3cc
Showing
6 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}))} | ||
/> | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
{ | ||
"label": "v1.105.1", | ||
"url": "https://v1.105.1.archive.immich.app/" | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters