Skip to content

Commit

Permalink
templates: bump for v3.4.0 (#9752)
Browse files Browse the repository at this point in the history
Automated bump of templates for v3.4.0

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and github-actions[bot] authored Dec 4, 2024
1 parent fa7ed3f commit fa39b37
Show file tree
Hide file tree
Showing 15 changed files with 252 additions and 198 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "965f2138-755a-4bb6-b83c-ad7827a6a425",
"id": "a621cec0-90cd-4514-bf1a-f98a91b06006",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
Expand Down
8 changes: 4 additions & 4 deletions templates/with-postgres/src/migrations/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as migration_20241204_154138_initial from './20241204_154138_initial'
import * as migration_20241204_184308_initial from './20241204_184308_initial'

export const migrations = [
{
up: migration_20241204_154138_initial.up,
down: migration_20241204_154138_initial.down,
name: '20241204_154138_initial',
up: migration_20241204_184308_initial.up,
down: migration_20241204_184308_initial.down,
name: '20241204_184308_initial',
},
]
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"id": "7b4ead3c-1d17-460a-b8a8-7b202a4fa16c",
"id": "9c8b4aed-7504-439b-a8cd-1911cd4da6d1",
"prevId": "00000000-0000-0000-0000-000000000000",
"version": "7",
"dialect": "postgresql",
Expand Down
8 changes: 4 additions & 4 deletions templates/with-vercel-postgres/src/migrations/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import * as migration_20241204_154113_initial from './20241204_154113_initial'
import * as migration_20241204_184240_initial from './20241204_184240_initial'

export const migrations = [
{
up: migration_20241204_154113_initial.up,
down: migration_20241204_154113_initial.down,
name: '20241204_154113_initial',
up: migration_20241204_184240_initial.up,
down: migration_20241204_184240_initial.down,
name: '20241204_184240_initial',
},
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import type { GlobalAfterChangeHook } from 'payload'

import { revalidateTag } from 'next/cache'

export const revalidateFooter: GlobalAfterChangeHook = ({ doc, req: { payload } }) => {
payload.logger.info(`Revalidating footer`)
export const revalidateFooter: GlobalAfterChangeHook = ({ doc, req: { payload, context } }) => {
if (!context.disableRevalidate) {
payload.logger.info(`Revalidating footer`)

revalidateTag('global_footer')
revalidateTag('global_footer')
}

return doc
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import type { GlobalAfterChangeHook } from 'payload'

import { revalidateTag } from 'next/cache'

export const revalidateHeader: GlobalAfterChangeHook = ({ doc, req: { payload } }) => {
payload.logger.info(`Revalidating header`)
export const revalidateHeader: GlobalAfterChangeHook = ({ doc, req: { payload, context } }) => {
if (!context.disableRevalidate) {
payload.logger.info(`Revalidating header`)

revalidateTag('global_header')
revalidateTag('global_header')
}

return doc
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { seed } from '@/endpoints/seed'
import config from '@payload-config'
import { headers } from 'next/headers'

const payloadToken = 'payload-token'
export const maxDuration = 60 // This function can run for a maximum of 60 seconds

export async function POST(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,37 @@ import type { Page } from '../../../payload-types'
export const revalidatePage: CollectionAfterChangeHook<Page> = ({
doc,
previousDoc,
req: { payload },
req: { payload, context },
}) => {
if (doc._status === 'published') {
const path = doc.slug === 'home' ? '/' : `/${doc.slug}`
if (!context.disableRevalidate) {
if (doc._status === 'published') {
const path = doc.slug === 'home' ? '/' : `/${doc.slug}`

payload.logger.info(`Revalidating page at path: ${path}`)
payload.logger.info(`Revalidating page at path: ${path}`)

revalidatePath(path)
revalidateTag('pages-sitemap')
}
revalidatePath(path)
revalidateTag('pages-sitemap')
}

// If the page was previously published, we need to revalidate the old path
if (previousDoc?._status === 'published' && doc._status !== 'published') {
const oldPath = previousDoc.slug === 'home' ? '/' : `/${previousDoc.slug}`
// If the page was previously published, we need to revalidate the old path
if (previousDoc?._status === 'published' && doc._status !== 'published') {
const oldPath = previousDoc.slug === 'home' ? '/' : `/${previousDoc.slug}`

payload.logger.info(`Revalidating old page at path: ${oldPath}`)
payload.logger.info(`Revalidating old page at path: ${oldPath}`)

revalidatePath(oldPath)
revalidateTag('pages-sitemap')
revalidatePath(oldPath)
revalidateTag('pages-sitemap')
}
}

return doc
}

export const revalidateDelete: CollectionAfterDeleteHook<Page> = ({ doc }) => {
const path = doc?.slug === 'home' ? '/' : `/${doc?.slug}`
revalidatePath(path)
revalidateTag('pages-sitemap')
export const revalidateDelete: CollectionAfterDeleteHook<Page> = ({ doc, req: { context } }) => {
if (!context.disableRevalidate) {
const path = doc?.slug === 'home' ? '/' : `/${doc?.slug}`
revalidatePath(path)
revalidateTag('pages-sitemap')
}

return doc
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,38 @@ import type { Post } from '../../../payload-types'
export const revalidatePost: CollectionAfterChangeHook<Post> = ({
doc,
previousDoc,
req: { payload },
req: { payload, context },
}) => {
if (doc._status === 'published') {
const path = `/posts/${doc.slug}`
if (!context.disableRevalidate) {
if (doc._status === 'published') {
const path = `/posts/${doc.slug}`

payload.logger.info(`Revalidating post at path: ${path}`)
payload.logger.info(`Revalidating post at path: ${path}`)

revalidatePath(path)
revalidateTag('posts-sitemap')
}
revalidatePath(path)
revalidateTag('posts-sitemap')
}

// If the post was previously published, we need to revalidate the old path
if (previousDoc._status === 'published' && doc._status !== 'published') {
const oldPath = `/posts/${previousDoc.slug}`
// If the post was previously published, we need to revalidate the old path
if (previousDoc._status === 'published' && doc._status !== 'published') {
const oldPath = `/posts/${previousDoc.slug}`

payload.logger.info(`Revalidating old post at path: ${oldPath}`)
payload.logger.info(`Revalidating old post at path: ${oldPath}`)

revalidatePath(oldPath)
revalidateTag('posts-sitemap')
revalidatePath(oldPath)
revalidateTag('posts-sitemap')
}
}

return doc
}

export const revalidateDelete: CollectionAfterDeleteHook<Post> = ({ doc }) => {
const path = `/posts/${doc?.slug}`
export const revalidateDelete: CollectionAfterDeleteHook<Post> = ({ doc, req: { context } }) => {
if (!context.disableRevalidate) {
const path = `/posts/${doc?.slug}`

revalidatePath(path)
revalidateTag('posts-sitemap')
revalidatePath(path)
revalidateTag('posts-sitemap')
}

return doc
}
Loading

0 comments on commit fa39b37

Please sign in to comment.