Skip to content

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

Chore/changelog v2 (#18148)

Terry Suttonbae3814094db
diff --git a/apps/www/lib/mdx/mdxComponents.tsx b/apps/www/lib/mdx/mdxComponents.tsx
index 8faa84535b0..192f77d606d 100644
--- a/apps/www/lib/mdx/mdxComponents.tsx
+++ b/apps/www/lib/mdx/mdxComponents.tsx
@@ -42,7 +42,7 @@ const BlogCollapsible = ({ title, ...props }: { title: string }) => {
return (
<Collapsible_Shadcn_>
<CollapsibleTrigger_Shadcn_
- className="
+ className="
data-[state=open]:text
hover:text-foreground-light
flex items-center gap-3
@@ -88,6 +88,7 @@ export default function mdxComponents(type?: 'blog' | 'lp' | undefined) {
{...props}
className={[type === 'blog' ? 'm-0 object-cover rounded-md border' : ''].join(' ')}
fill
+ loading="lazy"
/>
</span>
)
diff --git a/apps/www/lib/mdx/mdxSerialize.ts b/apps/www/lib/mdx/mdxSerialize.ts
index c959b7223a7..42e074ea7f4 100644
--- a/apps/www/lib/mdx/mdxSerialize.ts
+++ b/apps/www/lib/mdx/mdxSerialize.ts
@@ -5,7 +5,25 @@ import remarkGfm from 'remark-gfm'
import { CodeHikeConfig, remarkCodeHike } from '@code-hike/mdx'
import codeHikeTheme from 'config/code-hike.theme.json' assert { type: 'json' }
+// mdx2 needs self-closing tags.
+// dragging an image onto a Github discussion creates an <img>
+// we need to fix this before running them through mdx
+function addSelfClosingTags(htmlString: string): string {
+ const modifiedHTML = htmlString.replace(/<img[^>]*>/g, (match) => {
+ // Check if the <img> tag already has a closing slash
+ if (match.endsWith('/>')) {
+ return match
+ } else {
+ // Add slash (/) to make it self-closing
+ return match.slice(0, -1) + ' />'
+ }
+ })
+
+ return modifiedHTML
+}
+
export async function mdxSerialize(source: string) {
+ const formattedSource = addSelfClosingTags(source)
const codeHikeOptions: CodeHikeConfig = {
theme: codeHikeTheme,
lineNumbers: true,
@@ -14,7 +32,7 @@ export async function mdxSerialize(source: string) {
autoImport: false,
}
- const mdxSource: any = await serialize(source, {
+ const mdxSource: any = await serialize(formattedSource, {
scope: {
chCodeConfig: codeHikeOptions,
},
diff --git a/apps/www/next-env.d.ts b/apps/www/next-env.d.ts
index 4f11a03dc6c..fd36f9494e2 100644
--- a/apps/www/next-env.d.ts
+++ b/apps/www/next-env.d.ts
@@ -1,5 +1,6 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />
+/// <reference types="next/navigation-types/compat/navigation" />
// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
diff --git a/apps/www/package.json b/apps/www/package.json
index a93dd427fa1..398ed77fdc0 100644
--- a/apps/www/package.json
+++ b/apps/www/package.json
@@ -16,6 +16,7 @@
"@code-hike/mdx": "^0.9.0",
"@heroicons/react": "^1.0.6",
"@mdx-js/react": "^2.3.0",
+ "@octokit/rest": "^20.0.2",
"@next/bundle-analyzer": "^13.5.6",
"@next/mdx": "^13.5.6",
"@react-three/fiber": "^7.0.29",
diff --git a/apps/www/pages/changelog.tsx b/apps/www/pages/changelog.tsx
index 88551197777..f0697f54b79 100644
--- a/apps/www/pages/changelog.tsx
+++ b/apps/www/pages/changelog.tsx
@@ -6,12 +6,142 @@ import CTABanner from '~/components/CTABanner'
import DefaultLayout from '~/components/Layouts/Default'
import mdxComponents from '~/lib/mdx/mdxComponents'
import { mdxSerialize } from '~/lib/mdx/mdxSerialize'
+import { createAppAuth } from '@octokit/auth-app'
+import { Octokit } from '@octokit/core'
+import { Octokit as OctokitRest } from '@octokit/rest'
+import { paginateGraphql } from '@octokit/plugin-paginate-graphql'
+import { GetServerSideProps } from 'next'
+import Link from 'next/link'
+import { ArrowLeftIcon, ArrowRightIcon } from '@heroicons/react/outline'
-export async function getStaticProps() {
- const response = await fetch('https://api.github.com/repos/supabase/supabase/releases')
- const data = await response.json()
+export const ExtendedOctokit = Octokit.plugin(paginateGraphql)
+export type ExtendedOctokit = InstanceType<typeof ExtendedOctokit>
- if (!data) {
+export type Discussion = {
+ id: string
+ updatedAt: string
+ url: string
+ title: string
+ body: string
+}
+
+type Entry = {
+ id: string
+ title: string
+ url: string
+ created_at: string
+ source: MDXRemoteSerializeResult
+ type: string
+}
+
+export type DiscussionsResponse = {
+ repository: {
+ discussions: {
+ totalCount: number
+ nodes: Discussion[]
+ pageInfo: any
+ }
+ }
+}
+
+/**
+ * [Terry]
+ * this page powers supabase.com/changelog
+ * this page used to just be a feed of the releases endpoint
+ * (https://api.github.com/repos/supabase/supabase/releases) (rest api)
+ * but is now a blend of that legacy relases and the new Changelog category of the Discussions
+ * https://github.com/orgs/supabase/discussions/categories/changelog (graphql api)
+ * We should use the Changelog Discussions category for all future changelog entries and stop using releases
+ */
+
+export const getServerSideProps: GetServerSideProps = async ({ res, query }) => {
+ // refresh every 15 minutes
+ res.setHeader('Cache-Control', 'public, max-age=900, stale-while-revalidate=900')
+ const next = query.next ?? (null as string | null)
+ const restPage = query.restPage ? Number(query.restPage) : 1
+
+ const octokitRest = new OctokitRest({
+ auth: process.env.GITHUB_CHANGELOG_APP_REST_KEY,
+ })
+
+ // uses the rest api
+ async function fetchGitHubReleases() {
+ try {
+ const response = await octokitRest.repos.listReleases({
+ owner: 'supabase',
+ repo: 'supabase',
+ per_page: 10,
+ page: restPage,
+ })
+
+ return response.data || []
+ } catch (error) {
+ console.error(error)
+ return []
+ }
+ }
+
+ const releases = await fetchGitHubReleases()
+
+ // uses the graphql api
+ async function fetchDiscussions(owner: string, repo: string, categoryId: string, cursor: string) {
+ const octokit = new ExtendedOctokit({
+ authStrategy: createAppAuth,
+ auth: {
+ appId: process.env.GITHUB_CHANGELOG_APP_ID,
+ installationId: process.env.GITHUB_CHANGELOG_APP_INSTALLATION_ID,
+ privateKey: process.env.GITHUB_CHANGELOG_APP_PRIVATE_KEY,
+ },
+ })
+
+ const query = `
+ query troubleshootDiscussions($cursor: String, $owner: String!, $repo: String!, $categoryId: ID!) {
+ repository(owner: $owner, name: $repo) {
+ discussions(first: 10, after: $cursor, categoryId: $categoryId, orderBy: { field: CREATED_AT, direction: DESC }) {
+ totalCount
+ pageInfo {
+ hasPreviousPage
+ hasNextPage
+ startCursor
+ endCursor
+ }
+ nodes {
+ id
+ publishedAt
+ createdAt
+ url
+ title
+ body
+ }
+ }
+ }
+ }
+ `
+ const queryVars = {
+ owner,
+ repo,
+ categoryId,
+ cursor: next,
+ }
+
+ // fetch discussions
+ const {
+ repository: {
+ discussions: { nodes: discussions, pageInfo },
+ },
+ } = await octokit.graphql<DiscussionsResponse>(query, queryVars)
+
+ return { discussions, pageInfo }
+ }
+
+ const { discussions, pageInfo } = await fetchDiscussions(
+ 'supabase',
+ 'supabase',
+ 'DIC_kwDODMpXOc4CAFUr', // 'Changelog' category
+ next as string
+ )
+
+ if (!discussions) {
return {
props: {
notFound: true,
@@ -19,27 +149,71 @@ export async function getStaticProps() {
}
}
- const changelogRenderToString = await Promise.all(
- data.map(async (item: any): Promise<any> => {
- const mdxSource: MDXRemoteSerializeResult = await mdxSerialize(item.body)
+ // Process discussions
+ const formattedDiscussions = await Promise.all(
+ discussions.map(async (item: any): Promise<any> => {
+ const discussionsMdxSource: MDXRemoteSerializeResult = await mdxSerialize(item.body)
+
+ return {
+ ...item,
+ source: discussionsMdxSource,
+ type: 'discussion',
+ created_at: item.createdAt,
+ url: item.url,
+ }
+ })
+ )
+
+ // Process releases
+ const formattedReleases = await Promise.all(
+ releases.map(async (item: any): Promise<any> => {
+ const releasesMdxSource: MDXRemoteSerializeResult = await mdxSerialize(item.body)
+
return {
...item,
- source: mdxSource,
+ source: releasesMdxSource,
+ type: 'release',
+ created_at: item.created_at,
+ title: item.name ?? '',
+ url: item.html_url ?? '',
}
})
)
+ // Combine discussions and releases into a single array of entries
+ const combinedEntries = formattedDiscussions.concat(formattedReleases)
+
+ const sortedCombinedEntries = combinedEntries.sort((a, b) => {
+ const dateA = dayjs(a.created_at)
+ const dateB = dayjs(b.created_at)
+
+ if (dateA.isValid() && dateB.isValid()) {
+ return dateB.diff(dateA)
+ } else {
+ return 0
+ }
+ })
+
return {
props: {
- changelog: changelogRenderToString,
+ changelog: sortedCombinedEntries,
+ pageInfo: pageInfo,
+ restPage: Number(restPage),
},
}
}
-function ChangelogPage(props: any) {
+interface ChangelogPageProps {
+ changelog: Entry[]
+ pageInfo: any
+ restPage: number
+}
+
+function ChangelogPage({ changelog, pageInfo, restPage }: ChangelogPageProps) {
+ const { endCursor: end, hasNextPage, hasPreviousPage } = pageInfo
+
const TITLE = 'Changelog'
const DESCRIPTION = 'New updates and improvements to Supabase'
-
return (
<>
<NextSeo
@@ -60,42 +234,62 @@ function ChangelogPage(props: any) {
xl:px-20
"
>
- {/* Title and description */}
<div className="py-10">
<h1 className="h1">Changelog</h1>
<p className="text-foreground-lighter text-lg">New updates and product improvements</p>
</div>
{/* Content */}
- <div>
- {props.changelog.map((changelog: any, i: number) => {
- const date = changelog.published_at.split('T')
- return (
- <div key={i} className="border-muted grid border-l pb-10 lg:grid-cols-12 lg:gap-8">
- <div
- className="col-span-12 mb-8 self-start lg:sticky lg:top-0 lg:col-span-4 lg:-mt-32 lg:pt-32
+ <div className="grid gap-12 lg:gap-36">
+ {changelog.length > 0 &&
+ changelog
+ .filter((entry: Entry) => !entry.title.includes('[d]'))
+ .map((entry: Entry, i: number) => {
+ return (
+ <div key={i} className="border-muted grid border-l lg:grid-cols-12 lg:gap-8">
+ <div
+ className="col-span-12 mb-8 self-start lg:sticky lg:top-0 lg:col-span-4 lg:-mt-32 lg:pt-32
"
- >
- <div className="flex w-full items-baseline gap-6">
- <div className="bg-border border-muted text-foreground-lighter -ml-2.5 flex h-5 w-5 items-center justify-center rounded border drop-shadow-sm">
- <IconGitCommit size={14} strokeWidth={1.5} />
+ >
+ <div className="flex w-full items-baseline gap-6">
+ <div className="bg-border border-muted text-foreground-lighter -ml-2.5 flex h-5 w-5 items-center justify-center rounded border drop-shadow-sm">
+ <IconGitCommit size={14} strokeWidth={1.5} />
+ </div>
+ <div className="flex w-full flex-col gap-1">
+ {entry.title && (
+ <Link href={entry.url}>
+ <h3 className="text-foreground text-2xl">{entry.title}</h3>{' '}
+ </Link>
+ )}
+ <p className="text-muted text-lg">
+ {dayjs(entry.created_at).format('MMM D, YYYY')}
+ </p>
+ </div>
+ </div>
</div>
- <div className="flex w-full flex-col gap-1">
- {changelog.name && (
- <h3 className="text-foreground text-2xl">{changelog.name}</h3>
- )}
- <p className="text-muted text-lg">{dayjs(date[0]).format('MMM D, YYYY')}</p>
+ <div className="col-span-8 ml-8 lg:ml-0 max-w-[calc(100vw-80px)]">
+ <article className="prose prose-docs max-w-none">
+ <MDXRemote {...entry.source} components={mdxComponents('blog')} />
+ </article>
</div>
</div>
- </div>
- <div className="col-span-8 ml-8 lg:ml-0 max-w-[calc(100vw-80px)]">
- <article className="prose prose-docs max-w-none">
- <MDXRemote {...changelog.source} components={mdxComponents('blog')} />
- </article>
- </div>
- </div>
- )
- })}
+ )
+ })}
+ </div>
+ <div className="my-8 flex items-center gap-4">
+ {hasPreviousPage && (
+ <Link href={`/changelog`} className="flex items-center gap-2">
+ <ArrowLeftIcon width={14} /> Previous
+ </Link>
+ )}
+ {hasNextPage && (
+ <Link
+ href={`/changelog?next=${end}&restPage=${restPage + 1}`}
+ className="flex items-center gap-2"
+ >
+ Next <ArrowRightIcon width={14} />
+ </Link>
+ )}
</div>
</div>
diff --git a/package-lock.json b/package-lock.json
index ff891cb642e..54373306202 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1020,6 +1020,7 @@
"@mdx-js/react": "^2.3.0",
"@next/bundle-analyzer": "^13.5.6",
"@next/mdx": "^13.5.6",
+ "@octokit/rest": "^20.0.2",
"@react-three/fiber": "^7.0.29",
"@supabase/auth-helpers-react": "^0.4.2",
"@supabase/auth-ui-react": "^0.4.5",
@@ -5766,6 +5767,151 @@
"node": ">= 14"
}
},
+ "node_modules/@octokit/rest": {
+ "version": "20.0.2",
+ "resolved": "https://registry.npmjs.org/@octokit/rest/-/rest-20.0.2.tgz",
+ "integrity": "sha512-Ux8NDgEraQ/DMAU1PlAohyfBBXDwhnX2j33Z1nJNziqAfHi70PuxkFYIcIt8aIAxtRE7KVuKp8lSR8pA0J5iOQ==",
+ "dependencies": {
+ "@octokit/core": "^5.0.0",
+ "@octokit/plugin-paginate-rest": "^9.0.0",
+ "@octokit/plugin-request-log": "^4.0.0",
+ "@octokit/plugin-rest-endpoint-methods": "^10.0.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/rest/node_modules/@octokit/auth-token": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz",
+ "integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==",
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/rest/node_modules/@octokit/core": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.0.1.tgz",
+ "integrity": "sha512-lyeeeZyESFo+ffI801SaBKmCfsvarO+dgV8/0gD8u1d87clbEdWsP5yC+dSj3zLhb2eIf5SJrn6vDz9AheETHw==",
+ "dependencies": {
+ "@octokit/auth-token": "^4.0.0",
+ "@octokit/graphql": "^7.0.0",
+ "@octokit/request": "^8.0.2",
+ "@octokit/request-error": "^5.0.0",
+ "@octokit/types": "^12.0.0",
+ "before-after-hook": "^2.2.0",
+ "universal-user-agent": "^6.0.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/rest/node_modules/@octokit/endpoint": {
+ "version": "9.0.2",
+ "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.2.tgz",
+ "integrity": "sha512-qhKW8YLIi+Kmc92FQUFGr++DYtkx/1fBv+Thua6baqnjnOsgBYJDCvWZR1YcINuHGOEQt416WOfE+A/oG60NBQ==",
+ "dependencies": {
+ "@octokit/types": "^12.0.0",
+ "is-plain-object": "^5.0.0",
+ "universal-user-agent": "^6.0.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/rest/node_modules/@octokit/graphql": {
+ "version": "7.0.2",
+ "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.0.2.tgz",
+ "integrity": "sha512-OJ2iGMtj5Tg3s6RaXH22cJcxXRi7Y3EBqbHTBRq+PQAqfaS8f/236fUrWhfSn8P4jovyzqucxme7/vWSSZBX2Q==",
+ "dependencies": {
+ "@octokit/request": "^8.0.1",
+ "@octokit/types": "^12.0.0",
+ "universal-user-agent": "^6.0.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/rest/node_modules/@octokit/openapi-types": {
+ "version": "19.0.2",
+ "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-19.0.2.tgz",
+ "integrity": "sha512-8li32fUDUeml/ACRp/njCWTsk5t17cfTM1jp9n08pBrqs5cDFJubtjsSnuz56r5Tad6jdEPJld7LxNp9dNcyjQ=="
+ },
+ "node_modules/@octokit/rest/node_modules/@octokit/plugin-paginate-rest": {
+ "version": "9.1.4",
+ "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-9.1.4.tgz",
+ "integrity": "sha512-MvZx4WvfhBnt7PtH5XE7HORsO7bBk4er1FgRIUr1qJ89NR2I6bWjGyKsxk8z42FPQ34hFQm0Baanh4gzdZR4gQ==",
+ "dependencies": {
+ "@octokit/types": "^12.3.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ },
+ "peerDependencies": {
+ "@octokit/core": ">=5"
+ }
+ },
+ "node_modules/@octokit/rest/node_modules/@octokit/plugin-request-log": {
+ "version": "4.0.0",
+ "resolved": "https://registry.npmjs.org/@octokit/plugin-request-log/-/plugin-request-log-4.0.0.tgz",
+ "integrity": "sha512-2uJI1COtYCq8Z4yNSnM231TgH50bRkheQ9+aH8TnZanB6QilOnx8RMD2qsnamSOXtDj0ilxvevf5fGsBhBBzKA==",
+ "engines": {
+ "node": ">= 18"
+ },
+ "peerDependencies": {
+ "@octokit/core": ">=5"
+ }
+ },
+ "node_modules/@octokit/rest/node_modules/@octokit/plugin-rest-endpoint-methods": {
+ "version": "10.1.5",
+ "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.1.5.tgz",
+ "integrity": "sha512-LMEdsMV8TTMjMTqVoqMzV95XTbv0ZsWxCxQtjAunQOCdwoDH4BVF/Ke5JMSZEVCWGI2kzxnUNbFnK/MxwV7NjA==",
+ "dependencies": {
+ "@octokit/types": "^12.3.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ },
+ "peerDependencies": {
+ "@octokit/core": ">=5"
+ }
+ },
+ "node_modules/@octokit/rest/node_modules/@octokit/request": {
+ "version": "8.1.5",
+ "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.1.5.tgz",
+ "integrity": "sha512-zVKbNbX1xUluD9ZR4/tPs1yuYrK9xeh5fGZUXA6u04XGsTvomg0YO8/ZUC0FqAd49hAOEMFPAVUTh+2lBhOhLA==",
+ "dependencies": {
+ "@octokit/endpoint": "^9.0.0",
+ "@octokit/request-error": "^5.0.0",
+ "@octokit/types": "^12.0.0",
+ "is-plain-object": "^5.0.0",
+ "universal-user-agent": "^6.0.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/rest/node_modules/@octokit/request-error": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz",
+ "integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==",
+ "dependencies": {
+ "@octokit/types": "^12.0.0",
+ "deprecation": "^2.0.0",
+ "once": "^1.4.0"
+ },
+ "engines": {
+ "node": ">= 18"
+ }
+ },
+ "node_modules/@octokit/rest/node_modules/@octokit/types": {
+ "version": "12.3.0",
+ "resolved": "https://registry.npmjs.org/@octokit/types/-/types-12.3.0.tgz",
+ "integrity": "sha512-nJ8X2HRr234q3w/FcovDlA+ttUU4m1eJAourvfUUtwAWeqL8AsyRqfnLvVnYn3NFbUnsmzQCzLNdFerPwdmcDQ==",
+ "dependencies": {
+ "@octokit/openapi-types": "^19.0.2"
+ }
+ },
"node_modules/@octokit/tsconfig": {
"version": "1.0.2",
"license": "MIT"