Skip to content

Commit

Permalink
fix: blogs not showing fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ashgw committed Feb 10, 2024
1 parent 7e6835b commit 2b860ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/app/actions/blog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export async function getPost(slug: string): Promise<Maybe<BlogData>> {
return;
}
}
export async function getBlogPosts(): Promise<Maybe<BlogData[]>> {
export async function getBlogPosts() {
try {
const response = await fetch(SITE_URL + BLOG_API_URI, {
cache: 'force-cache',
Expand Down
10 changes: 5 additions & 5 deletions src/app/api/blogs/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export type _MaybeBlogData = {
filenameSlug: string;
};

function parseMDX(content: string): MDXData {
function parseMDX(content: string) {
return fm(content) as MDXData;
}

async function getMDXFileNames(dir: string): Promise<Maybe<string[]>> {
async function getMDXFileNames(dir: string) {
try {
const files = await fsPromises.readdir(dir);
const names = files.filter((file) => path.extname(file) === '.mdx');
Expand All @@ -29,7 +29,7 @@ async function getMDXFileNames(dir: string): Promise<Maybe<string[]>> {
}
}

async function readMDXFile(filePath: string): Promise<Maybe<MDXData>> {
async function readMDXFile(filePath: string) {
try {
let rawContent = await fsPromises.readFile(filePath, 'utf-8');
return parseMDX(rawContent);
Expand All @@ -39,7 +39,7 @@ async function readMDXFile(filePath: string): Promise<Maybe<MDXData>> {
}
}

async function getMDXData(dir: string): Promise<Maybe<_MaybeBlogData[]>> {
async function getMDXData(dir: string) {
let mdxFiles = await getMDXFileNames(dir);
if (mdxFiles === undefined) {
return;
Expand All @@ -56,6 +56,6 @@ async function getMDXData(dir: string): Promise<Maybe<_MaybeBlogData[]>> {
return Promise.all(blogDataPromises);
}

export async function getBlogPosts(): Promise<Maybe<_MaybeBlogData[]>> {
export async function getBlogPosts() {
return getMDXData(MDX_DIR);
}

0 comments on commit 2b860ee

Please sign in to comment.