Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: add pagination

Isaiah Hamilton2c0997da7d78
diff --git a/apps/temp-docs/components/pagination.tsx b/apps/temp-docs/components/pagination.tsx
new file mode 100644
index 00000000000..22705d3acae
--- /dev/null
+++ b/apps/temp-docs/components/pagination.tsx
@@ -0,0 +1,62 @@
+import Link from 'next/link'
+import { useRouter } from 'next/router'
+
+const pagination = () => {
+ const router = useRouter()
+ const Page: any = router.query.page || 1
+ const page = parseInt(Page)
+ return (
+ <ul className="flex justify-center space-x-1 text-xs font-medium">
+ <li>
+ <Link href="/discussions?page=1">
+ <a className="inline-flex h-8 w-8 items-center justify-center rounded border border-scale-600 bg-scale-300">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ className="h-3 w-3"
+ viewBox="0 0 20 20"
+ fill="currentColor"
+ >
+ <path
+ fill-rule="evenodd"
+ d="M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z"
+ clip-rule="evenodd"
+ />
+ </svg>
+ </a>
+ </Link>
+ </li>
+ {[1, 2, 3, 4, 5].map((element: any, i: number) => {
+ i = i + 1
+ return (
+ <li key={i}>
+ <Link href={`/discussions?page=${i}`}>
+ <a className={`inline-flex h-8 w-8 items-center justify-center rounded border border-scale-600 ${page === i ? "bg-brand-900" : "bg-scale-300"}`}>
+ {i}
+ </a>
+ </Link>
+ </li>
+ )
+ })}
+ <li>
+ <Link href="/discussions?page=1">
+ <a className="inline-flex h-8 w-8 items-center justify-center rounded border border-scale-600 bg-scale-300">
+ <svg
+ xmlns="http://www.w3.org/2000/svg"
+ className="h-3 w-3"
+ viewBox="0 0 20 20"
+ fill="currentColor"
+ >
+ <path
+ fill-rule="evenodd"
+ d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
+ clip-rule="evenodd"
+ />
+ </svg>
+ </a>
+ </Link>
+ </li>
+ </ul>
+ )
+}
+
+export default pagination
diff --git a/apps/temp-docs/pages/discussions/index.tsx b/apps/temp-docs/pages/discussions/index.tsx
index 8d711072e03..72d8c97dfe0 100644
--- a/apps/temp-docs/pages/discussions/index.tsx
+++ b/apps/temp-docs/pages/discussions/index.tsx
@@ -4,8 +4,13 @@ import Layout from '../../components/layouts/Layout'
import { IconArrowUp, IconCheckCircle } from '@supabase/ui'
import Image from 'next/image'
import Link from 'next/link'
+import Pagination from '../../components/pagination'
+
+export async function getStaticProps(context: { query: { page: number } }) {
+ const Page: any = context.query?.page || 1
+ const page = parseInt(Page)
+ console.log(page)
-export async function getStaticProps() {
const httpLink = createHttpLink({
uri: 'https://api.github.com/graphql',
})
@@ -51,7 +56,7 @@ export async function getStaticProps() {
}
totalCount
}
- discussions(first: 10) {
+ discussions(first: ${page}0) {
nodes {
id
number
@@ -269,6 +274,9 @@ const discussions = ({ data }: any) => {
)
})}
</div>
+ <div>
+ <Pagination />
+ </div>
</div>
</Layout>
)