Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,10 @@ const dataLoaderOptionsFor = (routePath: string): DataLoaderOptions => ({
export async function generateMetadata({
params,
}: {
params: {
slug: string[];
};
params: Promise<{ slug?: string | string[]; }>
}): Promise<Metadata> {
const routePath = params.slug && Array.isArray(params.slug) ? params.slug.join('/') : '/';
const { slug } = await params;
const routePath = slug && Array.isArray(params.slug) ? params.slug.join('/') : '/';
const neosData = await loadDocumentPropsCached(routePath, dataLoaderOptionsFor(routePath));
if (!neosData) {
return {};
Expand All @@ -153,7 +152,8 @@ export async function generateMetadata({
}

// And this will render the page output
const Page = async ({ params: { slug } }: { params: { slug: string[] } }) => {
const Page = async ({ params }: { params: Promise<{ slug: string[] }> }) => {
const { slug } = await params;
const routePath = slug && Array.isArray(slug) ? slug.join('/') : '/';
const dataLoaderOptions = dataLoaderOptionsFor(routePath);
const neosData = await loadDocumentPropsCached(routePath, dataLoaderOptions);
Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-simple-import-sort": "^8.0.0",
"next": "^13.4.0",
"next": "^15.3.4",
"prettier": "^2.7.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"typescript": "^5.1.0",
"vitest": "^1.2.1"
"vitest": "^1.6.1"
},
"peerDependencies": {
"next": "^12.2.0 || ^13.0.0 || ^14.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"next": "^15.0.0",
"react": "^19.0.0",
"react-dom": "^19.0.0"
},
"files": [
"src",
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ContentCollection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useContext } from 'react';
import { useContext, type JSX } from 'react';

import NeosContext from '../../utils/context';
import { useContentCollection, useInBackend } from '../../utils/hooks';
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/ContentComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from 'react';
import { ReactNode, type JSX } from 'react';

import { useContentComponent } from '../../utils/hooks';

Expand Down
2 changes: 2 additions & 0 deletions src/lib/components/Editable.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { useEditPreviewMode, useInBackend, useNode } from '../../utils/hooks';

import type { JSX } from "react";

type EditableProps = {
as?: keyof JSX.IntrinsicElements;
property: string;
Expand Down
2 changes: 2 additions & 0 deletions src/server/components/ContentCollection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ContextProps } from '../../types';
import ContentCollectionProvider from './ContentCollectionProvider';

import type { JSX } from "react";

type ContentCollectionProps = {
ctx: ContextProps;
as?: keyof JSX.IntrinsicElements;
Expand Down
2 changes: 1 addition & 1 deletion src/server/components/ContentComponent.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ReactNode } from 'react';
import { ReactNode, type JSX } from 'react';

import { ContextProps } from '../../types';
import ContentComponentProvider from './ContentComponentProvider';
Expand Down
2 changes: 2 additions & 0 deletions src/server/components/Editable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { ContextProps } from '../../types';
import { withEditPreviewMode, withNode } from '../utils/hooks';

import type { JSX } from "react";

type EditableProps = {
ctx: ContextProps;
as?: keyof JSX.IntrinsicElements;
Expand Down
8 changes: 4 additions & 4 deletions src/server/utils/dataLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const loadPreviewDocumentProps = async (
const startTime = Date.now();
const fetchUrl = apiUrl + '/neos/content-api/document?contextPath=' + encodeURIComponent(contextPath);
const response = await fetch(fetchUrl, {
headers: buildNeosPreviewHeaders(),
headers: await buildNeosPreviewHeaders(),
cache: 'no-store',
});

Expand Down Expand Up @@ -239,8 +239,8 @@ async function handleNotOkResponse(response: Response, fetchUrl: string): Promis
throw new ApiError('Content API responded with unexpected error', response.status, fetchUrl, undefined, responseBody);
}

export const buildNeosPreviewHeaders = () => {
const _headers = nextHeaders();
export const buildNeosPreviewHeaders = async () => {
const _headers = await nextHeaders();

const headers: HeadersInit = {
// Pass the cookie to headless API to forward the Neos session
Expand Down Expand Up @@ -269,7 +269,7 @@ export const buildNeosPreviewHeaders = () => {
}
}
return headers;
};
}

const applyProxyHeaders = (headers: Record<string, string>, baseUrl: string) => {
const publicBaseUrl = new URL(baseUrl);
Expand Down
6 changes: 5 additions & 1 deletion src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export const withZebra = (nextConfig: NextConfig): NextConfig => {
return rewrites.concat(neosRewrites);
}

rewrites.afterFiles = rewrites.afterFiles.concat(neosRewrites);
if (Array.isArray(rewrites.afterFiles)) {
rewrites.afterFiles = rewrites.afterFiles?.concat(neosRewrites);
} else {
rewrites.afterFiles = neosRewrites;
}
return rewrites;
},
};
Expand Down
Loading