Skip to content

Commit 6d5055d

Browse files
committed
Update content URL to support version selection
1 parent 15fc816 commit 6d5055d

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

xp-archive/client/contentTree/contentTreeEntry/NavigationItem.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ type Props = {
1313
export const getContentIconUrl = (type: string) =>
1414
`${import.meta.env.VITE_APP_ORIGIN}/xp/api/contentIcon?type=${type}`;
1515

16-
export const updateContentUrl = (id: string, locale: string) => {
17-
const newUrl = `${xpArchiveConfig.basePath}/${id}/${locale}`;
16+
export const updateContentUrl = (nodeId: string, locale: string, versionId?: string) => {
17+
const newUrl = `${xpArchiveConfig.basePath}/${nodeId}/${locale}/${versionId ?? ''}`;
1818
window.history.pushState({}, '', newUrl);
1919
};
2020

xp-archive/client/versionSelector/VersionSelector.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { VersionReference } from 'shared/types';
44
import { pruneString } from '@common/shared/pruneString';
55
import { formatTimestamp } from '@common/shared/timestamp';
66
import { useAppState } from 'client/context/appState/useAppState';
7+
import { updateContentUrl } from 'client/contentTree/contentTreeEntry/NavigationItem';
78

89
// function getOptions(versions: VersionReference[]): { label: string; value: string }[] {
910
// const sisteVersjon = { label: 'Siste versjon', value: 'Siste versjon' };
@@ -29,6 +30,7 @@ export const VersionSelector = ({ versions }: Props) => {
2930
const versionId = e.target.value;
3031
const nodeId = versions.find((v) => v.versionId === versionId)?.nodeId;
3132
setSelectedVersion({ nodeId, versionId });
33+
updateContentUrl(nodeId ?? '', 'no', versionId); // TODO: fiks hardkodet locale
3234
};
3335

3436
// const selectVersionC = (versionId: string) => {

0 commit comments

Comments
 (0)