chore: migrate to payload / nextjs

This commit is contained in:
syntaxbullet
2026-06-16 13:02:47 +02:00
parent aff090b693
commit 6b395e5735
257 changed files with 33616 additions and 1451 deletions

View File

@@ -0,0 +1,57 @@
import React from 'react'
const defaultLabels = {
plural: 'Docs',
singular: 'Doc',
}
const defaultCollectionLabels = {
posts: {
plural: 'Posts',
singular: 'Post',
},
}
export const PageRange: React.FC<{
className?: string
collection?: keyof typeof defaultCollectionLabels
collectionLabels?: {
plural?: string
singular?: string
}
currentPage?: number
limit?: number
totalDocs?: number
}> = (props) => {
const {
className,
collection,
collectionLabels: collectionLabelsFromProps,
currentPage,
limit,
totalDocs,
} = props
let indexStart = (currentPage ? currentPage - 1 : 1) * (limit || 1) + 1
if (totalDocs && indexStart > totalDocs) indexStart = 0
let indexEnd = (currentPage || 1) * (limit || 1)
if (totalDocs && indexEnd > totalDocs) indexEnd = totalDocs
const { plural, singular } =
collectionLabelsFromProps ||
(collection ? defaultCollectionLabels[collection] : undefined) ||
defaultLabels ||
{}
return (
<div className={[className, 'font-semibold'].filter(Boolean).join(' ')}>
{(typeof totalDocs === 'undefined' || totalDocs === 0) && 'Search produced no results.'}
{typeof totalDocs !== 'undefined' &&
totalDocs > 0 &&
`Showing ${indexStart}${indexStart > 0 ? ` - ${indexEnd}` : ''} of ${totalDocs} ${
totalDocs > 1 ? plural : singular
}`}
</div>
)
}