Urgent landing page fixes (#1724)

* don't trigger rebuild if release is draft

* be more strict about drafts

* fix
This commit is contained in:
Brendan Allan 2023-11-03 18:15:29 +08:00 committed by GitHub
parent 23e9cf0553
commit b7354a4580
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 8 deletions

View file

@ -25,6 +25,8 @@ export async function POST(req: Request) {
}
webhook.on('release', ({ payload }) => {
if (payload.release.draft) return;
revalidateTag(getRelease(payload.release.tag_name).path);
revalidateTag(getRecentReleases.path);
revalidateTag(getLatestRelease.path);

View file

@ -1,9 +1,12 @@
import { notFound } from 'next/navigation';
import { getRelease, getReleaseFrontmatter, githubFetch } from '../../github';
export const runtime = 'edge';
export async function GET(_: Request, { params }: { params: { version: string } }) {
const release = await githubFetch(getRelease(params.version));
if (release.draft) notFound();
return Response.json({
...getReleaseFrontmatter(release),

View file

@ -6,12 +6,14 @@ export async function GET() {
const releases = await githubFetch(getRecentReleases);
return Response.json(
releases.map((release) => {
return {
...getReleaseFrontmatter(release),
version: release.tag_name,
published_at: release.published_at
};
})
releases
.filter((r) => !r.draft)
.map((release) => {
return {
...getReleaseFrontmatter(release),
version: release.tag_name,
published_at: release.published_at
};
})
);
}

View file

@ -1,5 +1,6 @@
import { bundleMDX } from 'mdx-bundler';
import { getMDXComponent } from 'next-contentlayer/hooks';
import { notFound } from 'next/navigation';
import { getRelease, githubFetch } from '~/app/api/github';
import { DocMDXComponents } from '~/components/mdx';
import { toTitleCase } from '~/utils/util';
@ -29,6 +30,7 @@ export async function generateMetadata({ params }: Props) {
export default async function Page({ params }: Props) {
const release = await githubFetch(getRelease(params.tag));
if (release.draft) notFound();
const { code } = await bundleMDX({ source: processComments(release.body ?? '') });
const MDXContent = getMDXComponent(code);

View file

@ -8,7 +8,9 @@ export async function getReleasesCategories(): Promise<SectionMeta['categories']
const categories: Record<string, SectionMeta['categories'][number]> = {};
for (const release of releases) {
for (const release of releases ?? []) {
if (release.draft) continue;
const { frontmatter } = getReleaseFrontmatter(release);
const slug = frontmatter.category;