fix: syntax issues
This commit is contained in:
@@ -1,3 +1 @@
|
||||
{
|
||||
"importMap": {}
|
||||
}
|
||||
export const importMap = {};
|
||||
|
||||
@@ -4,7 +4,7 @@ import config from '@payload-config';
|
||||
import '@payloadcms/next/css';
|
||||
import type { ServerFunctionClient } from 'payload';
|
||||
import { handleServerFunctions, RootLayout } from '@payloadcms/next/layouts';
|
||||
import { importMap } from '../../../admin/importMap';
|
||||
import { importMap } from '../../../../admin/importMap';
|
||||
|
||||
type Args = { children: React.ReactNode };
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import type { Metadata } from 'next';
|
||||
import config from '@payload-config';
|
||||
import { generatePageMetadata, RootPage } from '@payloadcms/next/views';
|
||||
import { importMap } from '../../admin/importMap';
|
||||
import { importMap } from '../../../../admin/importMap';
|
||||
|
||||
type Args = {
|
||||
params: Promise<{ segments: string[] }>;
|
||||
|
||||
@@ -4,7 +4,7 @@ import config from '@payload-config';
|
||||
import '@payloadcms/next/css';
|
||||
import type { ServerFunctionClient } from 'payload';
|
||||
import { handleServerFunctions, RootLayout } from '@payloadcms/next/layouts';
|
||||
import { importMap } from './admin/importMap';
|
||||
import { importMap } from '../admin/importMap';
|
||||
import './custom.scss';
|
||||
|
||||
type Args = {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { CollectionConfig } from 'payload';
|
||||
import { revalidateAstro } from '../hooks/revalidateAstro';
|
||||
|
||||
/**
|
||||
* Returns a new collection config that appends the Astro revalidation hook
|
||||
* to `hooks.afterChange` without mutating the original module-level config.
|
||||
*/
|
||||
export function withRevalidate<T extends CollectionConfig>(config: T): T {
|
||||
const existing = (config.hooks?.afterChange ?? []) as NonNullable<
|
||||
NonNullable<CollectionConfig['hooks']>['afterChange']
|
||||
>;
|
||||
return {
|
||||
...config,
|
||||
hooks: {
|
||||
...config.hooks,
|
||||
afterChange: [...existing, revalidateAstro],
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import { Tags } from './collections/Tags';
|
||||
import { Editions } from './collections/Editions';
|
||||
import { Subscribers } from './collections/Subscribers';
|
||||
|
||||
import { revalidateAstro } from './hooks/revalidateAstro';
|
||||
import { withRevalidate } from './lib/withRevalidate';
|
||||
|
||||
const filename = fileURLToPath(import.meta.url);
|
||||
const dirname = path.dirname(filename);
|
||||
@@ -23,6 +23,13 @@ const corsOrigins = (process.env.CORS_ORIGINS || '')
|
||||
.map((s) => s.trim())
|
||||
.filter(Boolean);
|
||||
|
||||
// Wrap each publishing collection so a save fires the Astro rebuild webhook.
|
||||
const articles = withRevalidate(Articles);
|
||||
const authors = withRevalidate(Authors);
|
||||
const categories = withRevalidate(Categories);
|
||||
const tags = withRevalidate(Tags);
|
||||
const editions = withRevalidate(Editions);
|
||||
|
||||
export default buildConfig({
|
||||
serverURL: process.env.SERVER_URL,
|
||||
cors: corsOrigins,
|
||||
@@ -34,7 +41,7 @@ export default buildConfig({
|
||||
titleSuffix: ' · SoftVowels CMS',
|
||||
},
|
||||
},
|
||||
collections: [Users, Media, Articles, Authors, Categories, Tags, Editions, Subscribers],
|
||||
collections: [Users, Media, articles, authors, categories, tags, editions, Subscribers],
|
||||
editor: lexicalEditor(),
|
||||
secret: process.env.PAYLOAD_SECRET || 'dev-secret-change-me',
|
||||
typescript: {
|
||||
@@ -45,7 +52,6 @@ export default buildConfig({
|
||||
connectionString: process.env.DATABASE_URI || '',
|
||||
},
|
||||
}),
|
||||
sharp: (sharp) => sharp,
|
||||
upload: {
|
||||
limits: {
|
||||
fileSize: 25_000_000,
|
||||
@@ -53,6 +59,10 @@ export default buildConfig({
|
||||
},
|
||||
endpoints: [],
|
||||
hooks: {
|
||||
afterChange: [revalidateAstro],
|
||||
afterError: [
|
||||
async (err) => {
|
||||
console.error('[payload] afterError', err.error);
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user