Open-source status page, incident response and uptime monitoring
TypeScript alertingincident-managementmcpmcp-servermonitoringmonitoring-as-codeobservabilityon-callopen-sourcesrestatus-pagestatuspagesynthetic-monitoringterraformtinybirdtursouptimeuptime-checkeruptime-monitor
feat: pagination to next changelog (#701)
Maximilian Kaske4d8887995d1f
diff --git a/apps/web/src/app/(content)/_components/pagination.tsx b/apps/web/src/app/(content)/_components/pagination.tsxnew file mode 100644index 000000000..38c55234e--- /dev/null+++ b/apps/web/src/app/(content)/_components/pagination.tsx@@ -0,0 +1,43 @@+import Link from "next/link";+import type { Changelog } from "contentlayer/generated";+import { ChevronLeft, ChevronRight } from "lucide-react";++import { Button } from "@openstatus/ui";++export function Pagination({+ prev,+ next,+}: {+ prev?: Changelog;+ next?: Changelog;+}) {+ return (+ <div className="mx-auto flex w-full max-w-prose items-center justify-between">+ <div />+ {/* {prev ? (+ <div className="w-1/2 flex-1 text-left">+ <Button asChild variant="link">+ <Link href={`/changelog/${prev.slug}`}>+ <ChevronLeft className="mr-2 h-4 w-4" />+ <span className="truncate">{prev.title}</span>+ </Link>+ </Button>+ </div>+ ) : (+ <div />+ )} */}+ {next ? (+ <div className="w-1/2 flex-1 text-right">+ <Button asChild variant="link">+ <Link href={`/changelog/${next.slug}`}>+ <span className="truncate">{next.title}</span>+ <ChevronRight className="ml-2 h-4 w-4" />+ </Link>+ </Button>+ </div>+ ) : (+ <div />+ )}+ </div>+ );+}diff --git a/apps/web/src/app/(content)/changelog/[slug]/page.tsx b/apps/web/src/app/(content)/changelog/[slug]/page.tsxindex 8042316e3..85e2e5410 100644--- a/apps/web/src/app/(content)/changelog/[slug]/page.tsx+++ b/apps/web/src/app/(content)/changelog/[slug]/page.tsx@@ -2,6 +2,8 @@ import type { Metadata } from "next";import { notFound } from "next/navigation";import { allChangelogs } from "contentlayer/generated";+import { Separator } from "@openstatus/ui";+import {defaultMetadata,ogMetadata,@@ -10,6 +12,7 @@ import {import { Changelog } from "@/components/content/changelog";import { Shell } from "@/components/dashboard/shell";import { BackButton } from "@/components/layout/back-button";+import { Pagination } from "../../_components/pagination";// export const dynamic = "force-static";@@ -59,6 +62,20 @@ export async function generateMetadata({};}+function getChangelogPagination(slug: string) {+ const changelogs = allChangelogs.sort(+ (a, b) =>+ new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime(),+ );+ const findIndex = changelogs.findIndex(+ (changelog) => changelog.slug === slug,+ );+ return {+ prev: changelogs?.[findIndex - 1],+ next: changelogs?.[findIndex + 1],+ };+}+export default function ChangelogPage({params,}: {@@ -70,11 +87,15 @@ export default function ChangelogPage({notFound();}+ const { next, prev } = getChangelogPagination(params.slug);+return (<><BackButton href="/changelog" />- <Shell className="sm:py-8 md:py-12">+ <Shell className="flex flex-col gap-8 sm:py-8 md:gap-12 md:py-12"><Changelog post={post} />+ <Separator className="mx-auto max-w-prose" />+ <Pagination {...{ next, prev }} /></Shell></>);diff --git a/apps/web/src/app/(content)/changelog/page.tsx b/apps/web/src/app/(content)/changelog/page.tsxindex fb3d71731..2eef147d0 100644--- a/apps/web/src/app/(content)/changelog/page.tsx+++ b/apps/web/src/app/(content)/changelog/page.tsx@@ -22,8 +22,9 @@ export const metadata: Metadata = {title: "Changelog | OpenStatus",},};+export default async function Changelog() {- const posts = allChangelogs.sort(+ const changelogs = allChangelogs.sort((a, b) =>new Date(b.publishedAt).getTime() - new Date(a.publishedAt).getTime(),);@@ -34,15 +35,15 @@ export default async function Changelog() {title="Changelog"description="All the latest features, fixes and work to OpenStatus.">- {posts.map((post) => (+ {changelogs.map((changelog) => (<Timeline.Article- key={post.slug}- publishedAt={post.publishedAt}- imageSrc={post.image}- title={post.title}- href={`./changelog/${post.slug}`}+ key={changelog.slug}+ publishedAt={changelog.publishedAt}+ imageSrc={changelog.image}+ title={changelog.title}+ href={`./changelog/${changelog.slug}`}>- <Mdx code={post.body.code} />+ <Mdx code={changelog.body.code} /></Timeline.Article>))}</Timeline>diff --git a/apps/web/src/content/changelog/terraform-provider.mdx b/apps/web/src/content/changelog/terraform-provider.mdxindex 69906ad7c..99ae05c44 100644--- a/apps/web/src/content/changelog/terraform-provider.mdx+++ b/apps/web/src/content/changelog/terraform-provider.mdx@@ -10,4 +10,4 @@ This provider allows you to manage your Grafana Cloud resources using Terraform,enabling you to define and manage your OpenStatus resources as code.Here's the link to the:-https://registry.terraform.io/providers/openstatus/openstatus/latest/docs+[OpenStats Terraform Provider](https://registry.terraform.io/providers/openstatus/openstatus/latest/docs)