Skip to content

Commit 81b6a93

Browse files
authored
Merge branch 'main' into olejorgenbakken/issue4566
2 parents 607defd + 06d2dc2 commit 81b6a93

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+1455
-4813
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,4 @@ cypress/videos
2424
!portalen/**
2525
test-results/
2626
playwright-report/
27+
storybook-static/

Dockerfile

+14-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM docker.intern.sparebank1.no/base/cicd-container-base-images/node22-ubi9-minimal:latest as base
1+
FROM docker.intern.sparebank1.no/base/cicd-container-base-images/node22-ubi9-minimal:latest AS base
22

33
WORKDIR /app
44
USER root
@@ -11,34 +11,40 @@ RUN useradd -ms /bin/bash appuser
1111
RUN microdnf install tar -y
1212
RUN microdnf install findutils -y
1313

14-
FROM base as dependencies
14+
FROM base AS dependencies
15+
ARG NEXT_PUBLIC_SANITY_STUDIO_PROJECT_ID
1516

1617
WORKDIR /app
1718
COPY package.json .
1819
COPY pnpm-lock.yaml .
20+
COPY server.js .
1921
COPY patches ./patches
22+
COPY .storybook ./.storybook
2023
COPY packages ./packages
2124
COPY ny-portal ./ny-portal
2225
COPY pnpm-workspace.yaml .
2326
RUN pnpm install --frozen-lockfile
2427
RUN find . -name 'node_modules' -print0 | tar -cf node_modules.tar --null --files-from -
2528

26-
FROM base as builder
29+
FROM base AS builder
30+
ARG NEXT_PUBLIC_SANITY_STUDIO_PROJECT_ID
2731

2832
WORKDIR /app
2933
COPY --from=dependencies /app/node_modules.tar ./node_modules.tar
3034
COPY . .
3135
RUN tar -xf node_modules.tar
32-
RUN pnpm build
33-
RUN cd ny-portal && pnpm build
36+
RUN pnpm --filter "@fremtind/jokul" build
37+
RUN pnpm build-storybook
38+
RUN pnpm --filter "ny-portal" build
3439

35-
FROM base as runner
40+
FROM base AS runner
3641

3742
WORKDIR /app
3843
COPY --from=builder /app/package.json package.json
44+
COPY --from=builder /app/server.js server.js
3945
COPY --from=builder /app/ny-portal ./ny-portal
4046
COPY --from=builder /app/packages/jokul ./packages/jokul
47+
COPY --from=builder /app/storybook-static ./storybook-static
4148
COPY --from=builder /app/node_modules ./node_modules
4249
EXPOSE 3000
43-
WORKDIR /app/ny-portal
44-
CMD pnpm start
50+
CMD pnpm serve

ny-portal/next.config.mjs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { withPayload } from "@payloadcms/next/withPayload";
21
import createMDX from "@next/mdx";
32

43
/** @type {import('next').NextConfig} */
@@ -9,4 +8,4 @@ const nextConfig = {
98

109
const withMdx = createMDX({});
1110

12-
export default withPayload(withMdx(nextConfig));
11+
export default withMdx(nextConfig);

ny-portal/package.json

+1-8
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,16 @@
1111
"generate:importmap": "cross-env NODE_OPTIONS=--no-deprecation payload generate:importmap",
1212
"generate:types": "cross-env NODE_OPTIONS=--no-deprecation payload generate:types",
1313
"lint": "cross-env NODE_OPTIONS=--no-deprecation next lint",
14-
"payload": "cross-env NODE_OPTIONS=--no-deprecation payload",
1514
"start": "cross-env NODE_OPTIONS=--no-deprecation next start -p 3333",
1615
"typegen": "sanity schema extract --path=src/sanity/extract.json && sanity typegen generate"
1716
},
1817
"dependencies": {
19-
"@aws-sdk/client-sts": "^3.731.1",
20-
"@aws-sdk/rds-signer": "^3.731.1",
2118
"@fremtind/jokul": "^0.37.11",
2219
"@mdx-js/loader": "^3.1.0",
2320
"@mdx-js/react": "^2.3.0",
2421
"@next/mdx": "^15.1.6",
25-
"@payloadcms/db-postgres": "latest",
26-
"@payloadcms/next": "latest",
27-
"@payloadcms/richtext-lexical": "latest",
28-
"@payloadcms/ui": "latest",
2922
"@portabletext/react": "^3.2.1",
23+
"@portabletext/types": "^2.0.13",
3024
"@sanity/client": "^6.28.1",
3125
"@sanity/image-url": "^1.1.0",
3226
"@sanity/ui": "^2.14.3",
@@ -37,7 +31,6 @@
3731
"graphql": "^16.8.1",
3832
"next": "15.1.0",
3933
"next-sanity": "^9.8.59",
40-
"payload": "latest",
4134
"react": "^18.3.1",
4235
"react-dom": "^18.3.1",
4336
"react-live": "^4.1.8",

ny-portal/sanity.config.ts

+13-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
import { visionTool } from "@sanity/vision";
22
import { defineConfig } from "sanity";
3+
import type { Config } from "sanity";
34
import { structureTool } from "sanity/structure";
45
import { schemaTypes } from "@/sanity/schemas";
56

6-
export default defineConfig({
7-
name: "default",
8-
basePath: "/studio",
9-
title: "Jøkul Portal Studio",
10-
projectId: process.env.NEXT_PUBLIC_SANITY_STUDIO_PROJECT_ID || "",
11-
dataset: process.env.NEXT_PUBLIC_SANITY_STUDIO_DATASET || "test",
12-
plugins: [structureTool(), visionTool()],
13-
schema: {
14-
types: schemaTypes,
15-
},
16-
});
7+
export function getSanityConfig(config: Config) {
8+
return defineConfig({
9+
name: "default",
10+
basePath: "/studio",
11+
title: "Jøkul Portal Studio",
12+
plugins: [structureTool(), visionTool()],
13+
schema: {
14+
types: schemaTypes,
15+
},
16+
...config,
17+
});
18+
}

ny-portal/src/app/(frontend)/komponenter/[slug]/page.tsx

+3-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import PortableTextRenderer from "@/components/portable-text";
2-
import { PropDocumentation } from "@/components/prop-documentation/PropDocumentation";
1+
import { PortableText } from "@/components/portable-text/PortableText";
32
import { client } from "@/sanity/client";
43
import { componentPageBySlugQuery } from "@/sanity/queries/componentPage";
54

@@ -16,13 +15,9 @@ export default async function Page({
1615
<>
1716
<div>Hei jeg er {data?.title || "ikke i databasen"}</div>
1817

19-
{data?.lede && <PortableTextRenderer value={data.lede} />}
18+
{data?.lede && <PortableText blocks={data.lede} />}
2019

21-
{data?.content && <PortableTextRenderer value={data.content} />}
22-
23-
{data?.component_folder && (
24-
<PropDocumentation component={data.component_folder} />
25-
)}
20+
{data?.content && <PortableText blocks={data.content} />}
2621
</>
2722
);
2823
}

ny-portal/src/app/(frontend)/layout.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import Link from "next/link";
2-
import { Navigation } from "@/components/navigation";
2+
import { Navigation } from "@/components/Navigation";
33
import "./global.scss";
44
import styles from "./layout.module.scss";
55

ny-portal/src/app/(payload)/admin/[[...segments]]/not-found.tsx

-24
This file was deleted.

ny-portal/src/app/(payload)/admin/[[...segments]]/page.tsx

-24
This file was deleted.

ny-portal/src/app/(payload)/admin/importMap.js

-55
This file was deleted.

ny-portal/src/app/(payload)/api/[...slug]/route.ts

-19
This file was deleted.

ny-portal/src/app/(payload)/api/graphql-playground/route.ts

-7
This file was deleted.

ny-portal/src/app/(payload)/api/graphql/route.ts

-8
This file was deleted.

ny-portal/src/app/(payload)/layout.tsx

-29
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import nodePath, { resolve } from "node:path";
2+
import { NextResponse } from "next/server";
3+
import glob from "tiny-glob";
4+
import { PATH_SEPARATOR } from "@/components/portable-text/code-example/CodeExample";
5+
6+
export async function GET() {
7+
try {
8+
const codeExamplePaths = await glob("**/documentation/*.tsx", {
9+
cwd: resolve("..", "packages", "jokul", "src", "components"),
10+
});
11+
12+
const optionGroups = Object.groupBy(
13+
codeExamplePaths.sort().map((examplePath) => ({
14+
label: examplePath.substring(
15+
examplePath.lastIndexOf(nodePath.sep) + 1,
16+
examplePath.lastIndexOf("."),
17+
),
18+
value: examplePath.replaceAll(nodePath.sep, PATH_SEPARATOR),
19+
group: examplePath.split(nodePath.sep)[0],
20+
})),
21+
(examplePaths) => examplePaths.group,
22+
);
23+
24+
return NextResponse.json(optionGroups);
25+
} catch (error) {
26+
console.error("Error reading code example files", error);
27+
return NextResponse.json(
28+
{ error: "Failed to read code example files" },
29+
{ status: 500 },
30+
);
31+
}
32+
}

ny-portal/src/app/studio/Studio.tsx

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"use client";
2+
3+
import { NextStudio } from "next-sanity/studio";
4+
import type { Config } from "sanity";
5+
import { getSanityConfig } from "sanity.config";
6+
7+
export default function Studio(config: Config) {
8+
const sanityConfig = getSanityConfig(config);
9+
10+
return <NextStudio config={sanityConfig} />;
11+
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
"use client";
1+
import Studio from "../Studio";
22

3-
import { NextStudio } from "next-sanity/studio";
4-
import config from "../../../../sanity.config";
5-
6-
export default function Studio() {
7-
return <NextStudio config={config} />;
3+
export default async function StudioPage() {
4+
return (
5+
<Studio
6+
projectId={process.env.SANITY_PROJECT_ID || ""}
7+
dataset={process.env.SANITY_DATASET || "test"}
8+
/>
9+
);
810
}

0 commit comments

Comments
 (0)