Skip to content

Commit

Permalink
fix: fix ssg for blog posts
Browse files Browse the repository at this point in the history
  • Loading branch information
mehdibha committed Dec 27, 2023
1 parent 735f924 commit 68d20e4
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 31 deletions.
31 changes: 31 additions & 0 deletions apps/marketing/src/app/blog/[postSlug]/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
import React from "react";
import { Metadata } from "next";
import { notFound } from "next/navigation";
import { CallToAction } from "@/components/call-to-action";
import { getAllPosts, getPostBySlug } from "@/lib/posts";
import { siteConfig } from "@/config";

interface PostLayoutProps {
params: {
postSlug: string;
};
children: React.ReactNode;
}

const config = siteConfig.pricingPage;

export async function generateMetadata({ params }: PostLayoutProps): Promise<Metadata> {
const post = getPostBySlug(params.postSlug);
if (!post) {
notFound();
}
return {
title: post.metadata.title,
description: post.metadata.summary,
keywords: post.metadata.keywords,
openGraph: {
title: post.metadata.title,
description: post.metadata.summary,
images: post.metadata.thumbnail ? [post.metadata.thumbnail] : undefined,
},
};
}

export async function generateStaticParams() {
const posts = getAllPosts();

return posts.map((post) => ({
postSlug: post.slug,
}));
}

const PostLayout = (props: PostLayoutProps) => {
const { children } = props;
return (
Expand Down
30 changes: 1 addition & 29 deletions apps/marketing/src/app/blog/[postSlug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,8 @@
import { Metadata } from "next";
import { notFound } from "next/navigation";
import { Badge } from "@turbocharger/ui";
import { formatDate } from "@turbocharger/utils";
import { MDX } from "@/components/mdx";
import { getAllPosts, getPostBySlug } from "@/lib/posts";

export async function generateMetadata({ params }: PostPageProps): Promise<Metadata> {
const post = getPostBySlug(params.postSlug);
if (!post) {
notFound();
}
return {
title: post.metadata.title,
description: post.metadata.summary,
keywords: post.metadata.keywords,
openGraph: {
title: post.metadata.title,
description: post.metadata.summary,
images: post.metadata.thumbnail ? [post.metadata.thumbnail] : undefined,
},
};
}

export async function generateStaticParams() {
const posts = getAllPosts();

return posts.map((post) => ({
params: {
postSlug: post.slug,
},
}));
}
import { getPostBySlug } from "@/lib/posts";

interface PostPageProps {
params: {
Expand Down
1 change: 0 additions & 1 deletion apps/marketing/src/app/blog/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const metadata: Metadata = {

export default async function BlogPage() {
const posts = getAllPosts();
console.log(posts);

return (
<div className="container max-w-7xl pt-12">
Expand Down
2 changes: 1 addition & 1 deletion apps/marketing/src/components/hero.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const Hero = (props: HeroProps) => {
const { headline, subheadline, cta, demoVideo, companies } = props;
return (
<section className="px-6">
<h1 className="animate-in fade-in zoom-in font-display text-center text-3xl sm:text-4xl md:text-5xl lg:text-6xl">
<h1 className="font-display text-center text-3xl sm:text-4xl md:text-5xl lg:text-6xl">
{headline.split("\n").map((line, index) => (
<span key={index}>
{stringReplace(line, /\*\*(.*?)\*\*/g, (match, index) => (
Expand Down

1 comment on commit 68d20e4

@vercel
Copy link

@vercel vercel bot commented on 68d20e4 Dec 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.