Add blog section, update landing page components, and fix mobile pricing header

Made-with: Cursor
This commit is contained in:
Ayush Rodrigues
2026-04-15 20:50:22 +01:00
parent a2046f1ac1
commit f6c5046c32
37 changed files with 1621 additions and 11 deletions

View File

@@ -0,0 +1,62 @@
import fs from "fs";
import path from "path";
import matter from "gray-matter";
const CONTENT_DIR = path.join(process.cwd(), "content", "blog");
export function getAllPosts() {
if (!fs.existsSync(CONTENT_DIR)) return [];
const files = fs
.readdirSync(CONTENT_DIR)
.filter((file) => file.endsWith(".mdx"));
const posts = files.map((filename) => {
const filePath = path.join(CONTENT_DIR, filename);
const raw = fs.readFileSync(filePath, "utf-8");
const { data } = matter(raw);
return {
slug: data.slug || filename.replace(/\.mdx$/, ""),
title: data.title || "Untitled",
description: data.description || "",
date: data.date || null,
author: data.author || "Autumn Team",
image: data.image || null,
};
});
return posts.sort((a, b) => {
if (!a.date || !b.date) return 0;
return new Date(b.date) - new Date(a.date);
});
}
export function getPostBySlug({ slug }) {
if (!fs.existsSync(CONTENT_DIR)) return null;
const files = fs
.readdirSync(CONTENT_DIR)
.filter((file) => file.endsWith(".mdx"));
for (const filename of files) {
const filePath = path.join(CONTENT_DIR, filename);
const raw = fs.readFileSync(filePath, "utf-8");
const { data, content } = matter(raw);
const fileSlug = data.slug || filename.replace(/\.mdx$/, "");
if (fileSlug === slug) {
return {
slug: fileSlug,
title: data.title || "Untitled",
description: data.description || "",
date: data.date || null,
author: data.author || "Autumn Team",
image: data.image || null,
source: content,
};
}
}
return null;
}