mirror of
https://github.com/supabase/supabase.git
synced 2026-10-15 14:19:11 +03:00
* add cms turbo app * add cms scripts to package.json * update README * update README * update files * fix formatting * fix populateAuthors * sync dependencies * update launch week field * update lint config * Coordinate the deps to be the same as the other apps. * Remove extra files. * Run prettier on the CMS files. * Add commands for cleaning and typechecking. * Fix weird version of @types/react in docs. * run pnpm install * fix pnpm-lock * fix cms lint --------- Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
32 lines
805 B
TypeScript
32 lines
805 B
TypeScript
import { PayloadRequest, CollectionSlug } from 'payload'
|
|
|
|
const collectionPrefixMap: Partial<Record<CollectionSlug, string>> = {
|
|
posts: '/blog',
|
|
pages: '',
|
|
}
|
|
|
|
type Props = {
|
|
collection: keyof typeof collectionPrefixMap
|
|
slug: string
|
|
req: PayloadRequest
|
|
}
|
|
|
|
export const generatePreviewPath = ({ collection, slug }: Props) => {
|
|
if (collection === 'posts') {
|
|
const baseUrl = process.env.BLOG_APP_URL || 'http://localhost:3000'
|
|
// Use our preview API route for post previews
|
|
return `${baseUrl}/api/preview?slug=${slug}`
|
|
}
|
|
|
|
const encodedParams = new URLSearchParams({
|
|
slug,
|
|
collection,
|
|
path: `${collectionPrefixMap[collection]}/${slug}`,
|
|
previewSecret: process.env.PREVIEW_SECRET || '',
|
|
})
|
|
|
|
const url = `/next/preview?${encodedParams.toString()}`
|
|
|
|
return url
|
|
}
|