Skip to content

Commit 15fc816

Browse files
committed
legg til versionId i html-visningen
1 parent 6a50479 commit 15fc816

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

xp-archive/client/contentView/ContentView.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,13 @@ import style from './ContentView.module.css';
1111
const getDisplayComponent = (viewVariant: ViewVariant, data?: ContentServiceResponse | null) => {
1212
if (!data) return null;
1313
const components: Record<ViewVariant, React.ReactElement> = {
14-
html: <HtmlView nodeId={data.json._id} locale={data.json.language} />,
14+
html: (
15+
<HtmlView
16+
nodeId={data.json._id}
17+
locale={data.json.language}
18+
versionId={data.json._versionKey}
19+
/>
20+
),
1521
filepreview: <FilePreviewWrapper content={data.json} />,
1622
pdf: <PdfExport versions={data.versions} />,
1723
};

xp-archive/client/contentView/htmlView/HtmlView.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ import { Button, Loader } from '@navikt/ds-react';
77
type Props = {
88
nodeId: string;
99
locale: string;
10+
versionId: string;
1011
};
1112

12-
export const HtmlView = ({ nodeId, locale }: Props) => {
13+
export const HtmlView = ({ nodeId, locale, versionId }: Props) => {
1314
const [isLoading, setIsLoading] = useState(true);
14-
const htmlPath = `${xpArchiveConfig.basePath}/html/${nodeId}/${locale || ''}`;
15+
const htmlPath = `${xpArchiveConfig.basePath}/html/${nodeId}/${locale || ''}/${versionId || ''}`;
1516

1617
return (
1718
<div className={style.wrapper}>

xp-archive/server/src/routing/site.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ const setupApiRoutes = async (router: Router) => {
4949
const setupBrowserRoutes = async (router: Router, htmlRenderer: HtmlRenderer) => {
5050
const contentService = new ContentService();
5151

52-
router.get('/html/:contentId/:locale', async (req, res, next) => {
53-
const { contentId, locale } = req.params;
52+
router.get('/html/:contentId/:locale/:versionId', async (req, res, next) => {
53+
const { contentId, locale, versionId } = req.params;
5454

55-
const content = await contentService.fetchContent(contentId, locale);
55+
const content = await contentService.fetchContent(contentId, locale, versionId);
5656
if (!content) {
5757
return next();
5858
}
@@ -64,10 +64,10 @@ const setupBrowserRoutes = async (router: Router, htmlRenderer: HtmlRenderer) =>
6464
return res.send(content.html);
6565
});
6666

67-
router.get('/:contentId/:locale', async (req, res, next) => {
68-
const { contentId, locale } = req.params;
67+
router.get('/:contentId/:locale/:versionId', async (req, res, next) => {
68+
const { contentId, locale, versionId } = req.params;
6969

70-
const content = await contentService.fetchContent(contentId, locale);
70+
const content = await contentService.fetchContent(contentId, locale, versionId);
7171
if (!content) {
7272
return next();
7373
}

0 commit comments

Comments
 (0)