dify/web/app/components/plugins/marketplace/templates/template-pagination.tsx
Coding On Star cb6c04637b
feat(web): add marketplace creator profiles and homepage redesign (#41538)
Co-authored-by: zxhlyh <jasonapring2015@outlook.com>
Co-authored-by: fatelei <fatelei@gmail.com>
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: CodingOnStar <hanxujiang@dify.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: 姜涵煦 <hanxujiang@jianghanxudeMacBook-Pro-2.local>
Co-authored-by: L1nSn0w <l1nsn0w@qq.com>
Co-authored-by: yyh <92089059+lyzno1@users.noreply.github.com>
2026-09-04 08:09:45 +00:00

71 lines
1.7 KiB
TypeScript

import type { TemplateCategory } from './categories'
import Link from '@/next/link'
import { buildTemplatesHref, PAGE_LINK_CLASS, PAGE_LINK_DISABLED_CLASS } from './template-links'
// Server-rendered pagination: plain links keep the search results reachable
// beyond the first page without any client-side state.
export default function TemplatePagination({
category,
languages,
navigationLabel,
nextLabel,
page,
pageCount,
previousLabel,
query,
sortBy,
sortOrder,
view,
}: {
category: TemplateCategory
languages?: string[]
navigationLabel: string
nextLabel: string
page: number
pageCount: number
previousLabel: string
query: string
sortBy?: string
sortOrder?: string
view?: string
}) {
if (pageCount <= 1) return null
const buildHref = (targetPage: number) =>
buildTemplatesHref({
category,
languages,
page: targetPage,
query,
sortBy,
sortOrder,
view,
})
return (
<nav aria-label={navigationLabel} className="mt-6 flex items-center justify-center gap-3 pb-4">
{page > 1 ? (
<Link href={buildHref(page - 1)} className={PAGE_LINK_CLASS}>
{previousLabel}
</Link>
) : (
<span aria-disabled="true" className={PAGE_LINK_DISABLED_CLASS}>
{previousLabel}
</span>
)}
<span aria-current="page" className="system-sm-regular text-text-tertiary">
{page} / {pageCount}
</span>
{page < pageCount ? (
<Link href={buildHref(page + 1)} className={PAGE_LINK_CLASS}>
{nextLabel}
</Link>
) : (
<span aria-disabled="true" className={PAGE_LINK_DISABLED_CLASS}>
{nextLabel}
</span>
)}
</nav>
)
}