[fix] fix title case for post titles
This commit is contained in:
@@ -4,6 +4,7 @@ import { TPostListItem, TPostsByTag } from "@/types/post-list";
|
|||||||
import fs from "fs";
|
import fs from "fs";
|
||||||
import { serialize } from "next-mdx-remote/serialize";
|
import { serialize } from "next-mdx-remote/serialize";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
import { titleCase } from "title-case";
|
||||||
import { isEmptyString, nullifyEmptyArray, nullifyEmptyString } from "./utils";
|
import { isEmptyString, nullifyEmptyArray, nullifyEmptyString } from "./utils";
|
||||||
|
|
||||||
async function extractFrontmatters(filepath: string): Promise<TFrontmatter> {
|
async function extractFrontmatters(filepath: string): Promise<TFrontmatter> {
|
||||||
@@ -19,7 +20,7 @@ async function extractFrontmatters(filepath: string): Promise<TFrontmatter> {
|
|||||||
.map((tagname) => tagname.toUpperCase());
|
.map((tagname) => tagname.toUpperCase());
|
||||||
|
|
||||||
const normalizedResult: TFrontmatter = {
|
const normalizedResult: TFrontmatter = {
|
||||||
title: frontmatter.title,
|
title: titleCase(frontmatter.title),
|
||||||
subtitle: nullifyEmptyString(frontmatter.subtitle),
|
subtitle: nullifyEmptyString(frontmatter.subtitle),
|
||||||
coverURL: nullifyEmptyString(frontmatter.coverURL),
|
coverURL: nullifyEmptyString(frontmatter.coverURL),
|
||||||
tags: nullifyEmptyArray(normalizedTags),
|
tags: nullifyEmptyArray(normalizedTags),
|
||||||
|
|||||||
Reference in New Issue
Block a user